Changes for page How to Uplink -NB and -CB series devices data by MQTT with Thingseye
Last modified by Alec Chen on 2025/04/02 18:03
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 -How to con nect-NB and -CB series devices data by MQTT with Thingseye1 +How to communice Dragino -NB and -CB series devices data by MQTT with Thingseye - Content
-
... ... @@ -1,7 +1,5 @@ 1 1 **Table of Contents:** 2 2 3 -{{toc/}} 4 - 5 5 = 1. Introduction = 6 6 7 7 This document guides you on integrating Dragino **-NB** and **-CB** series devices data with Thingseye. ... ... @@ -39,9 +39,9 @@ 39 39 40 40 [[image:https://wiki.dragino.com/xwiki/bin/download/Main/General%20Configure%20to%20Connect%20to%20IoT%20server%20for%20-NB%20%26%20-NS%20NB-IoT%20models/WebHome/image-20230802112413-5.png?width=987&height=530&rev=1.1||alt="image-20230802112413-5.png" height="530" width="987"]] 41 41 42 -(% class=" mark smalltext-uppercase" %)##**Notice: MQTT protocol has a much higher power consumption compare with UDP/CoAP protocol. Please check the power analyze document and adjust the uplink**##40 +(% class="text-uppercase small mark" %)##**Notice: MQTT protocol has a much higher power consumption compare with UDP/CoAP protocol. Please check the power analyze document and adjust the uplink**## 43 43 44 -(% class=" mark smalltext-uppercase" %)##**period to a suitable interval.**##42 +(% class="text-uppercase small mark" %)##**period to a suitable interval.**## 45 45 46 46 = 4. Data Converters = 47 47 ... ... @@ -56,6 +56,81 @@ 56 56 [[image:1743578461281-635.png]] 57 57 58 58 57 + 58 + 59 +The **Add data converter** window will appear. 60 + 61 +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**. 62 + 63 +Click on the **TBEL** button if it has not been selected by default. 64 + 65 +Modify the default TBEL function to match with your device as described below: 66 + 67 +* Uncomment** line 11**: 68 + 69 +//var data = decodeToJson(payload)// 70 + 71 +* **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. 72 +* From **line 38**: Modify the telemetry section to allow parsed data to be assigned to the fields. 73 + 74 +//telemetry: { 75 + temperature: data.temperature, 76 + humidity: data.humidity, 77 + rawData: payloadStr 78 + }// 79 + 80 +The modified uplink decoder function to match with **Device A** is shown below. 81 + 82 +{{code language="nono"}} 83 +// Decode an uplink message from a buffer 84 +// payload - array of bytes 85 +// metadata - key/value object 86 + 87 +/** Decoder **/ 88 + 89 +// decode payload to string 90 +var payloadStr = decodeToString(payload); 91 + 92 +// decode payload to JSON 93 +var data = decodeToJson(payload); 94 + 95 +var deviceName = 'Device A'; 96 +var deviceType = 'thermostat'; 97 +var customerName = 'Customer C'; 98 +var groupName = 'thermostat devices'; 99 +var manufacturer = 'Example corporation'; 100 +// use assetName and assetType instead of deviceName and deviceType 101 +// to automatically create assets instead of devices. 102 +// var assetName = 'Asset A'; 103 +// var assetType = 'building'; 104 + 105 +// Result object with device/asset attributes/telemetry data 106 +var result = { 107 +// Use deviceName and deviceType or assetName and assetType, but not both. 108 + deviceName: deviceName, 109 + deviceType: deviceType, 110 +// assetName: assetName, 111 +// assetType: assetType, 112 +// customerName: customerName, 113 + groupName: groupName, 114 + attributes: { 115 + model: 'Model A', 116 + serialNumber: 'SN111', 117 + integrationName: metadata['integrationName'], 118 + manufacturer: manufacturer 119 + }, 120 + telemetry: { 121 + temperature: data.temperature, 122 + humidity: data.humidity, 123 + rawData: payloadStr 124 + } 125 +}; 126 + 127 +/** Helper functions 'decodeToString' and 'decodeToJson' are already built-in **/ 128 + 129 +return result; 130 +{{/code}} 131 + 59 59 Once you modify the decoder function, click on the **Add** button. 60 60 61 61 [[image:https://wiki.dragino.com/xwiki/bin/download/Main/ThingsBoard/ul-data-converter-device-a.png?width=500&height=524&rev=1.1||alt="ul-data-converter-device-a.png"]] ... ... @@ -168,8 +168,10 @@ 168 168 [[image:1743582084494-111.png]] 169 169 170 170 171 -= 6. Configure Physical NB-IoT Sensor = 172 172 245 + 246 += 8. Configure Physical NB-IoT Sensor = 247 + 173 173 Now, let's experiment with sending data to Thingseye using a real NB-IoT device. For example, we will use the **TS01-NB**. 174 174 175 175 First, configure the NB-IoT device with the necessary MQTT settings using AT commands. Below is a list of AT commands you can use.