Home > OS >  thingsboard send multiple data to device with http api with curl in cmd
thingsboard send multiple data to device with http api with curl in cmd

Time:03-21

i am trying to send two number to thingsboard iot platform. send one data is like this : curl -v POST --data "{"photoresistor":10}" https://thingsboard.cloud/api/v1/nIjlT58Xo81AdU2Pwymm/telemetry --header "Content-Type:application/json"

but i do not know how to send two data to thingsboard . in my search i saw this

curl -v -X POST --data "{"temperature":42,"humidity":73}" https://demo.thingsboard.io/api/v1/ABC123/telemetry --header "Content-Type:application/json"

form https://thingsboard.io/docs/reference/http-api/

but any device should have one $ACCESS_TOKEN . and i can not use above command with two data "{"temperature":42,"humidity":73}" . because every device need one ACCESS_TOKEN.

please help me to solve this problem. thanks.

CodePudding user response:

If you're using Thingsboard CE then you will need to get creative if you don't want to use access tokens. Possibly look at AWS lambda functions to act as a middle-man to forward messages.

If you're using Thingsboard PE then instead of posting to the device directly using it's ACCESS_TOKEN, you can use Integrations & Data Converters.

CodePudding user response:

There is also a way to achieve this with ThingsBoard CE. You could use the MQTT Gateway API:

"Gateway API provides the ability to exchange data between multiple devices and the platform using single MQTT connection."

https://thingsboard.io/docs/reference/gateway-mqtt-api/#:~:text=Gateway API provides the ability to exchange data,below is used by ThingsBoard open-source IoT Gateway.

Still ACCESS_TOKEN is needed, but only one for the Gateway. You can publish messages of multiple devices in a single connection. Each device is identified by it's name. Also not existing devices are created automatically.

  • Related