This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

sending data to thingsboard.io
#2
For HTTP use this:
Code:
1234567891011121314151617181920212223
require('json') require('ltn12') require('socket.http') body = json.encode({ temperature = 25 }) response = {} res, code = socket.http.request({   url = 'http://demo.thingsboard.io/api/v1/eoKkkZ6JL7UbmyOHGX9L/telemetry',   method = 'POST',   headers = {     ['Content-Type'] = 'application/json',     ['Content-Length'] = #body,   },   source = ltn12.source.string(body),   sink = ltn12.sink.table(response), }) if res and code == 200 then   log('request ok') else   log('request error', code, table.concat(response)) end

For MQTT search the forum, there are many examples of how to use it. The data must be encoded using JSON, same as for HTTP requests.
Reply


Messages In This Thread
sending data to thingsboard.io - by gdimaria - 22.11.2023, 11:06
RE: sending data to thingsboard.io - by admin - 22.11.2023, 11:12
RE: sending data to thingsboard.io - by admin - 22.11.2023, 13:38
RE: sending data to thingsboard.io - by admin - 27.11.2023, 14:45

Forum Jump: