Changes for page ThingsBoard
Last modified by Dilisi S on 2025/04/23 19:23
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Attachments (2 modified, 0 added, 8 removed)
Details
- Page properties
-
- Content
-
... ... @@ -164,16 +164,13 @@ 164 164 [[image:ins1.png||height="310" width="500"]] 165 165 166 166 167 -= 3. Creating Devices (Optional)=167 += 3. Creating Devices = 168 168 169 -{{info}} 170 -**The following procedure is optional. If you haven't created any device in ThingsBoard first, ThingsBoard will automatically create a device for you based on the integration settings (the device name defined in the uplink decoder) just after it receives the first uplink from your device.Type your information message here.** 171 -{{/info}} 172 172 173 173 First, you need to create devices in ThingsBoard to represent your physical devices. For example, you can name it **Device A**, and the second device could be **Device B** or any name you prefer. The device name should be unique within the **Devices** space. 174 174 175 175 176 -In the left navigation, click **Entities -> Devices**.173 +In the left navigation, click Entities -> Devices. 177 177 178 178 Click the **Add Device** button (the button with the **+** sign), and from the dropdown menu, click **Add new device**. 179 179 ... ... @@ -208,31 +208,29 @@ 208 208 [[image:create-new-converter-menu.png||height="259" width="500"]] 209 209 210 210 211 -The **Add data converter** window will appear. 208 +The **Add data converter** window will appear. Name it ‘**MQTT Uplink Converter NB/CB**’ and select the Type as **Uplink**. 212 212 213 -Let's create an uplink data converter for the device named '**Device A**'. Name it ‘**MQTT Uplink Converter - Device A**’ and select the Type as **Uplink**. 214 - 215 215 Click on the **TBEL** button if it has not been selected by default. 216 216 217 217 Modify the default TBEL function to match with your device as described below: 218 218 219 219 220 - *Uncomment**line 11**:215 +~1. Uncomment line 11: 221 221 222 - //var data = decodeToJson(payload)//217 +var data = decodeToJson(payload) 223 223 219 +[[image:Screenshot 2025-03-26 at 18.15.08.png||height="219" width="500"]] 224 224 225 -* **Line 13**: Assign your device name to the **deviceName** field. - We used **Device A** as it is to match with our device, **Device A **in the Devices section. 226 -* From **line 38**: Modify the telemetry section to allow parsed data to be assigned to the fields. 227 227 228 -//telemetry: { 222 +3. Modify the telemetry section to allow parsed data to be assigned to the fields. 223 + 224 +telemetry: { 229 229 temperature: data.temperature, 230 230 humidity: data.humidity, 231 231 rawData: payloadStr 232 - } //228 + } 233 233 234 234 235 -The modified uplink decoder function to match with **Device A** is shown below. 236 236 237 237 {{code language="JavaScript"}} 238 238 // Decode an uplink message from a buffer ... ... @@ -247,7 +247,7 @@ 247 247 // decode payload to JSON 248 248 var data = decodeToJson(payload); 249 249 250 -var deviceName = 'Device A';245 +var deviceName = 'Device B'; 251 251 var deviceType = 'thermostat'; 252 252 var customerName = 'Customer C'; 253 253 var groupName = 'thermostat devices'; ... ... @@ -284,21 +284,33 @@ 284 284 return result; 285 285 {{/code}} 286 286 282 +We use the same decoder function for all our devices. However, you need to modify a few things for each device. Among these, **deviceName** is a **mandatory** field. You should assign a device name to the **deviceName** field that matches the name of your device in the **Devices** section. 287 287 284 +For example, if your device name is **Device B**, you can change **Device A** to **Device B**. 285 + 286 + 287 +{{code language="JavaScript"}} 288 +var deviceName = 'Device A'; 289 +var deviceType = 'thermostat'; 290 +var customerName = 'Customer C'; 291 +var groupName = 'thermostat devices'; 292 +var manufacturer = 'Example corporation'; 293 +{{/code}} 294 + 295 + 288 288 Once you modify the decoder function, click on the **Add** button. 289 289 290 290 299 +[[image:mqtt-uplink.png||width="500"]] 291 291 292 -[[image:ul-data-converter-device-a.png||height="524" width="500"]] 293 293 294 294 295 295 You should see that the newly added **MQTT Uplink converter **NB/CB is listed on the **Data Converters** page. 296 296 297 297 298 -[[image: ul-data-converter-added.png||height="257"]]306 +[[image:data-converter-list-showing-uplink-dc.png]] 299 299 300 300 301 - 302 302 = 5. Add Integration = 303 303 304 304 ... ... @@ -319,7 +319,7 @@ 319 319 **Basic settings:** 320 320 321 321 * **Integration type**: MQTT 322 -* **Name**: MQTT integration - Device A329 +* **Name**: MQTT integration NB/CB 323 323 * **Enable integration**: YES 324 324 * **Allows create devices or assets**: YES 325 325 ... ... @@ -326,11 +326,9 @@ 326 326 Click **Next** button. 327 327 328 328 329 -[[image:add-integration-basic-settings.png||height="5 04" width="500"]]336 +[[image:add-integration-basic-settings.png||height="511" width="500"]] 330 330 331 331 332 - 333 - 334 334 **Uplink data converter:** 335 335 336 336 * Click on the **Select existing** button. ... ... @@ -339,10 +339,9 @@ 339 339 Click **Next** button. 340 340 341 341 342 -[[image:add-integration-ul-data-converter.png||height="5 05" width="500"]]347 +[[image:add-integration-uplink-data-converter.png||height="511" width="500"]] 343 343 344 344 345 - 346 346 **Downlink data converter:** 347 347 348 348 Dragino NB/CB devices don't require a downlink data converter to decode their payloads, so you can skip this step. ... ... @@ -358,16 +358,16 @@ 358 358 359 359 **Connection:** 360 360 361 -* **Host**: Host365 +* **Host**: Cluster URL (Eg. **//011731f7xxxxxxxxxxxfbbedfc63f4.s1.eu.hivemq.cloud//**) 362 362 * **Port**: 8883 363 -* **Credentials type**: Basic 367 +* **Credentials**: Basic 368 +* **Enable SSL**: YES 364 364 * **Username**: Username (from your HiveMQ Cloud Cluster with your credentials) 365 365 * **Password:** Password (from your HiveMQ Cloud Cluster with your credentials) 366 -* **Enable SSL**: YES 367 -* **Topic: device/a** (The topic can be anything; you can even use just the device name.) 371 +* **Topic: v1/devices/me/telemetry** (The topic can be anything; you can even use just the device name. For example, you can use your device name here, such as devices/a/telemetry.) 368 368 * **QoS:** 0-At most once 369 369 370 -[[image:add-integ artion-connection.png||height="505" width="500"]]374 +[[image:add-integration-connection.png||height="511" width="500"]] 371 371 372 372 373 373 Click on the **Advanced settings** button. ... ... @@ -397,10 +397,9 @@ 397 397 Since we haven't received data from a device yet, the integration **Status** is shown as **Pending.** 398 398 399 399 400 -[[image:integration- added.png]]404 +[[image:new-integration-pending.png]] 401 401 402 402 403 - 404 404 = 6. Verifying the receipt of data from virtual devices = 405 405 406 406 ... ... @@ -409,24 +409,24 @@ 409 409 410 410 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. 411 411 412 -The Mosquitto client publishes messages (payloads) on the topic **/device/ a**. Of course, you can use any topic for testing.415 +The Mosquitto client publishes messages (payloads) on the topic **v1/devices/me/telemetry**. Of course, you can use any topic for testing. 413 413 414 -(% id="cke_bm_37386S" style="display:none" %) (%%)The MQTT payload format is as follows :417 +(% 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. 415 415 416 416 {{code language="none"}} 417 -{"IMEI": "3 50693903995577", "temperature":25,"humidity":80, "pressure":1005}420 +{"IMEI": "S31B-NB", "temperature": 27, ......} 418 418 {{/code}} 419 419 420 -Once ThingsBoard receives this message, it forwardsthis payloadto thematchingdevice through the integration.423 +Once ThingsBoard receives this message, it automatically creates (provisions) the device mentioned in the **IMEI**, for example, S31B-NB. 421 421 422 422 423 423 == 5.2 Sending messages == 424 424 425 425 426 -On your computer'sterminal, issue the following MQTT command which simulates the device'**Device A'**. The message payload contains the fieldsIMEI,temperature,humidity,and pressure,which hold the values 350693903995577,30, 80,and1005respectively. This payload is also (technically) known as telemetry.429 +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. 427 427 428 428 {{code language="none"}} 429 -mosquitto_pub -d -q 1 -h 011731f7928xxxxx.s1.eu.hivemq.cloud -p 8883 -u "xxxxx" -P "xxxxx" - t "device/a" -m '{"IMEI":"350693903995577", "temperature":30,"humidity":80, "pressure":1005}'432 +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}' 430 430 {{/code}} 431 431 432 432 If the integration was performed without errors, the status of the integration changes to 'Active' after the first telemetry transmission. ... ... @@ -435,6 +435,12 @@ 435 435 [[image:integration-active.png]] 436 436 437 437 441 +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**. 442 + 443 + 444 +[[image:new-device.png]] 445 + 446 + 438 438 == 6.3 Viewing messages == 439 439 440 440 ... ... @@ -453,36 +453,25 @@ 453 453 Then click on the **Apply changes** (//**tick icon**//) button. 454 454 455 455 456 -[[image: debug-enabled.png||height="301"width="700"]]465 +[[image:Screenshot 2025-03-18 at 09.23.10.png]] 457 457 458 458 459 - 460 - 461 461 Now go to the **Events** tab. 462 462 463 -Select the **Event type**as **Debug** from the dropdown list.470 +Select the Event type as **Debug** from the dropdown list. 464 464 465 - Publish anothermessage (of course,you canrepeatthe previousmessagebypressing theUParrowonyourkeyboardandthen pressEnter key) toyourMQTT brokerfromyour terminal, for example:472 +Now you can see all the Uplink messages you are simulating through the MQTT broker. The status should be OK if there is no errors in your integration. 466 466 467 -{{code language="none"}} 468 -mosquitto_pub -d -q 1 -h 011731f7928xxxxx.s1.eu.hivemq.cloud -p 8883 -u "xxxxx" -P "xxxxx" -t "device/a" -m '{"IMEI":"350693903995577", "temperature":30, "humidity":80, "pressure":1005}' 469 -{{/code}} 470 470 471 - Now you can see that uplinkmessagein the **Events** tab (Click the **refresh** button if you didn'tseeany messages intheEvents tab).The status should be **OK **if there isno errors in your integration.475 +[[image:Screenshot 2025-03-16 at 18.38.59.png]] 472 472 473 473 474 -[[image:Screenshot 2025-03-26 at 19.49.31.png]] 475 - 476 - 477 - 478 478 Then click on the **three dots (...)** in the **Message** column. You can see the uplink message's **payload** in the **Message** window. 479 479 480 480 481 -[[image:Screenshot 2025-03- 26 at 19.47.52.png]]481 +[[image:Screenshot 2025-03-16 at 18.39.12.png]] 482 482 483 483 484 - 485 - 486 486 Now, you have successfully tested your integration with a simulated uplink payload and verified that it is received by ThingsBoard, and the device is provisioned. 487 487 488 488 ... ... @@ -496,7 +496,7 @@ 496 496 497 497 First simulate a few messages using MQTT. This time, we have added the 'humidity' field to the payload. Eg: 498 498 499 -{{code language="none"}}mosquitto_pub -d -q 1 -h 011731f7928xxxxx.s1.eu.hivemq.cloud -p 8883 -u "xxxxx" -P "xxxxx" - t "device/a" -m '{"IMEI":"350693903995577", "temperature":22, "humidity":80, "pressure":1005}'{{/code}}497 +{{code language="none"}}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": 22, "humidity":80}'{{/code}} 500 500 501 501 502 502 In **ThingsBoard**, from the left navigation menu, click **Dashboards**. Then, click the **+** button and select **Create new dashboard** from the dropdown menu. ... ... @@ -534,7 +534,7 @@ 534 534 535 535 Configure the **Time series chart** widget as follows: 536 536 537 -* **Datasource** - select **DeviceA**device you provisioned.535 +* **Datasource** - select S31B-NB device you provisioned. 538 538 * **Series**: 539 539 ** **temperature** - you can see this key by default. 540 540 ** **humidity** - Click **Add series** button. Then add the **humidity** for the key and then type **%** as its unit. ... ... @@ -555,11 +555,12 @@ 555 555 556 556 557 557 {{code language="none"}} 558 -mosquitto_pub -d -q 1 -h 011731f7928xxxxx.s1.eu.hivemq.cloud -p 8883 -u "xxxxx" -P "xxxxx" - t "device/a" -m '{"IMEI":"350693903995577", "temperature":22, "humidity":70, "pressure":1005}'556 +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": 22, "humidity":70}' 559 559 560 -mosquitto_pub -d -q 1 -h 011731f7928xxxxx.s1.eu.hivemq.cloud -p 8883 -u "xxxxx" -P "xxxxx" - t "device/a" -m '{"IMEI":"350693903995577", "temperature":27, "humidity":72, "pressure":1005}'558 +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, "humidity":72}' 561 561 562 -mosquitto_pub -d -q 1 -h 011731f7928xxxxx.s1.eu.hivemq.cloud -p 8883 -u "xxxxx" -P "xxxxx" -t "device/a" -m '{"IMEI":"350693903995577", "temperature":19, "humidity":80, "pressure":1005}' 560 +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": 19, "humidity":80}' 561 + 563 563 {{/code}} 564 564 565 565 The chart will update with the values in realtime, as shown in the below image. ... ... @@ -590,7 +590,7 @@ 590 590 591 591 592 592 593 -The following image shows the uplink payload of a real Dragino device. The publish topic is '**TS01-NB'that contains fieldsinthepayload, IMEI, IMSI, Model, temperature, etc**. Note that we have created a device named**TS01-NB** in the**Devices**sectioninadvance.592 +The following image shows the uplink payload of a real Dragino device. The publish topic is **TS01-NB**, and the device name is **861275077962896**, which is represented by the **IMEI**. 594 594 595 595 {{info}} 596 596 The ThingsBoard uses the device's IMEI number included in the payload to create a device in the Devices section. ... ... @@ -597,3 +597,6 @@ 597 597 {{/info}} 598 598 599 599 [[image:image-4.png]] 599 + 600 + 601 +
- Screenshot 2025-03-31 at 06.51.15.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.pradeeka - Size
-
... ... @@ -1,1 +1,0 @@ 1 -179.5 KB - Content
- add-integartion-connection.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.pradeeka - Size
-
... ... @@ -1,1 +1,0 @@ 1 -110.3 KB - Content
- add-integartion-connetcion.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.pradeeka - Size
-
... ... @@ -1,1 +1,0 @@ 1 -146.0 KB - Content
- add-integration-basic-settings.png
-
- Size
-
... ... @@ -1,1 +1,1 @@ 1 -12 3.8KB1 +122.5 KB - Content
- add-integration-ul-data-converter.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.pradeeka - Size
-
... ... @@ -1,1 +1,0 @@ 1 -121.2 KB - Content
- debug-enabled.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.pradeeka - Size
-
... ... @@ -1,1 +1,0 @@ 1 -196.3 KB - Content
- integration-active.png
-
- Size
-
... ... @@ -1,1 +1,1 @@ 1 -64. 1KB1 +64.2 KB - Content
- integration-added.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.pradeeka - Size
-
... ... @@ -1,1 +1,0 @@ 1 -196.2 KB - Content
- ul-data-converter-added.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.pradeeka - Size
-
... ... @@ -1,1 +1,0 @@ 1 -189.4 KB - Content
- ul-data-converter-device-a.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.pradeeka - Size
-
... ... @@ -1,1 +1,0 @@ 1 -168.3 KB - Content