Wiki source code of NDS01 - NB-IoT Door Sensor User Manual
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | (% style="text-align:center" %) | ||
2 | [[image:image-20221112113258-1.jpeg]] | ||
3 | |||
4 | |||
5 | |||
6 | |||
7 | |||
8 | |||
9 | |||
10 | |||
11 | |||
12 | |||
13 | |||
14 | = 1. Introduction = | ||
15 | |||
16 | |||
17 | == 1.1 What is NDS01 NB-IoT Door Sensor == | ||
18 | |||
19 | |||
20 | The Dragino NDS01 is a NB-IOT Door Sensor for Internet of Things solution. It is used to detect the open/close event for door and uplink the event to IoT server via NB-IoT network. | ||
21 | |||
22 | Besides open/close event, NDS01 also has an internal temperature and humidity sensor which can detect the temperature and humidity inside the sensor. | ||
23 | |||
24 | **NarrowBand-Internet of Things (NB-IoT)** is a standards-based low power wide area (LPWA) technology developed to enable a wide range of new IoT devices and services. NB-IoT significantly improves the power consumption of user devices, system capacity and spectrum efficiency, especially in deep coverage. | ||
25 | |||
26 | NDS01 is powered by 2 x AAA batteries for long term use. | ||
27 | |||
28 | *The measured temperature is 2~~3 degree higher than the actually environment temperature out of NDS01. | ||
29 | |||
30 | |||
31 | [[image:1668224602353-769.png]] | ||
32 | |||
33 | |||
34 | |||
35 | |||
36 | == 1.2 Specifications == | ||
37 | |||
38 | |||
39 | **Common DC Characteristics:** | ||
40 | |||
41 | * Supply Voltage: 2.1v ~~ 3.6v | ||
42 | * Operating Temperature: -10 ~~ 50°C | ||
43 | |||
44 | |||
45 | **NB-IoT Spec:** | ||
46 | |||
47 | * - B1 @H-FDD: 2100MHz | ||
48 | * - B3 @H-FDD: 1800MHz | ||
49 | * - B8 @H-FDD: 900MHz | ||
50 | * - B5 @H-FDD: 850MHz | ||
51 | * - B20 @H-FDD: 800MHz | ||
52 | * - B28 @H-FDD: 700MHz | ||
53 | |||
54 | |||
55 | **Power Consumption** | ||
56 | |||
57 | * IDEL Mode: 10uA @ 3.3v | ||
58 | * Max transmit power: <500mA@3.3v | ||
59 | |||
60 | | ||
61 | |||
62 | |||
63 | == 1.3 Features == | ||
64 | |||
65 | |||
66 | * NB-IoT Bands: B1/B3/B5/B8/B20/B28 @H-FDD | ||
67 | * Ultra low power consumption | ||
68 | * Door Open / Close Detect | ||
69 | * Device remove alarm | ||
70 | * Uplink Protocol: TCP or UDP | ||
71 | * Uplink on periodically | ||
72 | * Micro SIM card slot for NB-IoT SIM | ||
73 | * 2 x AAA LR03 Batteries | ||
74 | |||
75 | |||
76 | |||
77 | == 1.4 Applications == | ||
78 | |||
79 | |||
80 | * Smart Buildings & Home Automation | ||
81 | * Logistics and Supply Chain Management | ||
82 | * Smart Cities | ||
83 | * Smart Factory | ||
84 | |||
85 | |||
86 | |||
87 | = 2. Use NDS01 to communicate with IoT Server = | ||
88 | |||
89 | |||
90 | == 2.1 How it works == | ||
91 | |||
92 | |||
93 | The NDS01 is equipped with a NB-IoT module, the pre-loaded firmware in NDS01 will get environment data from sensors and send the value to local NB-IoT network via the NB-IoT module. The NB-IoT network will forward this value to IoT server via the protocol defined by NDS01. | ||
94 | |||
95 | |||
96 | The diagram below shows the working flow in default firmware of NDS01: | ||
97 | |||
98 | |||
99 | |||
100 | |||
101 | == 2.2 Configure the NDS01 == | ||
102 | |||
103 | === 2.2.1 Test Requirement === | ||
104 | |||
105 | |||
106 | To use NDS01 in your city, make sure meet below requirements: | ||
107 | |||
108 | * Your local operator has already distributed a NB-IoT Network there. | ||
109 | * The local NB-IoT network used the band that NDS01 supports. | ||
110 | * Your operator is able to distribute the data received in their NB-IoT network to your IoT server. | ||
111 | |||
112 | Below figure shows our testing structure. Here we have NB-IoT network coverage by China Mobile, the band they use is B8. The NDS01 will use UDP(120.24.4.116:5601) or TCP(120.24.4.116:5600)protocol to send data to IoT server. | ||
113 | |||
114 | [[image:file:///C:/Users/93456/AppData/Local/Temp/msohtmlclip1/01/clip_image002.png]] | ||
115 | |||
116 | |||
117 | |||
118 | === 2.2.1 Insert SIM card === | ||
119 | |||
120 | Insert the NB-IoT Card get from your provider. | ||
121 | |||
122 | |||
123 | User need to take out the NB-IoT module and insert the SIM card like below: | ||
124 | |||
125 | |||
126 | [[image:file:///C:/Users/93456/AppData/Local/Temp/msohtmlclip1/01/clip_image003.png]] | ||
127 | |||
128 | |||
129 | === 2.2.3 Configure NDS01 === | ||
130 | |||
131 | User need to configure NDS01 via serial port to set the **Server Address** / **Uplink Topic** to define where and how-to uplink packets. NDS01 support AT Commands, user can use a USB to TTL adapter to connect to NDS01 and use AT Commands to configure it, NDS01 needs to be in the wake-up state when using AT commands,as below. | ||
132 | |||
133 | [[image:file:///C:/Users/93456/AppData/Local/Temp/msohtmlclip1/01/clip_image004.png]] | ||
134 | |||
135 | |||
136 | |||
137 | Connection: | ||
138 | |||
139 | USB TTL GND <~-~-~-~-> GND | ||
140 | |||
141 | USB TTL TXD <~-~-~-~-> UART_RXD | ||
142 | |||
143 | USB TTL RXD <~-~-~-~-> UART_TXD | ||
144 | |||
145 | |||
146 | |||
147 | In the PC, use below serial tool settings: | ||
148 | |||
149 | * Baud: **115200** | ||
150 | * Data bits:** 8** | ||
151 | * Stop bits: **1** | ||
152 | * Parity: **None** | ||
153 | * Flow Control: **None** | ||
154 | |||
155 | After powering on the NDS01, the following information will be printed | ||
156 | |||
157 | [[image:file:///C:/Users/93456/AppData/Local/Temp/msohtmlclip1/01/clip_image005.png]] | ||
158 | |||
159 | AT command set | ||
160 | |||
161 | 1. Set and query the communication protocol | ||
162 | |||
163 | Send: AT+PRO=<val> Val: 0:TCP 1:UDP | ||
164 | |||
165 | Reply: OK | ||
166 | |||
167 | Send: AT+PRO? ~/~/Inquire | ||
168 | |||
169 | Reply: +PRO:0 | ||
170 | |||
171 | OK | ||
172 | |||
173 | 1. Set and query the server address | ||
174 | |||
175 | Send: AT+SERVADDR=<server>,<port> | ||
176 | |||
177 | Reply: OK | ||
178 | |||
179 | Send: AT+SERVADDR? ~/~/Inquire | ||
180 | |||
181 | Reply: +SERVADDR:<server>,<port> | ||
182 | |||
183 | OK | ||
184 | |||
185 | 1. Set and query the TDC | ||
186 | |||
187 | Send:AT+TDC=<value>~/~/Heartbeat time, in seconds, the default is 86400s,which is 24 hours | ||
188 | |||
189 | Reply:OK | ||
190 | |||
191 | Send:AT+TDC? ~/~/Inquire | ||
192 | |||
193 | Reply: +TDC:<value> | ||
194 | |||
195 | OK | ||
196 | |||
197 | 1. Query parameters | ||
198 | |||
199 | Send:AT+CFG? | ||
200 | |||
201 | Reply:+PRO:0 | ||
202 | |||
203 | +SERVADDR:120.27.12.119,2023 | ||
204 | |||
205 | +TDC:86400 | ||
206 | |||
207 | +CSQ:31 | ||
208 | |||
209 | +IMEI:868163049937383 | ||
210 | |||
211 | +ICCID:898604611619C0854626 | ||
212 | |||
213 | +IMSI:460048118204626 | ||
214 | |||
215 | OK | ||
216 | |||
217 | 1. Set and query the APN | ||
218 | |||
219 | Send: AT+APN="<apn>" ~/~/Set APN | ||
220 | |||
221 | Reply: OK | ||
222 | |||
223 | Send: AT+APN? ~/~/Inquire | ||
224 | |||
225 | Reply: +APN:"cmiot" | ||
226 | |||
227 | OK | ||
228 | |||
229 | 1. Alarm and Silencer | ||
230 | |||
231 | Send:AT+ALARM=<value> ~/~/0~~1,0: mute 1: buzzer alarm (note that no data will be reported, only the buzzer and the red light are on, if it is in silent mode, only the red light is on) | ||
232 | |||
233 | Reply: OK | ||
234 | |||
235 | |||
236 | |||
237 | |||
238 | === 2.2.4 Use UDP protocol to uplink data (Default protocol) === | ||
239 | |||
240 | * **AT+PRO=1 ** ~/~/ Set to use UDP protocol to uplink | ||
241 | * **AT+SERVADDR=119.91.62.30,1999 **~/~/ to set UDP server address and port | ||
242 | |||
243 | [[image:file:///C:/Users/93456/AppData/Local/Temp/msohtmlclip1/01/clip_image006.png]] | ||
244 | |||
245 | |||
246 | |||
247 | === 2.2.5 Use TCP protocol to uplink data === | ||
248 | |||
249 | * **AT+PRO=0 ** ~/~/ Set to use TCP protocol to uplink | ||
250 | * **AT+SERVADDR=119.91.62.30,2002 **~/~/ to set TCP server address and port | ||
251 | |||
252 | [[image:file:///C:/Users/93456/AppData/Local/Temp/msohtmlclip1/01/clip_image007.png]] | ||
253 | |||
254 | |||
255 | |||
256 | |||
257 | === 2.2.6 Change Update Interval === | ||
258 | |||
259 | User can use below command to change the **uplink interval**. | ||
260 | |||
261 | **AT+TDC=86400 **~/~/ Set Update Interval to 86400s | ||
262 | |||
263 | |||
264 | **NOTE:** | ||
265 | |||
266 | 1. By default, the device will send an uplink message every 24 hour (86400s). | ||
267 | |||
268 | [[image:file:///C:/Users/93456/AppData/Local/Temp/msohtmlclip1/01/clip_image008.png]] | ||
269 | |||
270 | |||
271 | |||
272 | |||
273 | == 2.3 Uplink Payload == | ||
274 | |||
275 | registration package, uplink payload includes in total 61 bytes | ||
276 | |||
277 | |||
278 | |((( | ||
279 | **Size** | ||
280 | |||
281 | **(bytes)** | ||
282 | )))|**2**|**1**|**1**|**1**|**1**|**15**|**15**|**20**|**1**|**1**|**3** | ||
283 | |**Value**|head|Version|data type|Data length|device type|device ID|IMSI|ICCID|BAT|Signal|tail | ||
284 | |||
285 | The payload is ASCII string, representative same HEX: 0x4B5710013401383639393735303334343431303832343630313133313138373433373332 | ||
286 | |||
287 | 38393836313132303232343031343339383736321E15494F54 where: | ||
288 | |||
289 | * Head: 0x4B57(fixed) | ||
290 | * Version: 0x10=”V1.0” | ||
291 | * Data type: 0x01=1(1:register,2:data sending) | ||
292 | * Data length: 0x34=52(Valid data is 52 bytes) | ||
293 | |||
294 | * Device type: 0x01 = 1(Representative NDS01) | ||
295 | * Device ID:0x383639393735303334343431303832=869975034441082(ASCII) | ||
296 | * IMSI: 0x343630313133313138373433373332 = 460113118743732(ASCII) | ||
297 | * ICCID: 0x3839383631313230323234303134333938373632=89861120224014398762(ASCII) | ||
298 | * Bat: 0x1E = 30/10=3.0V | ||
299 | * Signal: 0x15=21 | ||
300 | |||
301 | **0** -113dBm or less | ||
302 | |||
303 | **1** -111dBm | ||
304 | |||
305 | **2...30** -109dBm... -53dBm | ||
306 | |||
307 | **31** -51dBm or greater | ||
308 | |||
309 | **99** Not known or not detectable | ||
310 | |||
311 | * Tail:0x494F54(fixed) | ||
312 | |||
313 | data upload, uplink payload includes in total 32 bytes | ||
314 | |||
315 | |((( | ||
316 | **Size** | ||
317 | |||
318 | **(bytes)** | ||
319 | )))|**2**|**1**|**1**|**1**|**1**|**15**|**1**|**1**|**1**|**1**|**1**|**1**|**1**|**1**|**3** | ||
320 | |**Value**|head|Version|data type|Data length|device type|device ID|event type|Door magnetic state|BAT|Signal|((( | ||
321 | Temp | ||
322 | |||
323 | integer | ||
324 | )))|((( | ||
325 | Temp | ||
326 | |||
327 | decimal | ||
328 | )))|((( | ||
329 | Hum | ||
330 | |||
331 | integer | ||
332 | )))|((( | ||
333 | Hum | ||
334 | |||
335 | decimal | ||
336 | )))|tail | ||
337 | |||
338 | The payload is ASCII string, representative same HEX: 0x4B5710021401383639393735303334343431303832010020151c552312494F54 where: | ||
339 | |||
340 | * Head: 0x4B57(fixed) | ||
341 | * Version: 0x10=”V1.0” | ||
342 | * Data type: 0x02=2(1:register,2:data sending) | ||
343 | * Data length: 0x14=20(Valid data is 20 bytes) | ||
344 | |||
345 | * Device type: 0x01 = 1(Representative NDS01) | ||
346 | * Device ID:0x383639393735303334343431303832=869975034441082(ASCII) | ||
347 | * Event type:0x01 | ||
348 | |||
349 | 01:TDC | ||
350 | |||
351 | 02:alarm | ||
352 | |||
353 | 03:remove alarm | ||
354 | |||
355 | 04:dismantling alarm | ||
356 | |||
357 | 05:remove demolition alarm | ||
358 | |||
359 | 06:low voltage | ||
360 | |||
361 | 07:remove low voltage | ||
362 | |||
363 | * Door magnetic state: 0x00 | ||
364 | |||
365 | 00:Door sensor is close | ||
366 | |||
367 | 01:Door sensor is open | ||
368 | |||
369 | * Bat: 0x20 = 32/10=3.2V | ||
370 | * Signal: 0x15=21 | ||
371 | |||
372 | **0** -113dBm or less | ||
373 | |||
374 | **1** -111dBm | ||
375 | |||
376 | **2...30** -109dBm... -53dBm | ||
377 | |||
378 | **31** -51dBm or greater | ||
379 | |||
380 | **99** Not known or not detectable | ||
381 | |||
382 | * Temp integer:0x1c=28 | ||
383 | * Temp decimal:0x55=85 | ||
384 | |||
385 | Temp =Temp integer+(Temp decimal)/100=28+85/100=28.85℃ | ||
386 | |||
387 | * Hum integer:0x23=35 | ||
388 | * Hum decimal:0x12=18 | ||
389 | |||
390 | Hum =Hum integer+(Hum decimal)/100=35+18/100=35.18**%rh** | ||
391 | |||
392 | * Tail:0x494F54(fixed) | ||
393 | |||
394 | |||
395 | |||
396 | == 2.4 Node-Red Example == | ||
397 | |||
398 | Please refer to this link for the use of Node-RED: | ||
399 | |||
400 | [[http:~~/~~/8.211.40.43:8080/xwiki/bin/view/Main/Node-RED/>>url:http://8.211.40.43:8080/xwiki/bin/view/Main/Node-RED/]] | ||
401 | |||
402 | Please visit this link to download the Node-RED process: | ||
403 | |||
404 | [[https:~~/~~/github.com/dragino/dragino-end-node-decoder/tree/main/Node-RED>>url:https://github.com/dragino/dragino-end-node-decoder/tree/main/Node-RED]] | ||
405 | |||
406 | [[image:file:///C:/Users/93456/AppData/Local/Temp/msohtmlclip1/01/clip_image009.png]] | ||
407 | |||
408 | |||
409 | |||
410 | |||
411 | == 2.5 Buttons and LED and Mode == | ||
412 | |||
413 | Operating mode | ||
414 | |||
415 | (1) In the self-check mode (the default is the self-check mode when power on for the first time), the state change of the tamper switch does not trigger an alarm; | ||
416 | |||
417 | (2) In normal working mode, the state change of the tamper switch triggers an alarm; | ||
418 | |||
419 | (3) In silent mode (the default is non-silent mode when power on for the first time), the buzzer is silent. | ||
420 | |||
421 | |||
422 | led lights | ||
423 | |||
424 | (1) After the device is powered on, the green light flashes once; | ||
425 | |||
426 | (2) The device does not set server parameters or cannot connect to the server, and the green light flashes quickly; | ||
427 | |||
428 | (3) SIM card recognition fails, the green light is always on for 20s; | ||
429 | |||
430 | (4) The equipment signal is poor, and the green light flashes once every 3 seconds; | ||
431 | |||
432 | (5) When the device sends data, the green light flashes twice; | ||
433 | |||
434 | (6) The communication of the equipment is normal, and the green light flashes 3 times continuously; | ||
435 | |||
436 | (7) Trigger the tamper switch, the red light is always on for 30s, and goes out when the alarm is canceled; | ||
437 | |||
438 | (8) Trigger the door magnetic alarm, the red light is always on for 30s, and goes out when the alarm is canceled; | ||
439 | |||
440 | |||
441 | buzzer | ||
442 | |||
443 | (1) When the door magnetic alarm is triggered, the buzzer will sound for 30s; after the alarm is restored, the buzzer will be silenced; | ||
444 | |||
445 | (2) Enter the normal working mode (the tamper switch is closed for more than 5s or the door sensor is locked for more than 5s), the buzzer will sound for 1500ms; | ||
446 | |||
447 | (3) After entering the normal working mode, the tamper switch does not close, the buzzer sounds for 30s, the tamper switch is closed, and the buzzer sounds 1 time; | ||
448 | |||
449 | (4) When the door sensor does not alarm, press the button to trigger the alarm, and the buzzer will sound for 30s; when the door sensor alarms, press it once to cancel the alarm, and the buzzer will be silenced. | ||
450 | |||
451 | |||
452 | button | ||
453 | |||
454 | (1) When there is no alarm, press it once to trigger the alarm, and the buzzer will sound; when it alarms, press the buzzer to silence the sound. | ||
455 | |||
456 | (2) Press twice to silence the buzzer; | ||
457 | |||
458 | (3) Press the button three times or more, when the mute function is turned off, the mute function is turned on, and the green light flashes once; when the mute function is turned on, the mute function is turned off, and the green light flashes once. | ||
459 | |||
460 | |||
461 | data pack | ||
462 | |||
463 | (1) The device needs to send a registration packet and a heartbeat packet every time it is powered on and registered; | ||
464 | |||
465 | (2) The heartbeat time is reported once every 24 hours by default. | ||
466 | |||
467 | = 3. FAQ = | ||
468 | |||
469 | == 3.1 How to Upgrade Firmware == | ||
470 | |||
471 | User can upgrade the firmware for 1) bug fix, 2) new feature release. | ||
472 | |||
473 | Burning software please go to this link to download: | ||
474 | |||
475 | Note: | ||
476 | |||
477 | Disconnect one battery before starting the upgrade | ||
478 | |||
479 | Please use 1.8V USB TO TTL serial port | ||
480 | |||
481 | Connection: | ||
482 | |||
483 | USB TTL GND <~-~-~-~-> GND | ||
484 | |||
485 | USB TTL TXD <~-~-~-~-> UART_RXD | ||
486 | |||
487 | USB TTL RXD <~-~-~-~-> UART_TXD | ||
488 | |||
489 | 1. Double-click "FlashTool.exe" to start the program | ||
490 | |||
491 | [[image:file:///C:/Users/93456/AppData/Local/Temp/msohtmlclip1/01/clip_image010.png]] | ||
492 | |||
493 | [[image:file:///C:/Users/93456/AppData/Local/Temp/msohtmlclip1/01/clip_image011.png]] | ||
494 | |||
495 | 1. Select burn serial port and firmware package to complete the upgrade | ||
496 | |||
497 | [[image:file:///C:/Users/93456/AppData/Local/Temp/msohtmlclip1/01/clip_image012.png]] | ||
498 | |||
499 | [[image:file:///C:/Users/93456/AppData/Local/Temp/msohtmlclip1/01/clip_image013.png]] | ||
500 | |||
501 | 1. Install the battery to the node, and the upgrade will start at this time | ||
502 | |||
503 | [[image:file:///C:/Users/93456/AppData/Local/Temp/msohtmlclip1/01/clip_image014.png]] | ||
504 | |||
505 | 1. The following screenshot appears, indicating that the upgrade has been successful | ||
506 | |||
507 | [[image:file:///C:/Users/93456/AppData/Local/Temp/msohtmlclip1/01/clip_image015.png]] | ||
508 | |||
509 | |||
510 | = 4. Order Info = | ||
511 | |||
512 | Part Number: **NDS01** | ||
513 | |||
514 | |||
515 | = 5. Packing Info = | ||
516 | |||
517 | |||
518 | **Package Includes**: | ||
519 | |||
520 | * NDS01 NB-IoT Door Sensor | ||
521 | |||
522 | **Dimension and weight**: | ||
523 | |||
524 | * Device Size: | ||
525 | * Device Weight: | ||
526 | * Package Size / pcs : | ||
527 | * Weight / pcs : |