Wiki source code of Point to Point Communication for RS485-LN
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | = **1. point to point** = | ||
2 | |||
3 | == **1.1 Overview** == | ||
4 | |||
5 | ((( | ||
6 | [[image:1656901825798-483.png]] | ||
7 | |||
8 | |||
9 | == **1.2 Configure** == | ||
10 | |||
11 | |||
12 | (% style="color:blue" %)**A's configuration: ** **B's configuration:** | ||
13 | |||
14 | AT+GROUPMOD=0 AT+GROUPMOD=0 | ||
15 | |||
16 | AT+GROUPID=12345678 AT+GROUPID=12345678 | ||
17 | |||
18 | AT+TXCHS=868700000 AT+TXCHS=869000000 | ||
19 | |||
20 | AT+RXCHS=869000000 AT+RXCHS=868700000 | ||
21 | |||
22 | AT+CFGDEV=01 03 00 00 00 04,1 AT+CFGDEV=01 03 00 00 00 02,1 | ||
23 | |||
24 | or or | ||
25 | |||
26 | AT+COMMAND=01 03 00 00 00 04,1 AT+COMMAND=01 03 00 00 00 02,1 | ||
27 | ))) | ||
28 | |||
29 | |||
30 | |||
31 | == **1.3 Serial port display** == | ||
32 | |||
33 | |||
34 | [[image:image-20220704103422-2.png||height="430" width="817"]] | ||
35 | |||
36 | A sends a command to B to query B's RS485 sensor data and display it on A's upper computer. | ||
37 | |||
38 | Similarly, B sends a command to A to query A's RS485 sensor data and display it on B's upper computer. | ||
39 | |||
40 | |||
41 | [[image:image-20220704103502-3.png]] | ||
42 | |||
43 | If the sender does not get the ACK reply from the receiver, it will retransmit up to 4 times, each interval is 10 seconds, and the UplinkCounter of the retransmission will not increase. (Retransmission only occurs when using the AT+CFGDEV command or triggering an external interrupt) | ||
44 | |||
45 | |||
46 | |||
47 | == **2.2 Point To Mult-Point ** == | ||
48 | |||
49 | === **2.2.1 Overview** === | ||
50 | |||
51 | |||
52 | [[image:1656901541427-229.png]] | ||
53 | |||
54 | |||
55 | === **2.2.2 Configure** === | ||
56 | |||
57 | |||
58 | (% style="color:blue" %)**Configuration of the TX group:** | ||
59 | |||
60 | AT+GROUPMOD=0,2 | ||
61 | |||
62 | AT+GROUPID=12345678 | ||
63 | |||
64 | AT+TXCHS=868700000 | ||
65 | |||
66 | AT+RXCHS=869000000 | ||
67 | |||
68 | AT+CFGDEV=01 03 00 00 00 02,1 | ||
69 | |||
70 | or | ||
71 | |||
72 | AT+COMMAND=01 03 00 00 00 02,1 | ||
73 | |||
74 | |||
75 | (% style="color:blue" %)**Configuration for RX group number 1:** | ||
76 | |||
77 | AT+GROUPMOD=1,1 | ||
78 | |||
79 | AT+GROUPID=12345678 | ||
80 | |||
81 | AT+TXCHS=869000000 | ||
82 | |||
83 | AT+RXCHS=868700000 | ||
84 | |||
85 | |||
86 | (% style="color:blue" %)**Configuration for RX group number 2:** | ||
87 | |||
88 | AT+GROUPMOD=1,2 | ||
89 | |||
90 | AT+GROUPID=12345678 | ||
91 | |||
92 | AT+TXCHS=869000000 | ||
93 | |||
94 | AT+RXCHS=868700000 | ||
95 | |||
96 | |||
97 | |||
98 | === **2.2.3 Serial port display** === | ||
99 | |||
100 | (% id="cke_bm_79849S" style="display:none" %) [[image:1656901280202-290.png]] | ||
101 | |||
102 | |||
103 | [[image:image-20220704103658-4.png||height="495" width="852"]] | ||
104 | |||
105 | The TX group sends broadcast data to the RX group. After the RX group receives the data, it will reply to the TX group in order from small to large.(% style="display:none" %) | ||
106 | |||
107 | (% style="display:none" %) (%%) | ||
108 | |||
109 | |||
110 | [[image:image-20220704103658-5.png]] | ||
111 | |||
112 | If the sender does not get the ACK reply from the receiver, it will retransmit up to 4 times, each interval is 30 seconds, and the UplinkCounter of the retransmission will not increase.(Retransmission only occurs when using the AT+CFGDEV command or triggering an external interrupt) | ||
113 | |||
114 | (% style="display:none" %) (%%) | ||
115 | |||
116 | (% style="display:none" %) (%%) | ||
117 | |||
118 | == **2.3 AT command** == | ||
119 | |||
120 | (% style="display:none" %) (%%) | ||
121 | |||
122 | ATZ :Trig a reset of the MCU | ||
123 | |||
124 | AT+FDR :Reset Parameters to Factory Default, Keys Reserve | ||
125 | |||
126 | AT+FCU :Get or Set the Frame (% style="display:none" %) (%%)Counter Uplink | ||
127 | |||
128 | AT+FCD :Get or Set the Frame (% style="display:none" %) (%%)Counter Downlink | ||
129 | |||
130 | AT+TXP :Get or Set the transmit power, the maximum is 20dBm (default is 14dBm) | ||
131 | |||
132 | AT+SYNC :Get or Set the Sync (% style="display:none" %) (%%)word [1:0x34,0:0x12] (default is 1) | ||
133 | |||
134 | AT+PMB :Get or Set the preamble (default:8) | ||
135 | |||
136 | AT+TXCHS :Get or Set the transmit frequency of TX (default:868700000) | ||
137 | |||
138 | AT+TXSF :Get or Set the spreading factor of TX (7 to 12) (default:12) | ||
139 | |||
140 | AT+RXCHS :Get or Set the transmit frequency of RX (default:869000000) | ||
141 | |||
142 | AT+RXSF :Get or Set the spreading factor of RX (7 to 12) (default:12) | ||
143 | |||
144 | AT+BW :Get or Set the bandwidth [0:125khz,1:250khz,2:500khz] (default:0) | ||
145 | |||
146 | AT+CR :Get or Set the coding rate [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] (default:1) | ||
147 | |||
148 | AT+TDC :Get or set the application data transmission interval in ms(default 10 minutes) | ||
149 | |||
150 | AT+VER :get firmware version number | ||
151 | |||
152 | AT+SEND :Set Custom sent hex data | ||
153 | |||
154 | AT+GROUPMOD :Set or Get the grouping mode of the device (default: 0) | ||
155 | |||
156 | AT+GROUPID : (% style="display:none" %) (%%)Set or Get the password for matching between TX group and RX group, which can be composed of numbers or characters (default: 12345678)(% style="display:none" %) | ||
157 | |||
158 | |||
159 | ((( | ||
160 | (% style="color:#037691" %)**ATZ** (%%)**: ** Trig a reset of the MCU | ||
161 | ))) | ||
162 | |||
163 | ((( | ||
164 | (% style="color:#037691" %)**AT+FDR** (%%)**:** Reset Parameters to Factory Default, Keys Reserve | ||
165 | ))) | ||
166 | |||
167 | ((( | ||
168 | (% style="color:#037691" %)**AT+FCU** (%%)**:** Get or Set the Frame Co(% style="display:none" %) (%%)unter Uplink | ||
169 | ))) | ||
170 | |||
171 | ((( | ||
172 | (% style="color:#037691" %)**AT+FCD** (%%)**:** Get or Set the Frame Counter Downlink | ||
173 | ))) | ||
174 | |||
175 | ((( | ||
176 | (% style="color:#037691" %)**AT+TXP** (%%)**:** Get or Set the transmit power, the maximum is 20dBm (default is 14dBm) | ||
177 | ))) | ||
178 | |||
179 | ((( | ||
180 | (% style="color:#037691" %)**AT+SYNC** (%%)**:** Get or Set the Sync word [1:0x34,0:0x12] (default is 1) | ||
181 | ))) | ||
182 | |||
183 | ((( | ||
184 | (% style="color:#037691" %)**AT+PMB** (%%)**: **Get or Set the preamble (default:8) | ||
185 | ))) | ||
186 | |||
187 | ((( | ||
188 | (% style="color:#037691" %)**AT+TXCHS **(%%)**:** Get or Set the transmit frequency of TX (default:868700000) | ||
189 | ))) | ||
190 | |||
191 | ((( | ||
192 | (% style="color:#037691" %)**AT+TXSF **(%%)**:** Get or Set the spreading factor of TX (7 to 12) (default:12) | ||
193 | ))) | ||
194 | |||
195 | ((( | ||
196 | (% style="color:#037691" %)**AT+RXCHS **(%%)**:** Get or Set the transmit frequency of RX (default:869000000) | ||
197 | ))) | ||
198 | |||
199 | ((( | ||
200 | (% style="color:#037691" %)**AT+RXSF **(%%)**:** Get or Set the spreading factor of RX (7 to 12) (default:12) | ||
201 | ))) | ||
202 | |||
203 | ((( | ||
204 | (% style="color:#037691" %)**AT+BW **(%%)**: **Get or Set the bandwidth [0:125khz,1:250khz,2:500khz] (default:0) | ||
205 | ))) | ||
206 | |||
207 | ((( | ||
208 | (% style="color:#037691" %)**AT+CR **(%%)**: **Get or Set the coding rate [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] (default:1) | ||
209 | ))) | ||
210 | |||
211 | ((( | ||
212 | (% style="color:#037691" %)**AT+TDC **(%%)**:** Get or set the application data transmission interval in ms(default 10 minutes) | ||
213 | ))) | ||
214 | |||
215 | ((( | ||
216 | (% style="color:#037691" %)**AT+VER **(%%)**:** Get firmware version number | ||
217 | ))) | ||
218 | |||
219 | ((( | ||
220 | (% style="color:#037691" %)**AT+SEND **(%%)**: **Set Custom sent hex data | ||
221 | ))) | ||
222 | |||
223 | ((( | ||
224 | (% style="color:#037691" %)**AT+GROUPMOD **(%%)**: **Set or Get the grouping (% style="display:none" %) (%%)mode of the device (default: 0) | ||
225 | ))) | ||
226 | |||
227 | ((( | ||
228 | ((( | ||
229 | (% style="color:#037691" %)**AT+GROUPID **(%%)**: **Set or Get the password for (% style="display:none" %) (%%)matching between TX group and RX group, which can be composed of numbers or characters (default: 12345678)(% style="display:none" %) | ||
230 | |||
231 | (% style="color:#037691" %)**AT+INTMOD **(%%)**:** Get or Set the trigger interrupt mode | ||
232 | |||
233 | (% style="color:#037691" %)**AT+BAUDR **(%%)**:** Get or set the baud rate of rs485. (default: 9600) | ||
234 | |||
235 | (% style="color:#037691" %)**AT+DATABIT **(%%)**:** Get or Set databit(7:7 bits,8:8 bits) of rs485 (default: 8) | ||
236 | |||
237 | (% style="color:#037691" %)**AT+PARITY **(%%)**: **Get or Set parity(0:none,1:odd,2:even) of rs485(default: 0) | ||
238 | |||
239 | (% style="color:#037691" %)**AT+STOPBIT **(%%)**: **Get or Set stopbit(0:1 bit,1:1.5 bit,2:2 bit) of rs485(default: 0) | ||
240 | |||
241 | (% style="color:#037691" %)**AT+CMDDL **(%%)**:** Get or Set the delay waiting time after receiving RS485 command (default: 400) | ||
242 | |||
243 | (% style="color:#037691" %)**AT+CRCCHECK **(%%)**:** Get or set to receive and verify RS485 sensor data (0: Disable,1:CRC16_MODBUS) (default: 1) | ||
244 | |||
245 | (% style="color:#037691" %)**AT+SCHEDULE **(%%)**:** Each TDC sends command data to the receiver. | ||
246 | |||
247 | (% style="color:#037691" %)**AT+CFGDEV **(%%)**:** Instantly send RS485 commands to the receiver. | ||
248 | |||
249 | (% style="color:#037691" %)**AT+RS485 **(%%)**: **Send commands to the local RS485 device. | ||
250 | |||
251 | (% style="color:#037691" %)**AT+MOD **(%%)**:** Get or set the host send mode.(default: 0) | ||
252 | ))) | ||
253 | ))) | ||
254 | |||
255 | ((( | ||
256 | |||
257 | ))) | ||
258 | |||
259 | ((( | ||
260 | |||
261 | ))) | ||
262 | |||
263 | ((( | ||
264 | |||
265 | ))) | ||
266 | |||
267 | ((( | ||
268 | |||
269 | ))) | ||
270 | |||
271 | ((( | ||
272 | (% style="color:#4f81bd" %)**Example 1:** | ||
273 | ))) | ||
274 | |||
275 | ((( | ||
276 | **AT+SEND=01020304 **will send a payload of 01020304 | ||
277 | ))) | ||
278 | |||
279 | ((( | ||
280 | |||
281 | ))) | ||
282 | |||
283 | ((( | ||
284 | (% style="color:#4f81bd" %)**Example 2: ** | ||
285 | |||
286 | **AT+INTMOD=aa** (0:Disable,1:falling or rising,2:falling,3:rising) (default: 2) | ||
287 | ))) | ||
288 | |||
289 | ((( | ||
290 | RS485-LN support external Interrupt uplink since hardware v1.2 release. | ||
291 | |||
292 | [[image:image-20220704104958-6.png]] | ||
293 | |||
294 | Connect the Interrupt pin to RS485-LN INT port and connect the GND pin to V- port. When there | ||
295 | |||
296 | is a high voltage (Max 24v) on INT pin. Device will send an lora packet. | ||
297 | ))) | ||
298 | |||
299 | ((( | ||
300 | |||
301 | ))) | ||
302 | |||
303 | ((( | ||
304 | (% style="color:#4f81bd" %)**Example 3: ** | ||
305 | |||
306 | |||
307 | **AT+SCHEDULE: **This command will be sent to Group RX during each transmission, Max command length is 14 bytes. The grammar is: | ||
308 | |||
309 | AT+SCHEDULE =xx xx xx xx xx xx xx xx xx xx xx xx,m | ||
310 | |||
311 | xx xx xx xx xx xx xx xx xx xx xx xx: The RS485 command to be sent | ||
312 | |||
313 | m: 0: no CRC, 1: add CRC-16/MODBUS in the end of this command | ||
314 | |||
315 | For example, if we have a RS485 sensor. The command to get sensor value is: 01 03 0B B8 00 02 | ||
316 | |||
317 | 46 0A. Where 01 03 0B B8 00 02 is the Modbus command to read the register 0B B8 where | ||
318 | |||
319 | stored the sensor value. The 46 0A is the CRC-16/MODBUS which calculate manually. | ||
320 | ))) | ||
321 | |||
322 | ((( | ||
323 | |||
324 | ))) | ||
325 | |||
326 | ((( | ||
327 | |||
328 | ))) | ||
329 | |||
330 | ((( | ||
331 | (% style="color:#4f81bd" %)**Example 4: ** | ||
332 | |||
333 | |||
334 | **AT+CFGDEV :** This command will be sent to Group RX. | ||
335 | |||
336 | The grammar is: | ||
337 | |||
338 | AT+CFGDEV =xx xx xx xx xx xx xx xx xx xx xx xx,m | ||
339 | |||
340 | xx xx xx xx xx xx xx xx xx xx xx xx: The RS485 command to be sent | ||
341 | |||
342 | m: 0: no CRC, 1: add CRC-16/MODBUS in the end of this command. | ||
343 | ))) | ||
344 | |||
345 | ((( | ||
346 | |||
347 | |||
348 | |||
349 | (% style="color:#4f81bd" %)**Example 5:**(%%)** ** | ||
350 | ))) | ||
351 | |||
352 | **AT+RS485:** This command will be sent to local RS485 device. | ||
353 | |||
354 | The grammar is: | ||
355 | |||
356 | AT+RS485 =xx xx xx xx xx xx xx xx xx xx xx xx,m | ||
357 | |||
358 | xx xx xx xx xx xx xx xx xx xx xx xx: The RS485 command to be sent | ||
359 | |||
360 | m: 0: no CRC, 1: add CRC-16/MODBUS in the end of this command. | ||
361 | |||
362 | |||
363 | |||
364 | (% style="color:#4f81bd" %)**Example 6:** | ||
365 | |||
366 | **AT+MOD=0** Commands are transparently transmitted through UART. | ||
367 | |||
368 | **AT+MOD=1,500** Commands are transparently transmitted through RS485. 500 ms after the first character is received from RS485, all characters are commands. | ||
369 | |||
370 | |||
371 | |||
372 | (% style="color:#4f81bd" %)**Example 7:** | ||
373 | |||
374 | **AT+GROUPMOD=0** Set to point to point mode | ||
375 | |||
376 | **AT+GROUPMOD=0,aa** Set the TX group that controls the number of aa (The maximum value of aa is 8) | ||
377 | |||
378 | **AT+GROUPMOD=1,bb** Set to the RX group controlled by the TX group, numbered bb(The maximum value of bb is 8) | ||
379 | |||
380 | |||
381 | **AT+GROUPMOD=0,2** Set to control the TX group of the two RX groups | ||
382 | |||
383 | **AT+GROUPMOD=1,1** Set the RX group numbered 1 | ||
384 | |||
385 | **AT+GROUPMOD=1,2** Set the RX group numbered 2 | ||
386 | |||
387 | |||
388 | |||
389 | (% style="color:#4f81bd" %)**Example 8:** | ||
390 | |||
391 | |||
392 | (% style="color:#4f81bd" %)**Example 9:** | ||
393 | |||
394 | |||
395 | |||
396 | == **2.4 Data Format** == | ||
397 | |||
398 | ((( | ||
399 | 8 bytes of GROUPID + 9 bytes of payload + 4 bytes of checksum | ||
400 | ))) | ||
401 | |||
402 | ((( | ||
403 | |||
404 | ))) | ||
405 | |||
406 | ((( | ||
407 | (% style="color:#4f81bd" %)**Payload:** | ||
408 | ))) | ||
409 | |||
410 | (% border="1" style="background-color:#f7faff; color:black; width:938px" %) | ||
411 | |=(% style="width: 123px;" %)((( | ||
412 | **Size (bytes)** | ||
413 | )))|=(% style="width: 107px;" %)((( | ||
414 | 1 | ||
415 | )))|=(% style="width: 107px;" %)((( | ||
416 | 1 | ||
417 | )))|=(% style="width: 107px;" %)((( | ||
418 | 1 | ||
419 | )))|=(% style="width: 107px;" %)((( | ||
420 | 1 | ||
421 | )))|=(% style="width: 107px;" %)((( | ||
422 | 1 | ||
423 | )))|=(% style="width: 107px;" %)((( | ||
424 | 1 | ||
425 | )))|=(% style="width: 107px;" %)((( | ||
426 | 1 | ||
427 | )))|=(% style="width: 107px;" %)((( | ||
428 | 1 | ||
429 | )))|=(% style="width: 107px;" %)((( | ||
430 | 1 | ||
431 | ))) | ||
432 | |(% style="width:123px" %)((( | ||
433 | **Value** | ||
434 | )))|(% style="width:38px" %)((( | ||
435 | address | ||
436 | )))|(% style="width:70px" %)((( | ||
437 | request | ||
438 | )))|(% style="width:52px" %)((( | ||
439 | ACK | ||
440 | )))|(% style="width:127px" %)((( | ||
441 | ((( | ||
442 | DI1& | ||
443 | ))) | ||
444 | |||
445 | ((( | ||
446 | DI1 level | ||
447 | ))) | ||
448 | )))|(% style="width:101px" %)((( | ||
449 | DI1TODO1 | ||
450 | )))|(% style="width:91px" %)((( | ||
451 | DI1TORO1 | ||
452 | )))|(% style="width:111px" %)((( | ||
453 | ((( | ||
454 | DI2& | ||
455 | ))) | ||
456 | |||
457 | ((( | ||
458 | DI2 level | ||
459 | ))) | ||
460 | )))|(% style="width:105px" %)((( | ||
461 | DI2TODO2 | ||
462 | )))|(% style="width:106px" %)((( | ||
463 | DI2TORO2 | ||
464 | ))) | ||
465 | |||
466 | ((( | ||
467 | (% style="color:#037691" %)**The first byte**(%%)**:** 00 is the broadcast address, 01-08 is the RX group number. | ||
468 | ))) | ||
469 | |||
470 | ((( | ||
471 | (% style="color:#037691" %)**The second byte**(%%)**:** send mapping request when not 0, not request when it is 0. | ||
472 | ))) | ||
473 | |||
474 | ((( | ||
475 | (% style="color:#037691" %)**The third byte**(%%)**:** ACK returned to the sender after the mapping is completed. | ||
476 | ))) | ||
477 | |||
478 | ((( | ||
479 | ((( | ||
480 | (% style="color:#037691" %)**The fourth byte**(%%)**:** the high four bits are 1 to represent DI1, and the low four bits are the level of DI1 when the interrupt is triggered. | ||
481 | ))) | ||
482 | ))) | ||
483 | |||
484 | ((( | ||
485 | (% style="color:#037691" %)**The Fifth byte**(%%)**: **DI1TODO1 when the interrupt is triggered, 0 when the interrupt is not triggered. | ||
486 | ))) | ||
487 | |||
488 | ((( | ||
489 | (% style="color:#037691" %)**The Sixth byte**(%%)**:** 0 does not trigger interrupt when DI1TORO1 interrupt is triggered. | ||
490 | ))) | ||
491 | |||
492 | ((( | ||
493 | ((( | ||
494 | (% style="color:#037691" %)**The seventh byte**(%%)**:** the high four bits are 2 to represent DI2, and the low four bits are the level of DI2 when the interrupt is triggered. | ||
495 | ))) | ||
496 | ))) | ||
497 | |||
498 | ((( | ||
499 | (% style="color:#037691" %)**The 8th byte**(%%)**: **DI2TODO2 when the interrupt is triggered, 0 when the interrupt is not triggered. | ||
500 | ))) | ||
501 | |||
502 | ((( | ||
503 | (% style="color:#037691" %)**The 9th byte**(%%)**:** DI2TORO2 when an interrupt is triggered, 0 when an interrupt is not triggered. | ||
504 | ))) |