Version 4.1 by Karry Zhuang on 2024/09/20 18:06

Show last authors
1
2
3
4
5
6
7 == 1.RS485-LB connects to third-party sensors ==
8
9 == How to connect RS485-LB node to UART distance sensor? ==
10
11 Take the A16-15 as an example, but the same setup can support different distance sensors, compare specifications see this [[link>>url:http://wiki.dragino.com/xwiki/bin/view/Main/User%20Manual%20for%20LoRaWAN%20End%20Nodes/DDS04-LB_LoRaWAN_4-Channels_Distance_Detection_Sensor_User_Manual/#H1.4ProbeOptions]] to DDS04-LB.
12
13 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20LoRaWAN%20End%20Nodes/RS485-LB_Waterproof_RS485UART_to_LoRaWAN_Converter/WebHome/image-20240703151202-1.png?rev=1.1||alt="image-20240703151202-1.png"]]
14
15 * (((
16 **Connection:**
17 )))
18
19 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20LoRaWAN%20End%20Nodes/RS485-LB_Waterproof_RS485UART_to_LoRaWAN_Converter/WebHome/image-20240703153033-2.jpeg?width=687&height=364&rev=1.1||alt="image-20240703153033-2.jpeg" height="364" width="687"]]
20
21 * **AT command configuration:  **
22
23 **AT+MOD=2    **
24
25 **AT+COMMAND1=01 02 03 04 05 ,0  AT+SEARCH1=1,ff  AT+DATACUT1=4,2,2~~3  AT+CMDDL1=1000**
26
27 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20LoRaWAN%20End%20Nodes/RS485-LB_Waterproof_RS485UART_to_LoRaWAN_Converter/WebHome/image-20240703153540-3.png?rev=1.1||alt="image-20240703153540-3.png"]]
28
29 * **Decoder:  Decoding refer to this [[link>>url:https://github.com/dragino/dragino-end-node-decoder/tree/main/RS485-LB_A16-15]].**
30 * **Example in TTN:**
31
32 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20LoRaWAN%20End%20Nodes/RS485-LB_Waterproof_RS485UART_to_LoRaWAN_Converter/WebHome/image-20240703161941-4.png?width=1357&height=619&rev=1.1||alt="image-20240703161941-4.png" height="619" width="1357"]]
33
34 == 2.SN50v3-LB connects to third-party sensors ==
35
36
37
38 === 2.3.2 Working Modes & Sensor Data. Uplink via FPORT~=2 ===
39
40 SN50v3-LB/LS has different working mode for the connections of different type of sensors. This section describes these modes. Use can use the AT Command (% style="color:blue" %)**AT+MOD**(%%) to set SN50v3-LB/LS to different working modes.
41
42 For example:
43
44 (% style="color:blue" %)**AT+MOD=2  ** (%%) ~/~/ will set the SN50v3 to work in MOD=2 distance mode which target to measure distance via Ultrasonic Sensor.
45
46
47 (% style="color:red" %) **Important Notice:**
48
49 ~1. Some working modes has payload more than 12 bytes, The US915/AU915/AS923 frequency bands' definition has maximum 11 bytes in (% style="color:blue" %)**DR0**(%%). Server sides will see NULL payload while SN50v3-LB/LS transmit in DR0 with 12 bytes payload.
50
51 2. All modes share the same Payload Explanation from HERE.
52
53 3. By default, the device will send an uplink message every 20 minutes.
54
55 ==== 2.3.2.1  MOD~=1 (Default Mode) ====
56
57 In this mode, uplink payload includes in total 11 bytes. Uplink packets use FPORT=2.
58
59 (% border="1" cellspacing="3" style="background-color:#f2f2f2; width:517px" %)
60 |(% style="background-color:#4f81bd; color:white; width:50px" %)**Size(bytes)**|(% style="background-color:#4f81bd; color:white; width:20px" %)**2**|(% style="background-color:#4f81bd; color:white; width:100px" %)**2**|(% style="background-color:#4f81bd; color:white; width:50px" %)**2**|(% style="background-color:#4f81bd; color:white; width:90px" %)**1**|(% style="background-color:#4f81bd; color:white; width:128px" %)**2**|(% style="background-color:#4f81bd; color:white; width:79px" %)**2**
61 |Value|Bat|(% style="width:191px" %)(((
62 Temperature(DS18B20)(PC13)
63 )))|(% style="width:78px" %)(((
64 ADC(PA4)
65 )))|(% style="width:216px" %)(((
66 Digital in(PB15)&Digital Interrupt(PA8)
67 )))|(% style="width:308px" %)(((
68 Temperature(SHT20 or SHT31 or BH1750 Illumination Sensor)
69 )))|(% style="width:154px" %)(((
70 Humidity(SHT20 or SHT31)
71 )))
72
73 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20LoRaWAN%20End%20Nodes/LSN50%20%26%20LSN50-V2%20-%20LoRaWAN%20Sensor%20Node%20User%20Manual/WebHome/image-20220627150949-6.png?rev=1.1||alt="image-20220627150949-6.png"]]
74
75 ==== 2.3.2.2  MOD~=2 (Distance Mode) ====
76
77 This mode is target to measure the distance. The payload of this mode is totally 11 bytes. The 8^^th^^ and 9^^th^^ bytes is for the distance.
78
79 (% border="1" cellspacing="3" style="background-color:#f2f2f2; width:517px" %)
80 |(% style="background-color:#4f81bd; color:white; width:50px" %)**Size(bytes)**|(% style="background-color:#4f81bd; color:white; width:29px" %)**2**|(% style="background-color:#4f81bd; color:white; width:108px" %)**2**|(% style="background-color:#4f81bd; color:white; width:40px" %)**2**|(% style="background-color:#4f81bd; color:white; width:110px" %)**1**|(% style="background-color:#4f81bd; color:white; width:140px" %)**2**|(% style="background-color:#4f81bd; color:white; width:40px" %)**2**
81 |Value|BAT|(% style="width:196px" %)(((
82 Temperature(DS18B20)(PC13)
83 )))|(% style="width:87px" %)(((
84 ADC(PA4)
85 )))|(% style="width:189px" %)(((
86 Digital in(PB15) & Digital Interrupt(PA8)
87 )))|(% style="width:208px" %)(((
88 Distance measure by: 1) LIDAR-Lite V3HP
89 Or 2) Ultrasonic Sensor
90 )))|(% style="width:117px" %)Reserved
91
92 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20LoRaWAN%20End%20Nodes/LSN50%20%26%20LSN50-V2%20-%20LoRaWAN%20Sensor%20Node%20User%20Manual/WebHome/1656324539647-568.png?rev=1.1||alt="1656324539647-568.png"]]
93
94 (% style="color:blue" %)**Connection of LIDAR-Lite V3HP:**
95
96 [[image:image-20230512173758-5.png||height="563" width="712"]]
97
98 (% style="color:blue" %)**Connection to Ultrasonic Sensor:**
99
100 (% style="color:red" %)**Need to remove R1 and R2 resistors to get low power,otherwise there will be 240uA standby current.**
101
102 [[image:image-20230512173903-6.png||height="596" width="715"]]
103
104 For the connection to TF-Mini or TF-Luna , MOD2 payload is as below:
105
106 (% border="1" cellspacing="3" style="background-color:#f2f2f2; width:517px" %)
107 |(% style="background-color:#4f81bd; color:white; width:50px" %)**Size(bytes)**|(% style="background-color:#4f81bd; color:white; width:20px" %)**2**|(% style="background-color:#4f81bd; color:white; width:100px" %)**2**|(% style="background-color:#4f81bd; color:white; width:100px" %)**1**|(% style="background-color:#4f81bd; color:white; width:50px" %)**2**|(% style="background-color:#4f81bd; color:white; width:120px" %)**2**|(% style="background-color:#4f81bd; color:white; width:77px" %)**2**
108 |Value|BAT|(% style="width:183px" %)(((
109 Temperature(DS18B20)(PC13)
110 )))|(% style="width:173px" %)(((
111 Digital in(PB15) & Digital Interrupt(PA8)
112 )))|(% style="width:84px" %)(((
113 ADC(PA4)
114 )))|(% style="width:323px" %)(((
115 Distance measure by:1)TF-Mini plus LiDAR
116 Or 2) TF-Luna LiDAR
117 )))|(% style="width:188px" %)Distance signal  strength
118
119 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20LoRaWAN%20End%20Nodes/LSN50%20%26%20LSN50-V2%20-%20LoRaWAN%20Sensor%20Node%20User%20Manual/WebHome/1656376779088-686.png?rev=1.1||alt="1656376779088-686.png"]]
120
121 **Connection to [[TF-Mini plus>>url:http://en.benewake.com/product/detail/5c345cd0e5b3a844c472329b.html]] LiDAR(UART version):**
122
123 (% style="color:red" %)**Need to remove R3 and R4 resistors to get low power,otherwise there will be 400uA standby current.**(%%)
124 (% style="color:red" %)[[image:image-20230512180609-7.png||height="555" width="802"]]
125
126 **Connection to [[TF-Luna>>url:http://en.benewake.com/product/detail/5e1c1fd04d839408076b6255.html]] LiDAR (UART version):**
127
128 (% style="color:red" %)**Need to remove R3 and R4 resistors to get low power,otherwise there will be 400uA standby current.**(%%)
129 (% style="color:red" %)[[image:image-20230610170047-1.png||height="452" width="799"]]
130
131 ==== 2.3.2.3  MOD~=3 (3 ADC + I2C) ====
132
133 ==== 2.3.2.3  MOD~=3 (3 ADC + I2C) ====
134
135
136 This mode has total 12 bytes. Include 3 x ADC + 1x I2C
137
138 (% border="1" cellspacing="3" style="background-color:#f2f2f2; width:517px" %)
139 |=(% style="width: 50px;background-color:#4F81BD;color:white" %)(((
140 **Size(bytes)**
141 )))|=(% style="width: 50px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 50px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 50px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 90px;background-color:#4F81BD;color:white" %)**1**|=(% style="width: 110px;background-color:#4F81BD;color:white" %)2|=(% style="width: 97px;background-color:#4F81BD;color:white" %)2|=(% style="width: 20px;background-color:#4F81BD;color:white" %)1
142 |Value|(% style="width:68px" %)(((
143 ADC1(PA4)
144 )))|(% style="width:75px" %)(((
145 ADC2(PA5)
146 )))|(((
147 ADC3(PA8)
148 )))|(((
149 Digital Interrupt(PB15)
150 )))|(% style="width:304px" %)(((
151 Temperature(SHT20 or SHT31 or BH1750 Illumination Sensor)
152 )))|(% style="width:163px" %)(((
153 Humidity(SHT20 or SHT31)
154 )))|(% style="width:53px" %)Bat
155 [[image:image-20230513110214-6.png]]
156
157 ==== 2.3.2.4 MOD~=4 (3 x DS18B20) ====
158
159 This mode has total 11 bytes. As shown below:
160
161 (% border="1" cellspacing="3" style="background-color:#f2f2f2; width:517px" %)
162 |(% style="background-color:#4f81bd; color:white; width:50px" %)**Size(bytes)**|(% style="background-color:#4f81bd; color:white; width:20px" %)**2**|(% style="background-color:#4f81bd; color:white; width:100px" %)**2**|(% style="background-color:#4f81bd; color:white; width:50px" %)**2**|(% style="background-color:#4f81bd; color:white; width:99px" %)**1**|(% style="background-color:#4f81bd; color:white; width:99px" %)**2**|(% style="background-color:#4f81bd; color:white; width:99px" %)**2**
163 |Value|BAT|(% style="width:186px" %)(((
164 Temperature1(DS18B20)(PC13)
165 )))|(% style="width:82px" %)(((
166 ADC(PA4)
167 )))|(% style="width:210px" %)(((
168 Digital in(PB15) & Digital Interrupt(PA8) 
169 )))|(% style="width:191px" %)Temperature2(DS18B20)
170 (PB9)|(% style="width:183px" %)Temperature3(DS18B20)(PB8)
171
172 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20LoRaWAN%20End%20Nodes/LSN50%20%26%20LSN50-V2%20-%20LoRaWAN%20Sensor%20Node%20User%20Manual/WebHome/1656377606181-607.png?rev=1.1||alt="1656377606181-607.png"]]
173
174 [[image:image-20230513134006-1.png||height="559" width="736"]]
175
176 ==== 2.3.2.5  MOD~=5(Weight Measurement by HX711) ====
177
178 [[image:image-20230512164658-2.png||height="532" width="729"]]
179
180 Each HX711 need to be calibrated before used. User need to do below two steps:
181
182 1. Zero calibration. Don't put anything on load cell and run (% style="color:blue" %)**AT+WEIGRE**(%%) to calibrate to Zero gram.
183 1. Adjust calibration factor (default value 400): Put a known weight thing on load cell and run (% style="color:blue" %)**AT+WEIGAP**(%%) to adjust the Calibration Factor.
184 1. (((
185 Weight has 4 bytes, the unit is g.
186
187
188
189 )))
190
191 For example:
192
193 (% style="color:blue" %)**AT+GETSENSORVALUE =0**
194
195 Response:  Weight is 401 g
196
197 Check the response of this command and adjust the value to match the real value for thing.
198
199 (% border="1" cellspacing="3" style="background-color:#f2f2f2; width:517px" %)
200 |=(% style="width: 50px;background-color:#4F81BD;color:white" %)(((
201 **Size(bytes)**
202 )))|=(% style="width: 20px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 150px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 50px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 198px;background-color:#4F81BD;color:white" %)**1**|=(% style="width: 49px;background-color:#4F81BD;color:white" %)**4**
203 |Value|BAT|(% style="width:193px" %)(((
204 Temperature(DS18B20)(PC13)
205 )))|(% style="width:85px" %)(((
206 ADC(PA4)
207 )))|(% style="width:186px" %)(((
208 Digital in(PB15) & Digital Interrupt(PA8)
209 )))|(% style="width:100px" %)Weight
210
211 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20LoRaWAN%20End%20Nodes/LSN50%20%26%20LSN50-V2%20-%20LoRaWAN%20Sensor%20Node%20User%20Manual/WebHome/image-20220820120036-2.png?width=1003&height=469&rev=1.1||alt="image-20220820120036-2.png" height="469" width="1003"]]
212
213 ==== 2.3.2.6  MOD~=6 (Counting Mode) ====
214
215 In this mode, the device will work in counting mode. It counts the interrupt on the interrupt pins and sends the count on TDC time.
216
217 Connection is as below. The PIR sensor is a count sensor, it will generate interrupt when people come close or go away. User can replace the PIR sensor with other counting sensors.
218
219 [[image:image-20230512181814-9.png||height="543" width="697"]]
220
221 (% style="color:red" %)**Note:** **LoRaWAN wireless transmission will infect the PIR sensor. Which cause the counting value increase +1 for every uplink. User can change PIR sensor or put sensor away of the SN50_v3 to avoid this happen.**
222
223 (% border="1" cellspacing="3" style="background-color:#f2f2f2; width:517px" %)
224 |=(% style="width: 60px;background-color:#4F81BD;color:white" %)**Size(bytes)**|=(% style="width: 40px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 180px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 60px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 100px;background-color:#4F81BD;color:white" %)**1**|=(% style="width: 77px;background-color:#4F81BD;color:white" %)**4**
225 |Value|BAT|(% style="width:256px" %)(((
226 Temperature(DS18B20)(PC13)
227 )))|(% style="width:108px" %)(((
228 ADC(PA4)
229 )))|(% style="width:126px" %)(((
230 Digital in(PB15)
231 )))|(% style="width:145px" %)(((
232 Count(PA8)
233 )))
234
235 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20LoRaWAN%20End%20Nodes/LSN50%20%26%20LSN50-V2%20-%20LoRaWAN%20Sensor%20Node%20User%20Manual/WebHome/1656378441509-171.png?rev=1.1||alt="1656378441509-171.png"]]
236
237 ==== 2.3.2.7  MOD~=7 (Three interrupt contact modes) ====
238
239 (% border="1" cellspacing="3" style="background-color:#f2f2f2; width:517px" %)
240 |=(% style="width: 50px;background-color:#4F81BD;color:white" %)(((
241 **Size(bytes)**
242 )))|=(% style="width: 20px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 90px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 50px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 89px;background-color:#4F81BD;color:white" %)**1**|=(% style="width: 89px;background-color:#4F81BD;color:white" %)**1**|=(% style="width: 89px;background-color:#4F81BD;color:white" %)1|=(% style="width: 40px;background-color:#4F81BD;color:white" %)2
243 |Value|BAT|(% style="width:188px" %)(((
244 Temperature(DS18B20)
245 (PC13)
246 )))|(% style="width:83px" %)(((
247 ADC(PA5)
248 )))|(% style="width:184px" %)(((
249 Digital Interrupt1(PA8)
250 )))|(% style="width:186px" %)Digital Interrupt2(PA4)|(% style="width:197px" %)Digital Interrupt3(PB15)|(% style="width:100px" %)Reserved
251
252 [[image:image-20230513111203-7.png||height="324" width="975"]]
253
254 ==== 2.3.2.8  MOD~=8 (3ADC+1DS18B20) ====
255
256 (% border="1" cellspacing="3" style="background-color:#f2f2f2; width:517px" %)
257 |=(% style="width: 50px;background-color:#4F81BD;color:white" %)(((
258 **Size(bytes)**
259 )))|=(% style="width: 30px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 110px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 70px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 119px;background-color:#4F81BD;color:white" %)**1**|=(% style="width: 69px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 69px;background-color:#4F81BD;color:white" %)2
260 |Value|BAT|(% style="width:207px" %)(((
261 Temperature(DS18B20)
262 (PC13)
263 )))|(% style="width:94px" %)(((
264 ADC1(PA4)
265 )))|(% style="width:198px" %)(((
266 Digital Interrupt(PB15)
267 )))|(% style="width:84px" %)(((
268 ADC2(PA5)
269 )))|(% style="width:82px" %)(((
270 ADC3(PA8)
271 )))
272
273 [[image:image-20230513111231-8.png||height="335" width="900"]]
274
275 ==== 2.3.2.9  MOD~=9 (3DS18B20+ two Interrupt count mode) ====
276
277 (% border="1" cellspacing="3" style="background-color:#f2f2f2; width:517px" %)
278 |=(% style="width: 50px;background-color:#4F81BD;color:white" %)(((
279 **Size(bytes)**
280 )))|=(% style="width: 20px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 90px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 90px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 60px;background-color:#4F81BD;color:white" %)**1**|=(% style="width: 89px;background-color:#4F81BD;color:white" %)**2**|=(% style="width: 59px;background-color:#4F81BD;color:white" %)4|=(% style="width: 59px;background-color:#4F81BD;color:white" %)4
281 |Value|BAT|(((
282 Temperature
283 (DS18B20)(PC13)
284 )))|(((
285 Temperature2
286 (DS18B20)(PB9)
287 )))|(((
288 Digital Interrupt
289 (PB15)
290 )))|(% style="width:193px" %)(((
291 Temperature3
292 (DS18B20)(PB8)
293 )))|(% style="width:78px" %)(((
294 Count1(PA8)
295 )))|(% style="width:78px" %)(((
296 Count2(PA4)
297 )))
298
299 [[image:image-20230513111255-9.png||height="341" width="899"]]
300
301 (% style="color:blue" %)**The newly added AT command is issued correspondingly:**
302
303 (% style="color:#037691" %)** AT+INTMOD1 PA8**(%%)  pin:  Corresponding downlink:  (% style="color:#037691" %)**06 00 00 xx**
304
305 (% style="color:#037691" %)** AT+INTMOD2 PA4**(%%)  pin:  Corresponding downlink: (% style="color:#037691" %)**06 00 01 xx**
306
307 (% style="color:#037691" %)** AT+INTMOD3 PB15**(%%)  pin:  Corresponding downlink:  (% style="color:#037691" %)** 06 00 02 xx**
308
309
310 (% style="color:blue" %)**AT+SETCNT=aa,bb** 
311
312 When AA is 1, set the count of PA8 pin to BB Corresponding downlink:09 01 bb bb bb bb
313
314 When AA is 2, set the count of PA4 pin to BB Corresponding downlink:09 02 bb bb bb bb
315
316
317 ==== 2.3.2.10  MOD~=10 (PWM input capture and output mode,Since firmware v1.2) ====
318
319 (% style="color:red" %)**Note: Firmware not release, contact Dragino for testing.**
320
321 In this mode, the uplink can perform PWM input capture, and the downlink can perform PWM output.
322
323 [[It should be noted when using PWM mode.>>||anchor="H2.3.3.12A0PWMMOD"]]
324
325
326 ===== 2.3.2.10.a  Uplink, PWM input capture =====
327
328 [[image:image-20230817172209-2.png||height="439" width="683"]]
329
330 (% border="1" cellspacing="3" style="background-color:#f2f2f2; width:515px" %)
331 |(% style="background-color:#4f81bd; color:white; width:50px" %)**Size(bytes)**|(% style="background-color:#4f81bd; color:white; width:20px" %)**2**|(% style="background-color:#4f81bd; color:white; width:100px" %)**2**|(% style="background-color:#4f81bd; color:white; width:50px" %)**2**|(% style="background-color:#4f81bd; color:white; width:135px" %)**1**|(% style="background-color:#4f81bd; color:white; width:70px" %)**2**|(% style="background-color:#4f81bd; color:white; width:90px" %)**2**
332 |Value|Bat|(% style="width:191px" %)(((
333 Temperature(DS18B20)(PC13)
334 )))|(% style="width:78px" %)(((
335 ADC(PA4)
336 )))|(% style="width:135px" %)(((
337 PWM_Setting
338 &Digital Interrupt(PA8)
339 )))|(% style="width:70px" %)(((
340 Pulse period
341 )))|(% style="width:89px" %)(((
342 Duration of high level
343 )))
344
345 [[image:image-20230817170702-1.png||height="161" width="1044"]]
346
347 When the device detects the following PWM signal ,decoder will converts the pulse period and high-level duration to frequency and duty cycle.
348
349 **Frequency:**
350
351 (% class="MsoNormal" %)
352 (% lang="EN-US" %)If (% style="background-attachment:initial; background-clip:initial; background-image:initial; background-origin:initial; background-position:initial; background-repeat:initial; background-size:initial; color:blue; font-family:Arial,sans-serif" %)**AT+PWMSET**(%%)**=0, **(% lang="EN-US" %)Frequency= 1000000/(%%)Pulse period(HZ);
353
354 (% class="MsoNormal" %)
355 (% lang="EN-US" %)If (% style="background-attachment:initial; background-clip:initial; background-image:initial; background-origin:initial; background-position:initial; background-repeat:initial; background-size:initial; color:blue; font-family:Arial,sans-serif" %)**AT+PWMSET**(%%)**=1, **(% lang="EN-US" %)Frequency= 1000/(%%)Pulse period(HZ);
356
357
358 (% class="MsoNormal" %)
359 **Duty cycle:**
360
361 Duty cycle= Duration of high level/ Pulse period*100 ~(%).
362
363 [[image:image-20230818092200-1.png||height="344" width="627"]]
364
365 ===== 2.3.2.10.b  Uplink, PWM output =====
366
367 [[image:image-20230817172209-2.png||height="439" width="683"]]
368
369 (% style="background-attachment:initial; background-clip:initial; background-image:initial; background-origin:initial; background-position:initial; background-repeat:initial; background-size:initial; color:blue; font-family:Arial,sans-serif" %)**AT+PWMOUT=a,b,c**
370
371 a is the time delay of the output, the unit is ms.
372
373 b is the output frequency, the unit is HZ.
374
375 c is the duty cycle of the output, the unit is %.
376
377 (% style="background-attachment:initial; background-clip:initial; background-image:initial; background-origin:initial; background-position:initial; background-repeat:initial; background-size:initial; color:blue; font-family:Arial,sans-serif" %)**Downlink**(%%):  (% style="color:#037691" %)**0B 01 bb cc aa **
378
379 aa is the time delay of the output, the unit is ms.
380
381 bb is the output frequency, the unit is HZ.
382
383 cc is the duty cycle of the output, the unit is %.
384
385
386 For example, send a AT command: AT+PWMOUT=65535,1000,50  The PWM is always out, the frequency is 1000HZ, and the duty cycle is 50.
387
388 The oscilloscope displays as follows:
389
390
391 [[image:image-20231213102404-1.jpeg||height="688" width="821"]]
392
393 ===== 2.3.2.10.c  Downlink, PWM output =====
394
395 [[image:image-20230817173800-3.png||height="412" width="685"]]
396
397 Downlink:  (% style="color:#037691" %)**0B xx xx xx yy zz zz**
398
399 xx xx xx is the output frequency, the unit is HZ.
400
401 yy is the duty cycle of the output, the unit is %.
402
403 zz zz is the time delay of the output, the unit is ms.
404
405
406 For example, send a downlink command: 0B 00 61 A8 32 13 88, the frequency is 25KHZ, the duty cycle is 50, and the output time is 5 seconds.
407
408 The oscilloscope displays as follows:
409
410 [[image:image-20230817173858-5.png||height="634" width="843"]]
411
412 ==== 2.3.2.11  MOD~=11 (TEMP117) ====
413
414 In this mode, uplink payload includes in total 11 bytes. Uplink packets use FPORT=2.
415
416 (% border="1" cellspacing="3" style="background-color:#f2f2f2; width:517px" %)
417 |(% style="background-color:#4f81bd; color:white; width:50px" %)**Size(bytes)**|(% style="background-color:#4f81bd; color:white; width:20px" %)**2**|(% style="background-color:#4f81bd; color:white; width:100px" %)**2**|(% style="background-color:#4f81bd; color:white; width:50px" %)**2**|(% style="background-color:#4f81bd; color:white; width:90px" %)**1**|(% style="background-color:#4f81bd; color:white; width:128px" %)**2**|(% style="background-color:#4f81bd; color:white; width:79px" %)**2**
418 |Value|Bat|(% style="width:191px" %)(((
419 Temperature(DS18B20)(PC13)
420 )))|(% style="width:78px" %)(((
421 ADC(PA4)
422 )))|(% style="width:216px" %)(((
423 Digital in(PB15)&Digital Interrupt(PA8)
424 )))|(% style="width:308px" %)(((
425 Temperature
426
427 (TEMP117)
428 )))|(% style="width:154px" %)(((
429 Reserved position, meaningless
430
431 (0x0000)
432 )))
433
434 [[image:image-20240717113113-1.png||height="352" width="793"]]
435
436 Connection:
437
438 [[image:image-20240717141528-2.jpeg||height="430" width="654"]]
439
440 ==== 2.3.2.12  MOD~=12 (Count+SHT31) ====
441
442 This mode has total 11 bytes. As shown below:
443
444 (% border="1" cellspacing="3" style="background-color:#f2f2f2; width:517px" %)
445 |=(% style="width: 86px; background-color: rgb(79, 129, 189); color: white;" %)**Size(bytes)**|=(% style="width: 86px; background-color: rgb(79, 129, 189); color: white;" %)**2**|=(% style="width: 86px; background-color: rgb(79, 129, 189); color: white;" %)**2**|=(% style="width: 86px; background-color: rgb(79, 129, 189); color: white;" %)**2**|=(% style="width: 86px; background-color: rgb(79, 129, 189); color: white;" %)**1**|=(% style="width: 86px; background-color: rgb(79, 129, 189); color: white;" %)**4**
446 |Value|BAT|(% style="width:86px" %)(((
447 Temperature_SHT31
448 )))|(% style="width:86px" %)(((
449 Humidity_SHT31
450 )))|(% style="width:86px" %)(((
451 Digital in(PB15)
452 )))|(% style="width:86px" %)(((
453 Count(PA8)
454 )))
455
456 [[image:image-20240717150948-5.png||height="389" width="979"]]
457
458 Wiring example:
459
460 [[image:image-20240717152224-6.jpeg||height="359" width="680"]]
461
462 === 2.3.3  ​Decode payload ===
463
464 While using TTN V3 network, you can add the payload format to decode the payload.
465
466 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20LoRaWAN%20End%20Nodes/LSN50%20%26%20LSN50-V2%20-%20LoRaWAN%20Sensor%20Node%20User%20Manual/WebHome/1656378466788-734.png?rev=1.1||alt="1656378466788-734.png"]]
467
468 The payload decoder function for TTN V3 are here:
469
470 The payload decoder function for TTN V3 are here:
471
472 SN50v3-LB/LS TTN V3 Payload Decoder:  [[https:~~/~~/github.com/dragino/dragino-end-node-decoder>>url:https://github.com/dragino/dragino-end-node-decoder]]
473
474
475 ==== 2.3.3.1 Battery Info ====
476
477 Check the battery voltage for SN50v3-LB/LS.
478
479 Ex1: 0x0B45 = 2885mV
480
481 Ex2: 0x0B49 = 2889mV
482
483
484 ==== 2.3.3.2  Temperature (DS18B20) ====
485
486
487 If there is a DS18B20 connected to PC13 pin. The temperature will be uploaded in the payload.
488
489 More DS18B20 can check the [[3 DS18B20 mode>>||anchor="H2.3.2.4MOD3D4283xDS18B2029"]]
490
491 (% style="color:blue" %)**Connection:**
492
493 [[image:image-20230512180718-8.png||height="538" width="647"]]
494
495 (% style="color:blue" %)**Example**:
496
497 If payload is: 0105H:  (0105 & 8000 == 0), temp = 0105H /10 = 26.1 degree
498
499 If payload is: FF3FH :  (FF3F & 8000 == 1) , temp = (FF3FH - 65536)/10 = -19.3 degrees.
500
501 (FF3F & 8000:Judge whether the highest bit is 1, when the highest bit is 1, it is negative)
502
503
504 ==== 2.3.3.3 Digital Input ====
505
506
507 The digital input for pin PB15,
508
509 * When PB15 is high, the bit 1 of payload byte 6 is 1.
510 * When PB15 is low, the bit 1 of payload byte 6 is 0.
511
512 (% class="wikigeneratedid" id="H2.3.3.4A0AnalogueDigitalConverter28ADC29" %)
513 (((
514 When the digital interrupt pin is set to AT+INTMODx=0, this pin is used as a digital input pin.
515
516 (% style="color:red" %)**Note: The maximum voltage input supports 3.6V.**
517
518
519 )))
520
521 ==== 2.3.3.4  Analogue Digital Converter (ADC) ====
522
523
524 The measuring range of the ADC is only about 0.1V to 1.1V The voltage resolution is about 0.24mv.
525
526 When the measured output voltage of the sensor is not within the range of 0.1V and 1.1V, the output voltage terminal of the sensor shall be divided The example in the following figure is to reduce the output voltage of the sensor by three times If it is necessary to reduce more times, calculate according to the formula in the figure and connect the corresponding resistance in series.
527
528 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20LoRaWAN%20End%20Nodes/LHT65N%20LoRaWAN%20Temperature%20%26%20Humidity%20Sensor%20Manual/WebHome/image-20220628150112-1.png?width=285&height=241&rev=1.1||alt="image-20220628150112-1.png" height="241" width="285"]]
529
530 (% style="color:red" %)**Note: If the ADC type sensor needs to be powered by SN50_v3, it is recommended to use +5V to control its switch.Only sensors with low power consumption can be powered with VDD.**
531
532
533 The position of PA5 on the hardware after **LSN50 v3.3** is changed to the position shown in the figure below, and the collected voltage becomes one-sixth of the original.
534
535
536 [[image:image-20230811113449-1.png||height="370" width="608"]]
537
538 ==== 2.3.3.5 Digital Interrupt ====
539
540 Digital Interrupt refers to pin PA8, and there are different trigger methods. When there is a trigger, the SN50v3-LB/LS will send a packet to the server.
541
542 (% style="color:blue" %)** Interrupt connection method:**
543
544 [[image:image-20230513105351-5.png||height="147" width="485"]]
545
546 (% style="color:blue" %)**Example to use with door sensor :**
547
548 The door sensor is shown at right. It is a two wire magnetic contact switch used for detecting the open/close status of doors or windows.
549
550 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20LoRaWAN%20End%20Nodes/LSN50%20%26%20LSN50-V2%20-%20LoRaWAN%20Sensor%20Node%20User%20Manual/WebHome/1656379210849-860.png?rev=1.1||alt="1656379210849-860.png"]]
551
552 When the two pieces are close to each other, the 2 wire output will be short or open (depending on the type), while if the two pieces are away from each other, the 2 wire output will be the opposite status. So we can use SN50v3-LB/LS interrupt interface to detect the status for the door or window.
553
554
555 (% style="color:blue" %)**Below is the installation example:**
556
557 Fix one piece of the magnetic sensor to the door and connect the two pins to SN50v3-LB/LS as follows:
558
559 * (((
560 One pin to SN50v3-LB/LS's PA8 pin
561 )))
562 * (((
563 The other pin to SN50v3-LB/LS's VDD pin
564 )))
565
566 Install the other piece to the door. Find a place where the two pieces will be close to each other when the door is closed. For this particular magnetic sensor, when the door is closed, the output will be short, and PA8 will be at the VCC voltage.
567
568 Door sensors have two types: (% style="color:blue" %)** NC (Normal close)**(%%) and (% style="color:blue" %)**NO (normal open)**(%%). The connection for both type sensors are the same. But the decoding for payload are reverse, user need to modify this in the IoT Server decoder.
569
570 When door sensor is shorted, there will extra power consumption in the circuit, the extra current is 3v3/R14 = 3v3/1Mohm = 3uA which can be ignored.
571
572 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20LoRaWAN%20End%20Nodes/LSN50%20%26%20LSN50-V2%20-%20LoRaWAN%20Sensor%20Node%20User%20Manual/WebHome/1656379283019-229.png?rev=1.1||alt="1656379283019-229.png"]]
573
574 The above photos shows the two parts of the magnetic switch fitted to a door.
575
576 The software by default uses the falling edge on the signal line as an interrupt. We need to modify it to accept both the rising edge (0v ~-~-> VCC , door close) and the falling edge (VCC ~-~-> 0v , door open) as the interrupt.
577
578 The command is:
579
580 (% style="color:blue" %)**AT+INTMOD1=1   ** (%%) ~/~/  (more info about INMOD please refer** **[[**AT Command Manual**>>url:http://www.dragino.com/downloads/index.php?dir=LSN50-LoRaST/&file=DRAGINO_LSN50_AT_Commands_v1.5.1.pdf]]**. **)
581
582 Below shows some screen captures in TTN V3:
583
584 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20LoRaWAN%20End%20Nodes/LSN50%20%26%20LSN50-V2%20-%20LoRaWAN%20Sensor%20Node%20User%20Manual/WebHome/1656379339508-835.png?rev=1.1||alt="1656379339508-835.png"]]
585
586 In **MOD=1**, user can use byte 6 to see the status for door open or close. TTN V3 decoder is as below:
587
588 door= (bytes[6] & 0x80)? "CLOSE":"OPEN";
589
590
591 ==== 2.3.3.6 I2C Interface (SHT20 & SHT31) ====
592
593
594 The SDA and SCK are I2C interface lines. You can use these to connect to an I2C device and get the sensor data.
595
596 We have made an example to show how to use the I2C interface to connect to the SHT20/ SHT31 Temperature and Humidity Sensor.
597
598 (% style="color:red" %)**Notice: Different I2C sensors have different I2C commands set and initiate process, if user want to use other I2C sensors, User need to re-write the source code to support those sensors. SHT20/ SHT31 code in SN50v3-LB/LS will be a good reference.**
599
600
601 Below is the connection to SHT20/ SHT31. The connection is as below:
602
603 [[image:image-20230610170152-2.png||height="501" width="846"]]
604
605 The device will be able to get the I2C sensor data now and upload to IoT Server.
606
607 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20LoRaWAN%20End%20Nodes/LSN50%20%26%20LSN50-V2%20-%20LoRaWAN%20Sensor%20Node%20User%20Manual/WebHome/1656379664142-345.png?rev=1.1||alt="1656379664142-345.png"]]
608
609 Convert the read byte to decimal and divide it by ten.
610
611 **Example:**
612
613 Temperature:  Read:0116(H) = 278(D)  Value:  278 /10=27.8℃;
614
615 Humidity:    Read:0248(H)=584(D)  Value:  584 / 10=58.4, So 58.4%
616
617 If you want to use other I2C device, please refer the SHT20 part source code as reference.
618
619
620 ==== 2.3.3.7  ​Distance Reading ====
621
622
623 Refer [[Ultrasonic Sensor section>>||anchor="H2.3.3.8UltrasonicSensor"]].
624
625
626 ==== 2.3.3.8 Ultrasonic Sensor ====
627
628
629 This Fundamental Principles of this sensor can be found at this link: [[https:~~/~~/wiki.dfrobot.com/Weather_-_proof_Ultrasonic_Sensor_with_Separate_Probe_SKU~~_~~__SEN0208>>url:https://wiki.dfrobot.com/Weather_-_proof_Ultrasonic_Sensor_with_Separate_Probe_SKU___SEN0208]]
630
631 The SN50v3-LB/LS detects the pulse width of the sensor and converts it to mm output. The accuracy will be within 1 centimeter. The usable range (the distance between the ultrasonic probe and the measured object) is between 24cm and 600cm.
632
633 The working principle of this sensor is similar to the (% style="color:blue" %)**HC-SR04**(%%) ultrasonic sensor.
634
635 The picture below shows the connection:
636
637 [[image:image-20230512173903-6.png||height="596" width="715"]]
638
639 Connect to the SN50v3-LB/LS and run (% style="color:blue" %)**AT+MOD=2**(%%) to switch to ultrasonic mode (ULT).
640
641 The ultrasonic sensor uses the 8^^th^^ and 9^^th^^ byte for the measurement value.
642
643 **Example:**
644
645 Distance:  Read: 0C2D(Hex) = 3117(D)  Value:  3117 mm=311.7 cm
646
647
648 ==== 2.3.3.9  Battery Output - BAT pin ====
649
650
651 The BAT pin of SN50v3-LB/LS is connected to the Battery directly. If users want to use BAT pin to power an external sensor. User need to make sure the external sensor is of low power consumption. Because the BAT pin is always open. If the external sensor is of high power consumption. the battery of SN50v3-LB/LS will run out very soon.
652
653
654 ==== 2.3.3.10  +5V Output ====
655
656
657 SN50v3-LB/LS will enable +5V output before all sampling and disable the +5v after all sampling. 
658
659 The 5V output time can be controlled by AT Command.
660
661 (% style="color:blue" %)**AT+5VT=1000**
662
663 Means set 5V valid time to have 1000ms. So the real 5V output will actually have 1000ms + sampling time for other sensors.
664
665 By default the **AT+5VT=500**. If the external sensor which require 5v and require more time to get stable state, user can use this command to increase the power ON duration for this sensor.
666
667
668 ==== 2.3.3.11  BH1750 Illumination Sensor ====
669
670
671 MOD=1 support this sensor. The sensor value is in the 8^^th^^ and 9^^th^^ bytes.
672 [[image:image-20230512172447-4.png||height="416" width="712"]]
673
674 [[image:http://wiki.dragino.com/xwiki/bin/download/Main/User%20Manual%20for%20LoRaWAN%20End%20Nodes/LSN50%20%26%20LSN50-V2%20-%20LoRaWAN%20Sensor%20Node%20User%20Manual/WebHome/image-20220628110012-12.png?rev=1.1||alt="image-20220628110012-12.png" height="361" width="953"]]
675
676 ==== 2.3.3.12  PWM MOD ====
677
678 * (((
679 The maximum voltage that the SDA pin of SN50v3 can withstand is 3.6V, and it cannot exceed this voltage value, otherwise the chip may be burned.
680 )))
681 * (((
682 If the PWM pin connected to the SDA pin cannot maintain a high level when it is not working, you need to remove the resistor R2 or replace it with a resistor with a larger resistance, otherwise a sleep current of about 360uA will be generated. The position of the resistor is shown in the figure below:
683 )))
684
685 [[image:image-20230817183249-3.png||height="320" width="417"]]
686
687 * (((
688 The signal captured by the input should preferably be processed by hardware filtering and then connected in. The software processing method is to capture four values, discard the first captured value, and then take the middle value of the second, third, and fourth captured values.
689 )))
690 * (((
691 Since the device can only detect a pulse period of 50ms when [[AT+PWMSET=0>>||anchor="H3.3.8PWMsetting"]] (counting in microseconds), it is necessary to change the value of PWMSET according to the frequency of input capture.
692 )))
693 * (((
694 PWM Input allows low power consumption. PWM Output to achieve real-time control, you need to go to class C. Power consumption will not be low.
695
696 For PWM Output Feature, there are two consideration to see if the device can be powered by battery or have to be powered by external DC.
697
698 a) If real-time control output is required, the SN50v3-LB/LS is already operating in class C and an external power supply must be used.
699
700 b) If the output duration is more than 30 seconds, better to use external power source. 
701 )))
702
703 ==== 2.3.3.13  Working MOD ====
704
705
706 The working MOD info is contained in the Digital in & Digital Interrupt byte (7^^th^^ Byte).
707
708 User can use the 3^^rd^^ ~~ 7^^th^^  bit of this byte to see the working mod:
709
710 Case 7^^th^^ Byte >> 2 & 0x1f:
711
712 * 0: MOD1
713 * 1: MOD2
714 * 2: MOD3
715 * 3: MOD4
716 * 4: MOD5
717 * 5: MOD6
718 * 6: MOD7
719 * 7: MOD8
720 * 8: MOD9
721 * 9: MOD10
722
723
724
725 == 3.PS-LB-NA connects to third-party sensors ==
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746