Wiki source code of LDS02 - LoRaWAN Door Sensor User Manual
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | (% style="text-align:center" %) | ||
2 | [[image:1654679359875-169.png]] | ||
3 | |||
4 | |||
5 | **Contents:** | ||
6 | |||
7 | {{toc/}} | ||
8 | |||
9 | |||
10 | |||
11 | |||
12 | |||
13 | = 1. Introduction = | ||
14 | |||
15 | == 1.1 What is LDS02 LoRaWAN Door Sensor == | ||
16 | |||
17 | |||
18 | ((( | ||
19 | The Dragino LDS02 is a (% style="color:#037691" %)**LoRaWAN Door Sensor**(%%). It detects door open/close status and uplink to IoT server via LoRaWAN network. user can see the door status, open time, open counts in the IoT Server. | ||
20 | |||
21 | LDS02 is powered by (% style="color:#037691" %)**2 x AAA batteries**(%%) and target for long time use, these two batteries can provide about 16,000 ~~ 70,000 uplink packets. After battery running out, user can easily open the enclosure and replace with 2 common AAA batteries. | ||
22 | |||
23 | The LDS02 will send periodically data every day as well as for each door open/close action. It also (% style="color:#037691" %)**counts the door open times**(%%) and (% style="color:#037691" %)**calculate last door open duration**(%%). User can also disable the uplink for each open/close event, instead, device can count each open event and uplink periodically. | ||
24 | |||
25 | LDS02 has the (% style="color:#037691" %)**open alarm feature**(%%), user can set this feature so device will send Alarm if the door has been open for a certain time. | ||
26 | |||
27 | Each LDS02 is (% style="color:#037691" %)**pre-load with a set of unique keys**(%%) for LoRaWAN registration, register these keys to LoRaWAN server and it will auto connect after power on. | ||
28 | ))) | ||
29 | |||
30 | [[image:image-20220608171947-2.png]] | ||
31 | |||
32 | |||
33 | |||
34 | == 1.2 Features == | ||
35 | |||
36 | * LoRaWAN Class A v1.0.3 | ||
37 | * Frequency Bands: CN470/EU433/KR920/US915/EU868/AS923/AU915/IN865/RU864 | ||
38 | * SX1262 LoRa Core | ||
39 | * Water Leak detect | ||
40 | * 2 x AAA LR03 Batteries | ||
41 | * AT Commands to change parameters | ||
42 | * Uplink on periodically and open/close action | ||
43 | * Remote configure parameters via LoRa Downlink | ||
44 | * Firmware upgradable via program port | ||
45 | |||
46 | |||
47 | == 1.3 Applications == | ||
48 | |||
49 | * Smart Buildings & Home Automation | ||
50 | * Logistics and Supply Chain Management | ||
51 | * Smart Metering | ||
52 | * Smart Agriculture | ||
53 | * Smart Cities | ||
54 | * Smart Factory | ||
55 | |||
56 | |||
57 | == 1.4 Dimension == | ||
58 | |||
59 | Unit: mm | ||
60 | |||
61 | [[image:1654680563545-120.png]] | ||
62 | |||
63 | |||
64 | [[image:1654680510816-654.png]] | ||
65 | |||
66 | |||
67 | == 1.5 Firmware Change log == | ||
68 | |||
69 | ((( | ||
70 | ((( | ||
71 | LDS02 use the same firmware as LDS01. | ||
72 | ))) | ||
73 | |||
74 | ((( | ||
75 | [[LDS02 Image files – Download link>>url:http://www.dragino.com/downloads/index.php?dir=LoRa_End_Node/LDS01/Firmware/]] | ||
76 | ))) | ||
77 | ))) | ||
78 | |||
79 | |||
80 | = 2. Power ON LDS02 = | ||
81 | |||
82 | When receive the LDS02, please open the enclosure and add 2 x AAA batteries to power it. The [[LED>>||anchor="H4.7LEDs"]] will blink when device is powered. | ||
83 | |||
84 | |||
85 | = 3. How to install LDS02 = | ||
86 | |||
87 | ((( | ||
88 | ((( | ||
89 | When install the LDS02 on wall. Please make sure install as below so the marks will close to each other when close the door. | ||
90 | ))) | ||
91 | |||
92 | ((( | ||
93 | Open/Close threshold range: ~~ 25mm | ||
94 | ))) | ||
95 | ))) | ||
96 | |||
97 | [[image:1654680716522-793.png]] | ||
98 | |||
99 | |||
100 | |||
101 | = 4. Operation Mode = | ||
102 | |||
103 | == 4.1 How it works? == | ||
104 | |||
105 | ((( | ||
106 | The LDS02 is configured as LoRaWAN OTAA Class A mode by default. It has OTAA keys to join network. To connect a local LoRaWAN network, user just need to input the OTAA keys in the network server and [[power on>>||anchor="H2.PowerONLWL02"]] the LDS02. It will auto join the network via OTAA. | ||
107 | ))) | ||
108 | |||
109 | ((( | ||
110 | In case user can’t set the OTAA keys in the network server and has to use the existing keys from server. User can [[use AT Command>>||anchor="H6.UseATCommand"]] to set the keys in the devices. | ||
111 | ))) | ||
112 | |||
113 | |||
114 | == 4.2 Example to join LoRaWAN network == | ||
115 | |||
116 | Here shows an example for how to join the [[TTN V3 Network>>url:https://eu1.cloud.thethings.network/]]. Below is the network structure, we use [[LG308>>url:http://www.dragino.com/products/lora-lorawan-gateway/item/140-lg308.html]] as LoRaWAN gateway here. | ||
117 | |||
118 | [[image:1654680810108-149.png]] | ||
119 | |||
120 | |||
121 | ((( | ||
122 | The LDS02 in installed on the door edge to detect the open / close event. And send the status to LoRaWAN server. The LDS02 will uplink two type of messages to the server. | ||
123 | ))) | ||
124 | |||
125 | * ((( | ||
126 | A keep-alive message which send once per day. | ||
127 | ))) | ||
128 | * ((( | ||
129 | A door event message when there is a door open/close. ([[Alarm event can be disabled>>||anchor="H7.3CanIdisableuplinkforeacheventtosavebatterylife3F"]]) | ||
130 | ))) | ||
131 | |||
132 | ((( | ||
133 | |||
134 | |||
135 | The LG308 is already set to connect to [[TTN V3 network >>url:https://eu1.cloud.thethings.network/]]. What we need to now is only configure the TTN V3: | ||
136 | ))) | ||
137 | |||
138 | ((( | ||
139 | (% style="color:blue" %)**Step 1**(%%): Create a device in TTN V3 with the OTAA keys from LDS02. | ||
140 | ))) | ||
141 | |||
142 | ((( | ||
143 | Each LDS02 is shipped with a sticker with unique device EUI: | ||
144 | ))) | ||
145 | |||
146 | [[image:1654671040430-368.png]] | ||
147 | |||
148 | |||
149 | User can enter this key in their LoRaWAN Server portal. Below is TTN V3 screen shot: | ||
150 | |||
151 | **Add APP EUI in the application** | ||
152 | |||
153 | [[image:1654671794691-956.png]] | ||
154 | |||
155 | |||
156 | [[image:1654671809850-574.png]] | ||
157 | |||
158 | [[image:1654671820156-640.png]] | ||
159 | |||
160 | |||
161 | [[image:1654681258096-500.png]] | ||
162 | |||
163 | |||
164 | **Add APP KEY and DEV EUI** | ||
165 | |||
166 | [[image:1654671889112-678.png]] | ||
167 | |||
168 | |||
169 | (% style="color:blue" %)**Step 2**(%%): **[[Power on>>||anchor="H2.PowerONLWL02"]]** LWL02 and it will auto join to the TTN V3 network. After join success, it will start to upload message to TTN V3 and user can see in the panel. | ||
170 | |||
171 | |||
172 | |||
173 | |||
174 | |||
175 | == 4.3 Uplink Payload == | ||
176 | |||
177 | |||
178 | Uplink Payload total 9 bytes. | ||
179 | |||
180 | [[image:image-20220608150921-5.png]] | ||
181 | |||
182 | |||
183 | **Example:** | ||
184 | |||
185 | [[image:1654672186477-234.png]] | ||
186 | |||
187 | |||
188 | ((( | ||
189 | Example Payload Decoder in TTN V3: [[http:~~/~~/www.dragino.com/downloads/index.php?dir=LoRa_End_Node/LDS01/Payload/>>url:http://www.dragino.com/downloads/index.php?dir=LoRa_End_Node/LDS01/Payload/]] | ||
190 | ))) | ||
191 | |||
192 | |||
193 | == 4.4 Downlink Payload == | ||
194 | |||
195 | |||
196 | (% border="1" cellspacing="10" style="background-color:#ffffcc; color:green; width:410px" %) | ||
197 | |=(% style="width: 180px;" %)**Downlink Control Type**|=(% style="width: 80px;" %)**Type Code**|=(% style="width: 150px;" %)**Downlink payload size(bytes)** | ||
198 | |(% style="width:180px" %)TDC (Transmit Time Interval—Keep Alive Interval)|(% style="width:80px" %)0x01|(% style="width:150px" %)4 | ||
199 | |(% style="width:180px" %)RESET|(% style="width:80px" %)0x04|(% style="width:224px" %)2 | ||
200 | |(% style="width:180px" %)[[Set confirmed mode>>||anchor="HTypeCode0x05"]]|(% style="width:80px" %)0x05|(% style="width:150px" %)2 | ||
201 | |(% style="width:180px" %)[[Clear Counting>>||anchor="HTypeCode0xA6"]]|(% style="width:80px" %)0xA6|(% style="width:150px" %)2 | ||
202 | |(% style="width:180px" %)[[Enable/Disable Alarm>>||anchor="HTypeCode0xA7"]]|(% style="width:80px" %)0xA7|(% style="width:150px" %)2 | ||
203 | |(% style="width:180px" %)[[Control ADR/DR>>||anchor="HTypeCode0xA8"]]|(% style="width:80px" %)0xA8|(% style="width:150px" %)3 | ||
204 | |(% style="width:180px" %)[[Set Alarm Timeout>>||anchor="HTypeCode0xA9"]]|(% style="width:80px" %)0xA9|(% style="width:150px" %)4 | ||
205 | |||
206 | Example Downlink payload setting in TTN V3: | ||
207 | |||
208 | [[image:1654673412319-976.png]] | ||
209 | |||
210 | |||
211 | === (% style="color:#037691" %)**Type Code 0x01**(%%) === | ||
212 | |||
213 | If the payload=0100003C, means to control the LWL02’s Keep Alive interval to 0x00003C=60(S) | ||
214 | |||
215 | |||
216 | === (% style="color:#037691" %)**Type Code 0x04**(%%) === | ||
217 | |||
218 | If payload = 0x04FF, it will reset the LWL02. | ||
219 | |||
220 | |||
221 | === (% style="color:#037691" %)**Type Code 0x05**(%%) === | ||
222 | |||
223 | 0x05 00: Set uplink to LoRaWAN unconfirmed mode | ||
224 | |||
225 | 0x05 01: Set uplink to LoRaWAN confirmed mode | ||
226 | |||
227 | |||
228 | === (% style="color:#037691" %)**Type Code 0xA6**(%%) === | ||
229 | |||
230 | Example: 0xA601: Clear Counting | ||
231 | For LWL02: reset both count number and time. | ||
232 | |||
233 | |||
234 | === (% style="color:#037691" %)**Type Code 0xA7**(%%) === | ||
235 | |||
236 | 0xA7 01 : Equal to AT+DISALARM=1 | ||
237 | |||
238 | 0xA7 00 : Equal to AT+DISALARM=0 | ||
239 | |||
240 | |||
241 | === (% style="color:#037691" %)**Type Code 0xA8**(%%) === | ||
242 | |||
243 | Format: 0xA8 aa bb | ||
244 | |||
245 | aa: 1: Enable ADR; 0: Disable ADR (Same as AT+CADR command) | ||
246 | |||
247 | bb: set DR (Same as AT+CDATARATE ,only valid after ADR=0) | ||
248 | |||
249 | Example: 0x A8 00 02 : Set ADR=0 and DR=1 | ||
250 | |||
251 | |||
252 | === (% style="color:#037691" %)**Type Code 0xA9**(%%) === | ||
253 | |||
254 | See [[Alarm Base Timeout>>||anchor="H4.6AlarmBaseonTimeout"]] for detail. | ||
255 | |||
256 | |||
257 | == 4.5 Integrate with Datacake == | ||
258 | |||
259 | ((( | ||
260 | Datacake provides a human friendly interface to show the sensor data, once we have data in TTN V3, we can use Datacake to connect to TTN V3 and see the data in Datacake. Below are the steps: | ||
261 | ))) | ||
262 | |||
263 | |||
264 | (% style="color:blue" %)**Step 1**(%%): Be sure that your device is programmed and properly connected to the network at this time. | ||
265 | |||
266 | (% style="color:blue" %)**Step 2**(%%): To configure the Application to forward data to Datacake you will need to add integration. To add the Datacake integration, perform the following steps: | ||
267 | |||
268 | |||
269 | [[image:1654674520913-519.png]] | ||
270 | |||
271 | |||
272 | [[image:1654674530910-914.png]] | ||
273 | |||
274 | |||
275 | [[image:1654674543078-401.png]] | ||
276 | |||
277 | |||
278 | (% style="color:blue" %)**Step 3**(%%): Create an account or log in Datacake. | ||
279 | |||
280 | (% style="color:blue" %)**Step 4**(%%): Search LWL02 and add DevEUI. | ||
281 | |||
282 | [[image:1654674556510-911.png]] | ||
283 | |||
284 | |||
285 | == 4.6 Alarm Base on Timeout == | ||
286 | |||
287 | ((( | ||
288 | LWL02 can monitor the timeout for a status change, this feature can be used to monitor some event such as open fridge too long etc. | ||
289 | ))) | ||
290 | |||
291 | ((( | ||
292 | User configure this feature by using: | ||
293 | ))) | ||
294 | |||
295 | ((( | ||
296 | |||
297 | ))) | ||
298 | |||
299 | ((( | ||
300 | (% style="color:blue" %)**AT Command**(%%) to configure: | ||
301 | ))) | ||
302 | |||
303 | * ((( | ||
304 | **AT+TTRIG=1,30 ** **~-~->** When status change from close to open, and device keep in open | ||
305 | ))) | ||
306 | |||
307 | ((( | ||
308 | status for more than 30 seconds. LWL02 will send an uplink packet, the Alarm bit (the lowest bit of 10^^th^^ byte of payload) on this uplink packet is set to 1. | ||
309 | ))) | ||
310 | |||
311 | * ((( | ||
312 | **AT+TTIG=0,0** **~-~->** Default Value, disable timeout Alarm. | ||
313 | ))) | ||
314 | |||
315 | ((( | ||
316 | (% style="color:blue" %)**Downlink Command**(%%) to configure: | ||
317 | ))) | ||
318 | |||
319 | ((( | ||
320 | **Command: 0xA9 aa bb cc** | ||
321 | ))) | ||
322 | |||
323 | ((( | ||
324 | A9: Command Type Code | ||
325 | ))) | ||
326 | |||
327 | ((( | ||
328 | aa: status to be monitor | ||
329 | ))) | ||
330 | |||
331 | ((( | ||
332 | bb cc: timeout. | ||
333 | ))) | ||
334 | |||
335 | ((( | ||
336 | |||
337 | ))) | ||
338 | |||
339 | ((( | ||
340 | If user send 0xA9 01 00 1E: equal to AT+TTRIG=1,30 | ||
341 | ))) | ||
342 | |||
343 | ((( | ||
344 | Or | ||
345 | ))) | ||
346 | |||
347 | ((( | ||
348 | 0xA9 00 00 00: Equal to AT+TTRIG=0,0. Disable timeout Alarm. | ||
349 | ))) | ||
350 | |||
351 | |||
352 | |||
353 | == 4.7 LEDs == | ||
354 | |||
355 | |||
356 | (% border="1" cellspacing="10" style="background-color:#ffffcc; width:463px" %) | ||
357 | |=(% style="width: 184px;" %)**Action**|=(% style="width: 275px;" %)**LED behavior** | ||
358 | |(% style="width:184px" %)Power On|(% style="width:275px" %)(% style="color:green" %)**GREEN on 1s, **(% style="color:red" %)**RED on 1s,**(%%)** (% style="color:blue" %)BLUE on 1s(%%)** | ||
359 | |(% style="width:184px" %)Joined successful|(% style="width:275px" %)(% style="color:green" %)**GRENN LED **(%%)on 5s | ||
360 | |(% style="width:184px" %)Send an uplink message|(% style="width:275px" %)(% style="color:green" %)**GREEN LED**(%%) blinks once | ||
361 | |(% style="width:184px" %)Got a downlink message|(% style="width:275px" %)(% style="color:blue" %)**BLUE LED**(%%) blinks once | ||
362 | |||
363 | = 5. Battery & How to replace = | ||
364 | |||
365 | == 5.1 Battery Type and replace == | ||
366 | |||
367 | ((( | ||
368 | LWL02 is equipped with 2 x AAA LR03 batteries. If the batteries running low(see 2.1v in the platform). User can buy generic AAA battery and replace it. Note: | ||
369 | ))) | ||
370 | |||
371 | 1. ((( | ||
372 | The LWL02 doesn’t have any screw, use can use nail to open it by the middle. | ||
373 | ))) | ||
374 | 1. ((( | ||
375 | Make sure the direction is correct when install the AAA batteries. | ||
376 | ))) | ||
377 | |||
378 | ((( | ||
379 | (% style="color:red" %)**Important Notice: Make sure use new AAA LR03 battery and the battery doesn’t have broken surface.** | ||
380 | ))) | ||
381 | |||
382 | ((( | ||
383 | |||
384 | ))) | ||
385 | |||
386 | ((( | ||
387 | Example of AAA LR03 batter: | ||
388 | ))) | ||
389 | |||
390 | [[image:1654675278044-307.png]] | ||
391 | |||
392 | |||
393 | == 5.2 Power Consumption Analyze == | ||
394 | |||
395 | ((( | ||
396 | Dragino battery powered products are all run in Low Power mode. User can check the guideline from this link to calculate the estimate battery life: | ||
397 | ))) | ||
398 | |||
399 | ((( | ||
400 | [[https:~~/~~/www.dragino.com/downloads/downloads/LoRa_End_Node/Battery_Analyze/DRAGINO_Battery_Life_Guide.pdf>>url:https://www.dragino.com/downloads/downloads/LoRa_End_Node/Battery_Analyze/DRAGINO_Battery_Life_Guide.pdf]] | ||
401 | ))) | ||
402 | |||
403 | |||
404 | = 6. Use AT Command = | ||
405 | |||
406 | == 6.1 Access AT Command == | ||
407 | |||
408 | LWL02 supports AT Command set. User can use a USB to TTL adapter to configure LWL02 via use AT command, as below. | ||
409 | |||
410 | [[image:image-20220608160336-1.png]] | ||
411 | |||
412 | |||
413 | (% style="background-color:yellow" %)**USB to TTL <- -> LWL02** | ||
414 | |||
415 | (% style="background-color:yellow" %)**RX <- -> TX** | ||
416 | |||
417 | (% style="background-color:yellow" %)**TX <- -> RX** | ||
418 | |||
419 | (% style="background-color:yellow" %)**GND <- -> GND** | ||
420 | |||
421 | |||
422 | ((( | ||
423 | In PC, User needs to set (% style="color:#037691" %)**serial tool**(%%)(such as [[putty>>url:https://www.chiark.greenend.org.uk/~~sgtatham/putty/latest.html]], SecureCRT) baud rate to (% style="color:green" %)**115200**(%%) to access to access serial console of LWL02. Below is the output for reference: | ||
424 | ))) | ||
425 | |||
426 | ((( | ||
427 | The AT Access password is (% style="color:red" %)**123456**. | ||
428 | ))) | ||
429 | |||
430 | [[image:1654675618022-630.png]] | ||
431 | |||
432 | ((( | ||
433 | Each AT Command need to (% style="color:red" %)**add an ENTER**(%%) at the end before send. | ||
434 | ))) | ||
435 | |||
436 | ((( | ||
437 | When entering the first command, the (% style="color:red" %)**RED LED**(%%) will on and user can now input AT Commands. After input all needed AT Commands, please input AT+CLPM=1 to set the device to work in Low Power mode and (% style="color:red" %)**RED LED**(%%) will be off. | ||
438 | ))) | ||
439 | |||
440 | ((( | ||
441 | More detail AT Command manual can be found at [[AT Command Manual>>url:http://www.dragino.com/downloads/index.php?dir=LoRa_End_Node/LDS01/]] | ||
442 | ))) | ||
443 | |||
444 | |||
445 | = 7. FAQ = | ||
446 | |||
447 | == 7.1 How to upgrade the image? == | ||
448 | |||
449 | User can upgrade the of LWL02 for bug fix, new features, or change working region. The upgrade instruction is here: [[Firmware Upgrade Instruction>>doc:Main.Firmware Upgrade Instruction for STM32 base products.WebHome]] | ||
450 | |||
451 | |||
452 | == 7.2 How to change the LoRa Frequency Bands/Region? == | ||
453 | |||
454 | If user has for example US915 frequency and want to change it to AS923 frequency. User can follow the introduction for [[how to upgrade image>>||anchor="H7.1Howtoupgradetheimage3F"]]. When download the images, choose the required image file for download. | ||
455 | |||
456 | |||
457 | == 7.3 Can I disable uplink for each event to save battery life? == | ||
458 | |||
459 | Yes, User can use below method to disable this: | ||
460 | |||
461 | (% style="color:#4f81bd" %)**via AT Command**: | ||
462 | |||
463 | AT+DISALARM=1, End node will only send packet in TDC time. | ||
464 | |||
465 | AT+DISALARM=0, End node will send packet in TDC time or status change for door sensor. | ||
466 | |||
467 | (% style="color:#4f81bd" %)**via LoRaWAN downlink Command**: | ||
468 | |||
469 | 0xA701 : Equal to AT+DISALARM=1 | ||
470 | |||
471 | 0xA700 : Equal to AT+DISALARM=0 | ||
472 | |||
473 | |||
474 | = 8. Order Info = | ||
475 | |||
476 | **Part Number: (% style="color:blue" %)LWL02-XXX(%%)** | ||
477 | |||
478 | (% style="color:blue" %)**XXX:** | ||
479 | |||
480 | * (% style="color:red" %)**EU433**(%%): frequency bands EU433 | ||
481 | * (% style="color:red" %)**EU868**(%%): frequency bands EU868 | ||
482 | * (% style="color:red" %)**KR920**(%%): frequency bands KR920 | ||
483 | * (% style="color:red" %)**CN470**(%%): frequency bands CN470 | ||
484 | * (% style="color:red" %)**AS923**(%%): frequency bands AS923 | ||
485 | * (% style="color:red" %)**AU915**(%%): frequency bands AU915 | ||
486 | * (% style="color:red" %)**US915**(%%): frequency bands US915 | ||
487 | * (% style="color:red" %)**IN865**(%%): frequency bands IN865 | ||
488 | * (% style="color:red" %)**CN779**(%%): frequency bands CN779 | ||
489 | |||
490 | = 9. Packing Info = | ||
491 | |||
492 | **Package Includes**: | ||
493 | |||
494 | * LWL02 x 1 | ||
495 | |||
496 | = 10. Support = | ||
497 | |||
498 | * Support is provided Monday to Friday, from 09:00 to 18:00 GMT+8. Due to different timezones we cannot offer live support. However, your questions will be answered as soon as possible in the before-mentioned schedule. | ||
499 | * Provide as much information as possible regarding your enquiry (product models, accurately describe your problem and steps to replicate it etc) and send a mail to [[support@dragino.com>>url:file:///D:/市场资料/说明书/LoRa/LT系列/support@dragino.com]]. | ||
500 | |||
501 |