2

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.

2 Answers2

1

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.

JacksonB
  • 349
  • 1
  • 5
1

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%20API%20provides%20the%20ability%20to%20exchange%20data,below%20is%20used%20by%20ThingsBoard%20open-source%20IoT%20Gateway.

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.

mdeuchert
  • 248
  • 2
  • 8
  • Can you bring an example ? – taha akhlaghpasndi Mar 22 '22 at 20:43
  • General MQTT examples in the documention: https://thingsboard.io/docs/reference/mqtt-api/ 1. First create the Gateway device (Set "Is gateway" to true) 2. Copy ACCESS_TOKEN of Gateway device 3. Send data via MQTT (example shows mosquitto, also many clients available for e.g. Python) **Important**: Use topic v1/gateway/telemetry and Gateway ACCESS_TOKEN. Provide Device Name in Payload (https://thingsboard.io/docs/reference/gateway-mqtt-api/#:%7E:text=Gateway%20API%20provides%20the%20ability%20to%20exchange%20data,below%20is%20used%20by%20ThingsBoard%20open-source%20IoT%20Gateway) – mdeuchert Mar 23 '22 at 11:01