Version 105.1 by Edwin Chen on 2023/11/05 08:49

Show last authors
1 (% class="wikigeneratedid" id="HTableofContents:" %)
2 **Table of Contents:**
3
4 {{toc/}}
5
6
7
8
9
10
11 = 1. The use of this guideline =
12
13
14 This configure instruction is for Dragino NB-IoT models with -NB or -NS suffix, for example DDS75-NB. These models use the same NB-IoT Module **[[BC660K-GL>>https://www.quectel.com/product/lpwa-bc660k-gl-nb2]]** and has the same software structure. The have the same configure instruction to different IoT servers. Use can follow the instruction here to see how to configure to connect to those servers.
15
16
17 = 2. Attach Network =
18
19 == 2.1 General Configure to attach network ==
20
21
22 To attache NB-IoT sensors to NB-IoT Network, You need to:
23
24 1. Get a NB-IoT SIM card from Service Provider. (Not the same as the SIM card we use in mobile phone)
25 1. Insert the SIM card to Sensor
26 1. [[Configure APN>>http://wiki.dragino.com/xwiki/bin/view/Main/How%20to%20configure%20APN%20in%20the%20node/]] in the sensor (AT+APN=<APN>)
27
28 [[image:image-20230808205045-1.png||height="293" width="438"]]
29
30 After doing above, the NB-IoT Sensors should be able to attach to NB-IoT network .
31
32 The -NB and -NS models support (% style="color:blue" %)**LTE Cat NB2**(%%), with below frequency band: multiple frequency bands of (% style="color:blue" %)**B1/B2/B3/B4/B5/B8/B12/B13/B14/B17/B18/B19/B20/B25/B28/B66/B70/B85**(%%) . Make sure you use a the NB-IoT SIM card.
33
34 (% border="1" cellspacing="4" style="background-color:#f2f2f2; width:878px" %)
35 |(% style="background-color:#4f81bd; color:white; width:117px" %)**SIM Provider**|(% style="background-color:#4f81bd; color:white; width:151px" %)**AT+APN=**|(% style="background-color:#4f81bd; color:white; width:474px" %)**NB-IoT Coverage**|(% style="background-color:#4f81bd; color:white; width:135px" %)**Comments**
36 |(% style="width:117px" %)**[[1NCE>>https://1nce.com]]**|(% style="width:151px" %)iot.1nce.net|(% style="width:474px" %)(((
37 **[[Coverage Reference Link>>https://1nce.com/en-ap/1nce-connect]]**
38
39 Austria, Belgium, Bulgaria, Croatia, Czech Republic, Denmark, Finland, Germany, Great Britain, Greece, Hungary, Ireland, Italy, Latvia, Malta, Netherlands, Norway, Puerto Rico, Russia, Slovak , Republic, Slovenia, Spain, Sweden, Switzerland, Taiwan, USA, US Virgin Islands
40 )))|(% style="width:135px" %)
41 |(% style="width:117px" %)China Mobile|(% style="width:151px" %)No need configure|(% style="width:474px" %)China Mainland, HongKong|(% style="width:135px" %)
42 |(% style="width:117px" %)China Telecom|(% style="width:151px" %)ctnb|(% style="width:474px" %)China Mainland|(% style="width:135px" %)
43
44
45 == 2.2 Speed Up Network Attach time ==
46
47
48 BC660K-GL supports multi bands (% style="color:blue" %)**B1/B2/B3/B4/B5/B8/B12/B13/B14/B17/B18/B19/B20/B25/B28/B66/B70/B85. **(%%) It will search one by one and try to attach, this will take a lot of time and even cause attach fail. User can lock the band to specify band for its operator to make this faster.
49
50 (% style="color:#037691" %)**AT+QBAND?       ** (%%) ~/~/ Check what is the current used frequency band
51
52 (% style="color:#037691" %)**AT+QBAND=1,4    ** (%%) ~/~/ Set to use 1 frequency band. Band4
53
54 (% style="color:#037691" %)**AT+QBAND=2,8,20**  (%%) ~/~/ Set to use 2 frequency bands. Band 8 and Band 20
55
56
57 See bands used for different provider:** [[NB-IoT Deployment , Bands, Operator list>>http://wiki.dragino.com/xwiki/bin/view/Main/NB-IoT%20Deployment%20%2C%20Bands%2C%20Operator%20list/]]**
58
59
60 = 3. Configure to connect to different servers =
61
62 == 3.1 General UDP Connection ==
63
64
65 The NB-IoT Sensor can send packet to server use UDP protocol.
66
67
68 === 3.1.1 Simulate UDP Connection by PC tool ===
69
70
71 We can use PC tool to simulate UDP connection to make sure server works ok.
72
73 [[image:image-20230802112413-1.png]]
74
75
76 === 3.1.2 Configure NB-IoT Sensor ===
77
78 ==== 3.1.2.1 AT Commands ====
79
80
81 (% style="color:blue" %)**AT Commands:**
82
83 * (% style="color:#037691" %)**AT+PRO=2,0**  (%%) ~/~/  Set to use UDP protocol to uplink ,Payload Type select Hex payload
84
85 * (% style="color:#037691" %)**AT+SERVADDR=120.24.4.116,5601**  (%%) ~/~/  Set UDP server address and port
86
87 * (% style="color:#037691" %)**AT+CFM=1**    (%%) ~/~/  If the server does not respond, this command is unnecessary
88
89 [[image:image-20230802112413-2.png]]
90
91
92 ==== 3.1.2.2 Uplink Example ====
93
94
95 [[image:image-20230802112413-3.png]]
96
97
98 == 3.2 General MQTT Connection ==
99
100
101 The NB-IoT Sensor can send packet to server use MQTT protocol.
102
103 Below are the commands.
104
105 (% style="color:blue" %)**AT Commands:**
106
107 * (% style="color:#037691" %)**AT+PRO=3,0**   (%%) ~/~/  Set to use MQTT protocol to uplink, Payload Type select Hex payload.
108
109 * (% style="color:#037691" %)**AT+SERVADDR=120.24.4.116,1883**  (%%) ~/~/  Set MQTT server address and port
110
111 * (% style="color:#037691" %)**AT+CLIENT=CLIENT**     (%%) ~/~/  Set up the CLIENT of MQTT
112
113 * (% style="color:#037691" %)**AT+UNAME=UNAME**        (%%) ~/~/  Set the username of MQTT
114
115 * (% style="color:#037691" %)**AT+PWD=PWD**             (%%) ~/~/  Set the password of MQTT
116
117 * (% style="color:#037691" %)**AT+PUBTOPIC=NSE01_PUB**  (%%) ~/~/  Set the sending topic of MQTT
118
119 * (% style="color:#037691" %)**AT+SUBTOPIC=NSE01_SUB**  (%%) ~/~/  Set the subscription topic of MQTT
120
121 [[image:image-20230802112413-4.png]]
122
123 [[image:image-20230802112413-5.png||height="530" width="987"]]
124
125 (% style="color:red" %)**Notice: MQTT protocol has a much higher power consumption compare with UDP/CoAP protocol. Please check the power analyze document and adjust the uplink  period to a suitable interval.**
126
127
128 == 3.3 [[ThingSpeak>>url:https://thingspeak.com/]] (via MQTT) ==
129
130 === 3.3.1 Get MQTT Credentials ===
131
132
133 [[ThingSpeak>>url:https://thingspeak.com/]] connection uses MQTT Connection. So we need to get MQTT Credentials first. You need to point MQTT Devices to ThingSpeak Channel as well.
134
135 [[image:image-20230802112413-6.png||height="336" width="925"]]
136
137 [[image:image-20230802112413-7.png]]
138
139
140 === 3.3.2 Simulate with MQTT.fx ===
141
142 ==== 3.3.2.1 Establish MQTT Connection ====
143
144
145 After we got MQTT Credentials, we can first simulate with PC tool MQTT.fx tool to see if the Credentials and settings are fine.
146
147 [[image:image-20230802112413-8.png]]
148
149 * (% style="color:#037691" %)**Broker Address:**(%%) mqtt3.thingspeak.com
150
151 * (% style="color:#037691" %)**Broker Port:**(%%) 1883
152
153 * (% style="color:#037691" %)**Client ID:**(%%) <Your ThingSpeak MQTT ClientID>
154
155 * (% style="color:#037691" %)**User Name:**(%%) <Your ThingSpeak MQTT User Name>
156
157 * (% style="color:#037691" %)**Password:**(%%) <Your ThingSpeak MQTT Password>
158
159
160 ==== 3.3.2.2 Publish Data to ThingSpeak Channel ====
161
162
163 [[image:image-20230802112413-9.png]]
164
165 [[image:image-20230802112413-10.png]]
166
167
168 (% style="color:blue" %)**In MQTT.fx, we can publish below info:**
169
170 * (% style="color:#037691" %)**Topic:**(%%) channels/YOUR_CHANNEL_ID/publish
171
172 * (% style="color:#037691" %)**Payload:**(%%) field1=63&field2=67&status=MQTTPUBLISH
173
174 Where 63 and 67 are the value to be published to field1 & field2.
175
176
177 (% style="color:blue" %)**Result: **
178
179 [[image:image-20230802112413-11.png||height="539" width="901"]]
180
181
182 === 3.3.3 Configure NB-IoT Sensor for connection ===
183
184 ==== 3.3.3.1 AT Commands: ====
185
186
187 In the NB-IoT, we can run below commands so to publish the channels like MQTT.fx
188
189 * (% style="color:blue" %)**AT+PRO=3,1** (%%) ~/~/ Set to use ThingSpeak Server and Related Payload
190
191 * (% style="color:blue" %)**AT+CLIENT=<Your ThingSpeak MQTT ClientID>**
192
193 * (% style="color:blue" %)**AT+UNAME=<Your ThingSpeak MQTT User Name>**
194
195 * (% style="color:blue" %)**AT+PWD=<Your ThingSpeak MQTT Password>**
196
197 * (% style="color:blue" %)**AT+PUBTOPIC=<YOUR_CHANNEL_ID>**
198
199 * (% style="color:blue" %)**AT+SUBTOPIC=<YOUR_CHANNEL_ID>**
200
201
202 ==== 3.3.3.2 Uplink Examples ====
203
204
205 [[image:image-20230816201942-1.png]]
206
207 For SE01-NB
208
209 For DDS20-NB
210
211 For DDS45-NB
212
213 For DDS75-NB
214
215 For NMDS120-NB
216
217 For SPH01-NB
218
219 For NLM01-NB
220
221 For NMDS200-NB
222
223 For CPN01-NB
224
225 For DS03A-NB
226
227 For SN50V3-NB
228
229
230 ==== 3.3.3.3 Map fields to sensor value ====
231
232
233 When NB-IoT sensor upload to ThingSpeak. The payload already specify which fileds related to which sensor value. Use need to create fileds in Channels Settings. with name so to see the value correctly.
234
235
236 [[image:image-20230802112413-12.png||height="504" width="1011"]]
237
238 [[image:image-20230802112413-13.png||height="331" width="978"]]
239
240
241 Below is the NB-IoT Product Table show the mapping.
242
243 (% border="1" cellspacing="4" style="background-color:#f2f2f2; width:1424px" %)
244 |(% style="background-color:#4f81bd; width:143px" %) |(% style="background-color:#4f81bd; color:white; width:103px" %)Field1|(% style="background-color:#4f81bd; color:white; width:102px" %)Field2|(% style="background-color:#4f81bd; color:white; width:157px" %)Field3|(% style="background-color:#4f81bd; color:white; width:154px" %)Field4|(% style="background-color:#4f81bd; color:white; width:153px" %)Field5|(% style="background-color:#4f81bd; color:white; width:151px" %)Field6|(% style="background-color:#4f81bd; color:white; width:160px" %)Field7|(% style="background-color:#4f81bd; color:white; width:152px" %)Field8|(% style="background-color:#4f81bd; color:white; width:67px" %)Field9|(% style="background-color:#4f81bd; color:white; width:69px" %)Field10
245 |(% style="background-color:#4f81bd; color:white; width:143px" %)S31x-NB|(% style="width:103px" %)Temperature |(% style="width:102px" %)Humidity|(% style="width:157px" %)Battery|(% style="width:154px" %)RSSI|(% style="width:153px" %) |(% style="width:151px" %) |(% style="width:160px" %) |(% style="width:152px" %) |(% style="width:67px" %) |(% style="width:69px" %)
246 |(% style="background-color:#4f81bd; color:white; width:143px" %)SE01-NB|(% style="width:103px" %)Temperature |(% style="width:102px" %)Humidity|(% style="width:157px" %)conduct|(% style="width:154px" %)dielectric_constant|(% style="width:153px" %)Battery|(% style="width:151px" %)RSSI|(% style="width:160px" %) |(% style="width:152px" %) |(% style="width:67px" %) |(% style="width:69px" %)
247 |(% style="background-color:#4f81bd; color:white; width:143px" %)DDS20-NB|(% style="width:103px" %)distance|(% style="width:102px" %)Battery|(% style="width:157px" %)RSSI|(% style="width:154px" %) |(% style="width:153px" %) |(% style="width:151px" %) |(% style="width:160px" %) |(% style="width:152px" %) |(% style="width:67px" %) |(% style="width:69px" %)
248 |(% style="background-color:#4f81bd; color:white; width:143px" %)DDS45-NB|(% style="width:103px" %)distance|(% style="width:102px" %)Battery|(% style="width:157px" %)RSSI|(% style="width:154px" %) |(% style="width:153px" %) |(% style="width:151px" %) |(% style="width:160px" %) |(% style="width:152px" %) |(% style="width:67px" %) |(% style="width:69px" %)
249 |(% style="background-color:#4f81bd; color:white; width:143px" %)DDS75-NB|(% style="width:103px" %)distance|(% style="width:102px" %)Battery|(% style="width:157px" %)RSSI|(% style="width:154px" %) |(% style="width:153px" %) |(% style="width:151px" %) |(% style="width:160px" %) |(% style="width:152px" %) |(% style="width:67px" %) |(% style="width:69px" %)
250 |(% style="background-color:#4f81bd; color:white; width:143px" %)NMDS120-NB|(% style="width:103px" %)distance|(% style="width:102px" %)Battery|(% style="width:157px" %)RSSI|(% style="width:154px" %) |(% style="width:153px" %) |(% style="width:151px" %) |(% style="width:160px" %) |(% style="width:152px" %) |(% style="width:67px" %) |(% style="width:69px" %)
251 |(% rowspan="1" style="background-color:#4f81bd; color:white; width:143px" %)SPH01-NB|(% style="width:103px" %)ph|(% style="width:102px" %)Temperature|(% style="width:157px" %)Battery|(% style="width:154px" %)RSSI|(% style="width:153px" %) |(% style="width:151px" %) |(% style="width:160px" %) |(% style="width:152px" %) |(% style="width:67px" %) |(% colspan="1" rowspan="1" style="width:69px" %)
252 |(% style="background-color:#4f81bd; color:white; width:143px" %)NLM01-NB|(% style="width:103px" %)Humidity|(% style="width:102px" %)Temperature|(% style="width:157px" %)Battery|(% style="width:154px" %)RSSI|(% style="width:153px" %) |(% style="width:151px" %) |(% style="width:160px" %) |(% style="width:152px" %) |(% style="width:67px" %) |(% style="width:69px" %)
253 |(% style="background-color:#4f81bd; color:white; width:143px" %)NMDS200-NB|(% style="width:103px" %)distance1|(% style="width:102px" %)distance2|(% style="width:157px" %)Battery|(% style="width:154px" %)RSSI|(% style="width:153px" %) |(% style="width:151px" %) |(% style="width:160px" %) |(% style="width:152px" %) |(% style="width:67px" %) |(% style="width:69px" %)
254 |(% style="background-color:#4f81bd; color:white; width:143px" %)CPN01-NB|(% style="width:103px" %)alarm|(% style="width:102px" %)count|(% style="width:157px" %)door open duration|(% style="width:154px" %)calc flag|(% style="width:153px" %)Battery|(% style="width:151px" %)RSSI|(% style="width:160px" %) |(% style="width:152px" %) |(% style="width:67px" %) |(% style="width:69px" %)
255 |(% colspan="1" rowspan="1" style="background-color:#4f81bd; color:white; width:143px" %)DS03A-NB|(% colspan="1" rowspan="1" style="width:103px" %)level|(% colspan="1" rowspan="1" style="width:102px" %)alarm|(% colspan="1" rowspan="1" style="width:157px" %)pb14door open num|(% colspan="1" rowspan="1" style="width:154px" %)pb14 last open time|(% colspan="1" rowspan="1" style="width:153px" %)pb15 level status|(% colspan="1" rowspan="1" style="width:151px" %)pb15 alarm status|(% colspan="1" rowspan="1" style="width:160px" %)pb15 door open num|(% colspan="1" rowspan="1" style="width:152px" %)pb15 last open time|(% colspan="1" rowspan="1" style="width:67px" %)Battery|(% colspan="1" rowspan="1" style="width:69px" %)RSSI
256 |(% colspan="1" rowspan="1" style="background-color:#4f81bd; color:white; width:143px" %)SN50V3-NB mod1|(% colspan="1" rowspan="1" style="width:103px" %)mod|(% colspan="1" rowspan="1" style="width:102px" %)Battery|(% colspan="1" rowspan="1" style="width:157px" %)RSSI|(% colspan="1" rowspan="1" style="width:154px" %)DS18B20 Temp|(% colspan="1" rowspan="1" style="width:153px" %)exit_state/input PA4|(% colspan="1" rowspan="1" style="width:151px" %)adc0|(% colspan="1" rowspan="1" style="width:160px" %)Temperature |(% colspan="1" rowspan="1" style="width:152px" %)Humidity|(% colspan="1" rowspan="1" style="width:67px" %) |(% colspan="1" rowspan="1" style="width:69px" %)
257 |(% colspan="1" style="background-color:#4f81bd; color:white; width:143px" %)SN50V3-NB mod2|(% colspan="1" style="width:103px" %)mod|(% colspan="1" style="width:102px" %)Battery|(% colspan="1" style="width:157px" %)RSSI|(% colspan="1" style="width:154px" %)DS18B20 Temp|(% colspan="1" style="width:153px" %)exit_state/input PA4|(% colspan="1" style="width:151px" %)adc0|(% colspan="1" style="width:160px" %)distance|(% colspan="1" style="width:152px" %) |(% colspan="1" style="width:67px" %) |(% colspan="1" style="width:69px" %)
258 |(% colspan="1" style="background-color:#4f81bd; color:white; width:143px" %)SN50V3-NB mod3|(% colspan="1" style="width:103px" %)mod|(% colspan="1" style="width:102px" %)Battery|(% colspan="1" style="width:157px" %)RSSI|(% colspan="1" style="width:154px" %)adc0|(% colspan="1" style="width:153px" %)exit_state/input PA4|(% colspan="1" style="width:151px" %)adc1|(% colspan="1" style="width:160px" %)Temperature|(% colspan="1" style="width:152px" %)Humidity|(% colspan="1" style="width:67px" %)adc4|(% colspan="1" style="width:69px" %)
259 |(% colspan="1" style="background-color:#4f81bd; color:white; width:143px" %)SN50V3-NB mod4|(% colspan="1" style="width:103px" %)mod|(% colspan="1" style="width:102px" %)Battery|(% colspan="1" style="width:157px" %)RSSI|(% colspan="1" style="width:154px" %)DS18B20 Temp|(% colspan="1" style="width:153px" %)adc0|(% colspan="1" style="width:151px" %)exit_state/input PA4|(% colspan="1" style="width:160px" %)DS18B20 Temp2|(% colspan="1" style="width:152px" %)DS18B20 Temp3|(% colspan="1" style="width:67px" %) |(% colspan="1" style="width:69px" %)
260 |(% colspan="1" style="background-color:#4f81bd; color:white; width:143px" %)SN50V3-NB mod5|(% colspan="1" style="width:103px" %)mod|(% colspan="1" style="width:102px" %)Battery|(% colspan="1" style="width:157px" %)RSSI|(% colspan="1" style="width:154px" %)DS18B20 Temp|(% colspan="1" style="width:153px" %)adc0|(% colspan="1" style="width:151px" %)exit_state/input PA4|(% colspan="1" style="width:160px" %)Weight|(% colspan="1" style="width:152px" %) |(% colspan="1" style="width:67px" %) |(% colspan="1" style="width:69px" %)
261 |(% colspan="1" style="background-color:#4f81bd; color:white; width:143px" %)SN50V3-NB mod6|(% colspan="1" style="width:103px" %)mod|(% colspan="1" style="width:102px" %)Battery|(% colspan="1" style="width:157px" %)RSSI|(% colspan="1" style="width:154px" %)count|(% colspan="1" style="width:153px" %) |(% colspan="1" style="width:151px" %) |(% colspan="1" style="width:160px" %) |(% colspan="1" style="width:152px" %) |(% colspan="1" style="width:67px" %) |(% colspan="1" style="width:69px" %)
262
263
264 == 3.4 [[Datacake>>https://datacake.co/]] ==
265
266
267 (% class="wikigeneratedid" %)
268 Dragino NB-IoT sensors has its template in **[[Datacake>>https://datacake.co/]]** Platform. There are two version for NB Sensor,
269
270
271 (% class="wikigeneratedid" %)
272 As example for S31B-NB. there are two versions: **S31B-NB-1D and S31B-NB-GE.**
273
274 * (% style="color:blue" %)**S31B-NB-1D**(%%): This version have pre-configure DataCake connection. User just need to Power on this device, it will auto connect send data to DataCake Server.
275
276 * (% style="color:blue" %)**S31B-NB-GE**(%%): This verson doesn't have pre-configure Datacake connection. User need to enter the AT Commands to connect to Datacake. See below for instruction.
277
278
279 === 3.4.1 Create device ===
280
281
282 (% style="color:blue" %)**Add Device**(%%) in DataCake.
283
284 [[image:image-20230808162301-1.png||height="473" width="994"]]
285
286
287 [[image:image-20230808162342-2.png]]
288
289
290 (% style="color:blue" %)**Choose the correct model**(%%) from template.
291
292 [[image:image-20230808162421-3.png]]
293
294
295 (% style="color:blue" %)**Fill Device ID**(%%). The device ID needs to be filled in with IMEI, and a prefix of(% style="color:blue" %)** 'f' **(%%)needs to be added.
296
297 [[image:image-20230808163612-7.png]]
298
299 [[image:image-20230808163035-5.png]]
300
301 [[image:image-20230808163049-6.png]]
302
303
304 === 3.4.2 Scan QR code to obtain data ===
305
306
307 Users can use their phones or computers to scan QR codes to obtain device data information.
308
309 [[image:image-20230808170051-8.png||height="255" width="259"]]
310
311 [[image:image-20230808170548-9.png]]
312
313
314 === 3.4.2 AT command for connecting to DataCake ===
315
316
317 (% style="color:blue" %)**AT+PRO=2,0**
318
319 (% style="color:blue" %)**AT+SERVADDR=67.207.76.90,4445**
320
321
322 == 3.5 Node-Red (via MQTT) ==
323
324 === 3.5.1 Configure [[Node-Red>>http://wiki.dragino.com/xwiki/bin/view/Main/Node-RED/]] ===
325
326
327 Take S31-NB UDP protocol as an example.
328
329 Dragino provides input flow examples for the sensors.
330
331 User can download the required JSON file through Dragino Node-RED input flow template.
332
333 Download sample JSON file link: [[https:~~/~~/www.dropbox.com/sh/mduw85jcuwsua22/AAAvwPhg9z6dLjJhmZjqBf_ma?dl=0>>url:https://www.dropbox.com/sh/mduw85jcuwsua22/AAAvwPhg9z6dLjJhmZjqBf_ma?dl=0]]
334
335 We can directly import the template.
336
337 The templates for S31-NB and NB95S31B are the same.
338
339
340 [[image:image-20230809173127-4.png]]
341
342
343 Please select the NB95S31B template.
344
345 [[image:image-20230809173310-5.png]]
346
347 [[image:image-20230809173438-6.png]]
348
349 [[image:image-20230809173800-7.png]]
350
351
352 Successfully imported template.
353
354 [[image:image-20230809173835-8.png]]
355
356
357 Users can set UDP port.
358
359 [[image:image-20230809174053-9.png]]
360
361
362 === 3.5.2 Simulate Connection ===
363
364
365 We have completed the configuration of UDP. We can try sending packets to node red.
366
367 [[image:image-20230810083934-1.png]]
368
369 [[image:image-20230810084048-2.png]]
370
371 === 3.5.3 Configure NB-IoT Sensors ===
372
373
374 * (% style="color:blue" %)**AT+PRO=2,0(hex format) or 2,1(json format)  **(%%)** **~/~/  Set to UDP Server and  Payload
375
376 * (% style="color:blue" %)**AT+SERVADDR=xx.xx.xx.xx,port   **(%%)** **~/~/  Set Server IP and  port
377
378
379 == 3.6 ThingsBoard.Cloud (via MQTT) ==
380
381 === 3.6.1 Configure ThingsBoard ===
382
383 ==== 3.6.1.1 Create Device ====
384
385
386 Create a New Device in [[ThingsBoard>>url:https://thingsboard.cloud/]]. Record Device Name which is used for MQTT connection.
387
388 [[image:image-20230802112413-32.png]]
389
390
391 ==== 3.6.1.2 Create Uplink & Downlink Converter ====
392
393
394 (% style="color:blue" %)**Uplink Converter**
395
396 The purpose of the decoder function is to parse the incoming data and metadata to a format that ThingsBoard can consume. deviceName and deviceType are required, while attributes and telemetry are optional. Attributes and telemetry are flat key-value objects. Nested objects are not supported.
397
398 To create an uplink converter go to the (% style="color:blue" %)**Integrations center**(%%) -> (% style="color:blue" %)**Data converters**(%%) page and click (% style="color:blue" %)**“plus”** (%%)button. Name it (% style="color:blue" %)**“MQTT Uplink Converter”**(%%) and select type (% style="color:blue" %)"**Uplink"**(%%). Use debug mode for now.
399
400 [[image:image-20230802112413-33.png||height="732" width="1302"]]
401
402
403 (% style="color:blue" %)**Downlink Converter**
404
405 The Downlink converter transforming outgoing RPC message and then the Integration sends it to external MQTT broke
406
407 [[image:image-20230802112413-34.png||height="734" width="1305"]]
408
409 (% style="color:red" %)**Note: Our device payload is already human readable data. Therefore, users do not need to write decoders. Simply create by default.**
410
411
412 ==== 3.6.1.3 MQTT Integration Setup ====
413
414
415 Go to the (% style="color:blue" %)**Integrations center**(%%) **->** (% style="color:blue" %)**Integrations page**(%%) and click **“(% style="color:blue" %)plus(%%)”** icon to add a new integration. Name it (% style="color:blue" %)**“MQTT Integration”**(%%), select type (% style="color:blue" %)**MQTT**;
416
417 [[image:image-20230802112413-35.png||height="738" width="1312"]]
418
419
420 * The next steps is to add the recently created uplink and downlink converters;
421
422 [[image:image-20230802112413-36.png||height="736" width="1308"]]
423
424 [[image:image-20230802112413-37.png||height="735" width="1307"]]
425
426
427 (% style="color:blue" %)**Add a topic filter:**
428
429 tb/mqtt-integration-tutorial/sensors~/~/temperature ~-~-> Temperature  **固定的? 对的。**
430
431 You can also select an MQTT QoS level. We use MQTT QoS level 0 (At most once) by default;
432
433 [[image:image-20230802112413-38.png||height="731" width="1300"]]
434
435
436 === 3.6.2 Simulate with MQTT.fx ===
437
438
439 [[image:image-20230802112413-39.png]]
440
441 [[image:image-20230802112413-40.png]]
442
443
444 === 3.6.3 Configure NB-IoT Sensor ===
445
446
447 (% style="color:blue" %)**AT Commands**
448
449 * (% style="color:#037691" %)**AT+PRO=3,3  **(%%)** **~/~/ Use MQTT to connect to ThingsBoard. Payload Type set to 3.
450
451 * (% style="color:#037691" %)**AT+SUBTOPIC=<device name>**
452
453 * (% style="color:#037691" %)**AT+PUBTOPIC=<device name>**
454
455 * (% style="color:#037691" %)**AT+CLIENT=<device name> or User Defined**
456
457 * (% style="color:#037691" %)**AT+UNAME=<device name> or User Defined**
458
459 * (% style="color:#037691" %)**AT+PWD=<device name> or User Defined**
460
461 Test Uplink by click the button for 1 second
462
463 [[image:image-20230802112413-41.png]]
464
465 [[image:image-20230802112413-42.png]]
466
467 [[image:image-20230802112413-43.png]]
468
469
470 == 3.7 [[Tago.io>>url:https://admin.tago.io/]] (via MQTT) ==
471
472 === 3.7.1 Create device & Get Credentials ===
473
474
475 We use MQTT Connection to send data to [[Tago.io>>url:https://admin.tago.io/]]. We need to Create Device and Get MQTT Credentials first.
476
477 [[image:image-20230802112413-44.png]]
478
479 [[image:image-20230802112413-45.png]]
480
481
482 Go to the Device section and create a device. Then, go to the section tokens and copy your device-token.
483
484 [[image:image-20230802112413-46.png]]
485
486
487 The device needs to enable the TLS mode and set the (% style="color:blue" %)**AT+TLSMOD=1,0**(%%) command.
488
489 (% style="color:blue" %)**On the Connection Profile window, set the following information:**
490
491 * (% style="color:#037691" %)**Profile Name: “Any name”**
492
493 * (% style="color:#037691" %)**Broker Address: mqtt.tago.io**
494
495 * (% style="color:#037691" %)**Broker Port: 8883**
496
497 * (% style="color:#037691" %)**Client ID: “Any value”**
498
499 (% style="color:blue" %)**On the section User credentials, set the following information:**
500
501 * (% style="color:#037691" %)**User Name: “Any value”** (%%) **~/~/ Tago validates your user by the token only**
502
503 * (% style="color:#037691" %)**Password: “Your device token”**
504
505 * (% style="color:#037691" %)**PUBTOPIC: “Any value”**
506
507 * (% style="color:#037691" %)**SUBTOPIC: “Any value”**
508
509 (% style="color:blue" %)**AT command:**
510
511 * (% style="color:#037691" %)**AT+PRO=3,0 or 3,5 ** (%%) **~/~/ hex format or json format**
512
513 * (% style="color:#037691" %)**AT+SUBTOPIC=<device name>or User Defined**
514
515 * (% style="color:#037691" %)**AT+PUBTOPIC=<device name>or User Defined**
516
517 * (% style="color:#037691" %)**AT+CLIENT=<device name> or User Defined**
518
519 * (% style="color:#037691" %)**AT+UNAME=<device name> or User Defined**
520
521 * (% style="color:#037691" %)**AT+PWD=“Your device token”**
522
523
524 === 3.7.2 Simulate with MQTT.fx ===
525
526
527 [[image:image-20230802112413-52.png]]
528
529
530 [[image:image-20230808105300-2.png]]
531
532
533 Users can run the (% style="color:blue" %)**AT+PRO=3,5**(%%) command, and the payload will be converted to **JSON format**.
534
535 [[image:image-20230808105217-1.png]]
536
537 [[image:image-20230808105329-3.png]]
538
539
540 === 3.7.3 tago data ===
541
542
543 [[image:image-20230802112413-50.png]]
544
545 [[image:image-20230802112413-51.png||height="184" width="696"]]
546
547
548 == 3.8 TCP Connection ==
549
550
551 (% style="color:blue" %)**AT command:**
552
553 * (% style="color:#037691" %)**AT+PRO=4,0   ** (%%) ~/~/ Set to use TCP protocol to uplink(HEX format)
554
555 * (% style="color:#037691" %)**AT+PRO=4,1   ** (%%) ~/~/ Set to use TCP protocol to uplink(JSON format)
556
557 * (% style="color:#037691" %)**AT+SERVADDR=120.24.4.116,5600 ** (%%) ~/~/ to set TCP server address and port
558
559 (% style="color:blue" %)**Sensor Console Output when Uplink:**
560
561 [[image:image-20230807233631-1.png]]
562
563
564 (% style="color:blue" %)**See result in TCP Server:**
565
566 [[image:image-20230807233631-2.png]]