<
From version < 161.1 >
edited by Dilisi S
on 2025/03/18 04:12
To version < 157.1 >
edited by Dilisi S
on 2025/03/17 01:45
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -458,7 +458,6 @@
458 458  * **Topic: v1/devices/+/telemetry** (the + replaces any 'device name' will create a device in the Entities -> Devices)
459 459  * **QoS:** 0-At most once
460 460  
461 -
462 462  [[image:add-integration-connection.png||height="511" width="500"]]
463 463  
464 464  
... ... @@ -501,24 +501,36 @@
501 501  
502 502  We use the Mosquitto MQTT client to simulate MQTT messages, acting as a virtual device. First, install the Mosquitto client on your computer from [[this link>>url:https://mosquitto.org/download/]]. The Mosquitto client publishes messages to the MQTT broker (HiveMQ) on a specified MQTT topic. ThingsBoard subscribes to these messages using the same topic.
503 503  
504 -The Mosquitto client publishes messages (payloads) on the topic **v1/devices/me/telemetry**. Of course, you can use any topic for testing.
503 +The Mosquitto client publishes messages on the topic v1/devices/[device_name]/telemetry. The [device_name]placeholder can be replaced with any device name, for example, 'S31B-NB'. Then, the MQTT topic would be v1/devices/S31B-NB/telemetry.
505 505  
506 -(% id="cke_bm_37386S" style="display:none" %) (%%)The MQTT payload format is as follows, which is common for all **~-~-NB** and **~-~-CB** series devices. The **IMEI** field is mandatory and is used to provision a new device with the name assigned to it in ThingsBoard.
505 +On the ThingsBoard side, we configure the MQTT topic subscription as v1/devices/+/telemetry. The + wildcard represents any device name and allows ThingsBoard to automatically create (provision) a device with that name, such as S31B-NB, for example.
507 507  
507 +
508 +**The new device is created the first time the MQTT topic is received. For subsequent MQTT topics with the same device name, no duplicate devices will be created.**
509 +
510 +
511 +For example, if you send two MQTT messages with different device names in the topic:
512 +
513 +1. v1/devices/**S31B-NB**/telemetry
514 +1. v1/devices/**LDS25-NB**/telemetry
515 +
516 +ThingsBoard will create two devices named **S31B-NB** and **LDS25-NB** in the **//Devices//** section.
517 +
518 +
519 +The MQTT payload format is as follows, which is common for all ~-~-NB and ~-~-CB series devices:
520 +
508 508  {{code language="none"}}
509 -{"IMEI": "S31B-NB", "temperature": 27, ......}
522 +{"temperature":10.4, "humidity":85}
510 510  {{/code}}
511 511  
512 -Once ThingsBoard receives this message, it automatically creates (provisions) the device mentioned in the **IMEI**, for example, S31B-NB.
513 513  
514 -
515 515  == 5.2 Sending messages ==
516 516  
517 517  
518 -On the terminal, issue the following MQTT command which simulates the device S31B-NB. The message payload contains the fields temperature and humidity, which hold the values S31B-NB and 27, respectively. This payload is also (technically) known as telemetry.
529 +On the terminal, issue the following MQTT command which simulates the device S31B-NB. The message payload contains the fields temperature and humidity, which hold the values 10.4 and 85, respectively. This payload is also (technically) known as telemetry.
519 519  
520 520  {{code language="none"}}
521 -mosquitto_pub -d -q 1 -h 011731f7928xxxxx.s1.eu.hivemq.cloud -p 8883 -t "v1/devices/me/telemetry" -u "xxxxx" -P "xxxxx" -m '{"IMEI": "S31B-NB", "temperature": 27}'
532 +mosquitto_pub -d -q 1 -h 011731f7928xxxxx.s1.eu.hivemq.cloud -p 8883 -t "tb/mqtt-integration-tutorial/sensors/S31B-NB/telemetry" -u "xxxxx" -P "xxxxx" -m '{"temperature":10.4, "humidity":85}'
522 522  {{/code}}
523 523  
524 524  If the integration was performed without errors, the status of the integration changes to 'Active' after the first telemetry transmission.
... ... @@ -530,10 +530,9 @@
530 530  Also, a new device named **S31B-NB** will appear under **//Entities -> Devices -> All//**. This means the first MQTT message triggers ThingsBoard to provision a device named **S31B-NB**.
531 531  
532 532  
544 +[[image:device-provision-1.png]]
533 533  
534 -[[image:new-device.png]]
535 535  
536 -
537 537  Click on the device S31B-NB on the devices list to see its details.
538 538  
539 539  Then go to the **Latest telemetry** tab.
add-integration-connection.png
Size
... ... @@ -1,1 +1,1 @@
1 -153.2 KB
1 +124.4 KB
Content
new-device.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.pradeeka
Size
... ... @@ -1,1 +1,0 @@
1 -143.3 KB
Content
Copyright ©2010-2024 Dragino Technology Co., LTD. All rights reserved
Dragino Wiki v2.0