Wiki source code of How to Uplink -NB and -CB series devices data by MQTT with Thingseye
Last modified by Alec Chen on 2025/04/02 18:03
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | **Table of Contents:** | ||
| 2 | |||
| 3 | = 1. Introduction = | ||
| 4 | |||
| 5 | This document guides you on integrating Dragino **-NB** and **-CB** series devices data with Thingseye. | ||
| 6 | |||
| 7 | The **NB series** devices end with the suffix **-NB**, and the **CB series** devices end with the suffix **-CB**. For example, **S31B-NB** is an **NB device**, and **S31-CB** is a **CB device**. | ||
| 8 | |||
| 9 | = 2. Prerequisites = | ||
| 10 | |||
| 11 | To complete this tutorial, you need to have certificate files. [[lns1.thingseye.io>>url:http://lns1.thingseye.io/]] is the Dragino's MQTT broker, which requires a CA certificate file, Certificate file, and the Private key file to use. | ||
| 12 | |||
| 13 | If customers need to use this MQTT connection with Thingseye, they need to contact TE team to obtain three license files or click this [[link>>url:https://www.dropbox.com/scl/fo/d5s1wf36f4syv30a8laup/AK8FjVpNXYXCWodRnnQ1Hig?rlkey=jrz1ip0f0xwwq5z2m2gu1tuij&e=1&st=kl4caub0&dl=0]] to download the certificates.. | ||
| 14 | |||
| 15 | [[image:https://wiki.dragino.com/xwiki/bin/download/Main/ThingsBoard/ins1.png?width=500&height=310&rev=1.1||alt="ins1.png" height="310" width="500"]] | ||
| 16 | |||
| 17 | |||
| 18 | = (% style="color:#333333; font-family:inherit; font-size:max(23px, min(29px, 12.3333px + 1.38889vw))" %)3. Configure Thingseye's Integration(%%) = | ||
| 19 | |||
| 20 | == 3.1 Creat new MQTT integration == | ||
| 21 | |||
| 22 | In the left navigation, click **Integrations center**, and then click **Integrations**. | ||
| 23 | |||
| 24 | On the **Integrations** page, click on the '**+**' button. | ||
| 25 | |||
| 26 | [[image:1743578691561-822.png]] | ||
| 27 | |||
| 28 | |||
| 29 | The **Add integration** window appears. | ||
| 30 | |||
| 31 | In the **Add integration** window, configure the following settings: | ||
| 32 | |||
| 33 | **Basic settings:** | ||
| 34 | |||
| 35 | * **Integration type**: MQTT | ||
| 36 | * **Name**: MQTT integration | ||
| 37 | * **Enable integration**: YES | ||
| 38 | * **Debug mode**:YES | ||
| 39 | * **Allows create devices or assets**: YES | ||
| 40 | |||
| 41 | Click **Next** button. | ||
| 42 | |||
| 43 | [[image:1743578960106-916.png||height="549" width="547"]] | ||
| 44 | |||
| 45 | |||
| 46 | **Uplink/downlink data converter:** | ||
| 47 | |||
| 48 | * ((( | ||
| 49 | Next, directly select to create a new Uplink data converter . | ||
| 50 | ))) | ||
| 51 | |||
| 52 | Click **Next** button. | ||
| 53 | |||
| 54 | [[image:1743581191958-140.png||height="547" width="543"]] | ||
| 55 | |||
| 56 | |||
| 57 | |||
| 58 | **Downlink data converter:** | ||
| 59 | |||
| 60 | * Next, directly select to create a new Uplink data converter . | ||
| 61 | |||
| 62 | Click **Skip** button. | ||
| 63 | |||
| 64 | [[image:1743581287837-189.png||height="547" width="542"]] | ||
| 65 | |||
| 66 | |||
| 67 | **Connection:** | ||
| 68 | |||
| 69 | * **Host**: [[lns1.thingseye.io>>url:http://lns1.thingseye.io/]] | ||
| 70 | * **Port**: 8883 | ||
| 71 | * **Credentials **: PEM(Paste 3 certificates to boxs below)Click this [[link>>url:https://www.dropbox.com/scl/fo/d5s1wf36f4syv30a8laup/AK8FjVpNXYXCWodRnnQ1Hig?rlkey=jrz1ip0f0xwwq5z2m2gu1tuij&e=1&st=kl4caub0&dl=0]] to download the certificates. | ||
| 72 | * **Password:** Password or nothng | ||
| 73 | * **Enable SSL**: YES | ||
| 74 | * **Topic: ** **It needs to align with the device's topic.** | ||
| 75 | * **QoS:** 0-At most once or an MQTT QoS level | ||
| 76 | |||
| 77 | Click **Skip** button. | ||
| 78 | |||
| 79 | [[image:1743579352961-586.png||height="507" width="502"]] | ||
| 80 | |||
| 81 | [[image:1743584347047-327.png]] | ||
| 82 | |||
| 83 | |||
| 84 | Click on the **Add** button. | ||
| 85 | |||
| 86 | You should see that the newly added integration is listed on the **Integrations** page. | ||
| 87 | |||
| 88 | Since we haven't received data from a device yet, the integration **Status** is shown as **Pending, Active instead if it have.** | ||
| 89 | |||
| 90 | [[image:1743580606618-281.png||height="495" width="504"]] | ||
| 91 | |||
| 92 | |||
| 93 | = 4. Configure Thingseye's Data Converters = | ||
| 94 | |||
| 95 | First, you need to download the [[**MQTT uplink/downlink JS** **code**>>url:https://www.dropbox.com/scl/fo/d5s1wf36f4syv30a8laup/AK8FjVpNXYXCWodRnnQ1Hig?rlkey=jrz1ip0f0xwwq5z2m2gu1tuij&e=1&st=kl4caub0&dl=0]]. | ||
| 96 | |||
| 97 | In **Thingseye**, **Data Converters** are components used to transform incoming or outgoing data between different formats, typically to convert raw telemetry data from devices into a structured format that Thingseye can understand, or vice versa. | ||
| 98 | |||
| 99 | == 4.1 Uplink == | ||
| 100 | |||
| 101 | * **Uplink Converter** | ||
| 102 | |||
| 103 | The purpose of the decoder function is to parse the incoming data and metadata to a format that ThingsBoard can consume. | ||
| 104 | |||
| 105 | Go to the **Integrations center** -> **Data converters** page, and find that MQTT uplink converter that was newly created when the integration was created. | ||
| 106 | |||
| 107 | [[image:1743581830822-223.png]] | ||
| 108 | |||
| 109 | |||
| 110 | Enter edit mode and apply **MQTT uplink JS code** to this uplink converter. | ||
| 111 | |||
| 112 | [[image:1743581965585-763.png]] | ||
| 113 | |||
| 114 | |||
| 115 | == 4.2 Downlink == | ||
| 116 | |||
| 117 | * ((( | ||
| 118 | **Downlink Converter** | ||
| 119 | ))) | ||
| 120 | |||
| 121 | Go to the **Integrations center** -> **Data converters** page, and find that MQTT downlink converter that was newly created when the integration was created. | ||
| 122 | |||
| 123 | |||
| 124 | Enter edit mode and apply **MQTT downlink JS code** to this downlink converter. | ||
| 125 | |||
| 126 | [[image:1743582084494-111.png]] | ||
| 127 | |||
| 128 | |||
| 129 | == 4.3 Simulate with MQTT.fx == | ||
| 130 | |||
| 131 | [[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-20241126191118-18.png?width=835&height=605&rev=1.1||alt="image-20241126191118-18.png"]] | ||
| 132 | |||
| 133 | [[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-20241126193252-25.png?width=803&height=663&rev=1.1||alt="image-20241126193252-25.png"]] | ||
| 134 | |||
| 135 | |||
| 136 | = 5. Test connect = | ||
| 137 | |||
| 138 | **AT Commands** | ||
| 139 | |||
| 140 | * **AT+PRO=3,5 **~/~/ Use MQTT Connection & Json Payload | ||
| 141 | * **AT+SERVADDR=lns1.thingseye.io,8883** | ||
| 142 | * **AT+SUBTOPIC=8899 **~/~/ Consistent with the Topic of MQTT integration created by ThingsEye | ||
| 143 | * **AT+PUBTOPIC=8899 **~/~/ Consistent with the Topic of MQTT integration created by ThingsEye | ||
| 144 | * **AT+CLIENT=NULL** | ||
| 145 | * **AT+UNAME=NULL** | ||
| 146 | * **AT+PWD=NULL** | ||
| 147 | * **AT+TLSMOD=1,2** | ||
| 148 | |||
| 149 | (% class="box warningmessage" %) | ||
| 150 | ((( | ||
| 151 | Be careful, “ Topic” should be same of device & serve. If your device not belongs Dragino, address should be same of the broker which using. | ||
| 152 | ))) | ||
| 153 | |||
| 154 | Test Uplink by click the button for 1~~3 seconds, the MQTT integration in ThingsEye allows you to view the data upstream from the device: | ||
| 155 | |||
| 156 | |||
| 157 | |||
| 158 | Go to **"Device" ** -> ** "Search Device"**, enter the ** IMEI** of the device to find the device. | ||
| 159 | |||
| 160 | |||
| 161 | |||
| 162 |