Wiki source code of Point to Point Communication for RS485-LN
Last modified by Bei Jinggeng on 2024/04/30 15:42
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | **Table of Contents:** | ||
2 | |||
3 | {{toc/}} | ||
4 | |||
5 | |||
6 | |||
7 | |||
8 | |||
9 | |||
10 | |||
11 | = **1. point to point** = | ||
12 | |||
13 | == **1.1 Overview** == | ||
14 | |||
15 | ((( | ||
16 | [[image:1656901825798-483.png]] | ||
17 | |||
18 | |||
19 | |||
20 | == **1.2 Configure** == | ||
21 | |||
22 | |||
23 | (% style="color:blue" %)**A's configuration: ** **B's configuration:** | ||
24 | |||
25 | AT+GROUPMOD=0 AT+GROUPMOD=0 | ||
26 | |||
27 | AT+GROUPID=12345678 AT+GROUPID=12345678 | ||
28 | |||
29 | AT+TXCHS=868700000 AT+TXCHS=869000000 | ||
30 | |||
31 | AT+RXCHS=869000000 AT+RXCHS=868700000 | ||
32 | |||
33 | AT+CFGDEV=01 03 00 00 00 04,1 AT+CFGDEV=01 03 00 00 00 02,1 | ||
34 | |||
35 | or or | ||
36 | |||
37 | AT+COMMAND=01 03 00 00 00 04,1 AT+COMMAND=01 03 00 00 00 02,1 | ||
38 | ))) | ||
39 | |||
40 | |||
41 | |||
42 | == **1.3 Serial port display** == | ||
43 | |||
44 | |||
45 | [[image:image-20220704103422-2.png||height="430" width="817"]] | ||
46 | |||
47 | ((( | ||
48 | A sends a command to B to query B's RS485 sensor data and display it on A's upper computer. | ||
49 | ))) | ||
50 | |||
51 | ((( | ||
52 | Similarly, B sends a command to A to query A's RS485 sensor data and display it on B's upper computer. | ||
53 | ))) | ||
54 | |||
55 | |||
56 | [[image:image-20220704103502-3.png]] | ||
57 | |||
58 | ((( | ||
59 | (% data-sider-select-id="8e84c97f-97c9-47b5-afbd-e7cc77629fea" %) | ||
60 | 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) | ||
61 | ))) | ||
62 | |||
63 | |||
64 | |||
65 | = **2. Point To Mult-Point ** = | ||
66 | |||
67 | == (% data-sider-select-id="4dc2ef7f-a118-4ded-9b73-05d0d1e1b75b" %)**2.1 Overview**(%%) == | ||
68 | |||
69 | |||
70 | [[image:1656901541427-229.png]] | ||
71 | |||
72 | |||
73 | == (% data-sider-select-id="bd833649-16b9-4259-adc1-73e489ec3912" %)**2.2 Configure**(%%) == | ||
74 | |||
75 | |||
76 | (% data-sider-select-id="809f0ceb-1a62-4e1d-8aa6-9a12c485bcb8" style="color:blue" %)**Configuration of the TX group:** | ||
77 | |||
78 | AT+GROUPMOD=0,2 | ||
79 | |||
80 | AT+GROUPID=12345678 | ||
81 | |||
82 | AT+TXCHS=868700000 | ||
83 | |||
84 | AT+RXCHS=869000000 | ||
85 | |||
86 | AT+CFGDEV=01 03 00 00 00 02,1 | ||
87 | |||
88 | or | ||
89 | |||
90 | AT+COMMAND=01 03 00 00 00 02,1 | ||
91 | |||
92 | |||
93 | (% style="color:blue" %)**Configuration for RX group number 1:** | ||
94 | |||
95 | AT+GROUPMOD=1,1 | ||
96 | |||
97 | AT+GROUPID=12345678 | ||
98 | |||
99 | AT+TXCHS=869000000 | ||
100 | |||
101 | AT+RXCHS=868700000 | ||
102 | |||
103 | |||
104 | (% style="color:blue" %)**Configuration for RX group number 2:** | ||
105 | |||
106 | AT+GROUPMOD=1,2 | ||
107 | |||
108 | AT+GROUPID=12345678 | ||
109 | |||
110 | AT+TXCHS=869000000 | ||
111 | |||
112 | AT+RXCHS=868700000 | ||
113 | |||
114 | |||
115 | |||
116 | == (% data-sider-select-id="0bffbb87-9169-426e-8f09-a6a5603b35a9" %)**2.3 Serial port display**(%%) == | ||
117 | |||
118 | (% id="cke_bm_79849S" style="display:none" %) [[image:1656901280202-290.png]] | ||
119 | |||
120 | |||
121 | [[image:image-20220704103658-4.png||height="495" width="852"]] | ||
122 | |||
123 | ((( | ||
124 | 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" %) | ||
125 | ))) | ||
126 | |||
127 | (% style="display:none" %) (%%) | ||
128 | |||
129 | |||
130 | [[image:image-20220704103658-5.png]] | ||
131 | |||
132 | ((( | ||
133 | (% data-sider-select-id="4d98d2d3-b7f6-4f2a-91e1-d65b9392aca1" %) | ||
134 | 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) | ||
135 | ))) | ||
136 | |||
137 | (% style="display:none" %) (%%) | ||
138 | |||
139 | (% data-sider-select-id="7b4bbeb1-7dda-4179-9621-d8d6f6aa0fc0" %) | ||
140 | = (% data-sider-select-id="e960f7c8-2a3f-496a-b62f-425f1133b00e" %)**3 Point to Point (RS485 Pass Through).**(%%) = | ||
141 | |||
142 | == (% data-sider-select-id="4dc2ef7f-a118-4ded-9b73-05d0d1e1b75b" %)**3.1 Overview**(%%) == | ||
143 | |||
144 | (% data-sider-select-id="e960f7c8-2a3f-496a-b62f-425f1133b00e" %)**PC ~-~-> RS485 to USB adapter ~-~-> RS485-LN A<~-~-~-~--LoRa ~-~-~-~-> RS485-LN B<~-~- >RS485 sensor** | ||
145 | |||
146 | [[image:image-20240430153458-2.png]] | ||
147 | |||
148 | |||
149 | == (% data-sider-select-id="4dc2ef7f-a118-4ded-9b73-05d0d1e1b75b" %)**3.2 **(% data-sider-select-id="bd833649-16b9-4259-adc1-73e489ec3912" %)**Configure**(%%) == | ||
150 | |||
151 | (% data-sider-select-id="809f0ceb-1a62-4e1d-8aa6-9a12c485bcb8" style="color:blue" %)**Configuration of the PC:** | ||
152 | |||
153 | (% data-sider-select-id="1f71c512-1e78-4d70-998d-fa9a5e6d5fc8" %) | ||
154 | RS485 sensor read command | ||
155 | |||
156 | |||
157 | (% data-sider-select-id="fb8dd359-d0dd-4b15-a1ec-d8a7532f876f" style="color:blue" %)**Configuration for RX group number 1:** | ||
158 | |||
159 | (% data-sider-select-id="85b4fff7-5f64-4d7c-9084-ed37c89c0db7" %) | ||
160 | AT+MOD=1,500 | ||
161 | |||
162 | (% data-sider-select-id="8131b4ed-95d6-45f2-a437-98c105271570" %) | ||
163 | AT+GROUPID=12345678 | ||
164 | |||
165 | AT+TXCHS=869000000 | ||
166 | |||
167 | AT+RXCHS=868700000 | ||
168 | |||
169 | |||
170 | (% style="color:blue" %)**Configuration for RX group number 2:** | ||
171 | |||
172 | AT+GROUPID=12345678 | ||
173 | |||
174 | AT+TXCHS=869000000 | ||
175 | |||
176 | AT+RXCHS=868700000 | ||
177 | |||
178 | Configure parameters consistent with the RS485 sensor: | ||
179 | |||
180 | AT+BAUDR=4800 | ||
181 | |||
182 | AT+PARITY=0 | ||
183 | |||
184 | AT+DATABIT=8 | ||
185 | |||
186 | AT+STOPBIT=0 | ||
187 | |||
188 | AT+SCHEDULE=0,0 | ||
189 | |||
190 | AT+CMDDL=400 | ||
191 | |||
192 | |||
193 | |||
194 | |||
195 | == (% data-sider-select-id="0bffbb87-9169-426e-8f09-a6a5603b35a9" %)**3.3 Serial port display**(%%) == | ||
196 | |||
197 | [[image:image-20240430145609-1.png||height="652" width="1152"]] | ||
198 | |||
199 | 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) | ||
200 | |||
201 | |||
202 | = (% data-sider-select-id="45a0429e-5661-4b10-9cb4-be581299c196" %)**4. AT command**(%%) = | ||
203 | |||
204 | (% style="display:none" %) (%%) (% style="display:none" %) | ||
205 | |||
206 | ((( | ||
207 | (% style="color:#037691" %)**ATZ** (%%)**: ** Trig a reset of the MCU | ||
208 | ))) | ||
209 | |||
210 | ((( | ||
211 | (% style="color:#037691" %)**AT+FDR** (%%)**:** Reset Parameters to Factory Default, Keys Reserve | ||
212 | ))) | ||
213 | |||
214 | ((( | ||
215 | (% style="color:#037691" %)**AT+FCU** (%%)**:** Get or Set the Frame Co(% style="display:none" %) (%%)unter Uplink | ||
216 | ))) | ||
217 | |||
218 | ((( | ||
219 | (% style="color:#037691" %)**AT+FCD** (%%)**:** Get or Set the Frame Counter Downlink | ||
220 | ))) | ||
221 | |||
222 | ((( | ||
223 | (% style="color:#037691" %)**AT+TXP** (%%)**:** Get or Set the transmit power, the maximum is 20dBm (default is 14dBm) | ||
224 | ))) | ||
225 | |||
226 | ((( | ||
227 | (% style="color:#037691" %)**AT+SYNC** (%%)**:** Get or Set the Sync word [1:0x34,0:0x12] (default is 1) | ||
228 | ))) | ||
229 | |||
230 | ((( | ||
231 | (% style="color:#037691" %)**AT+PMB** (%%)**: **Get or Set the preamble (default:8) | ||
232 | ))) | ||
233 | |||
234 | ((( | ||
235 | (% style="color:#037691" %)**AT+TXCHS **(%%)**:** Get or Set the transmit frequency of TX (default:868700000) | ||
236 | ))) | ||
237 | |||
238 | ((( | ||
239 | (% style="color:#037691" %)**AT+TXSF **(%%)**:** Get or Set the spreading factor of TX (7 to 12) (default:12) | ||
240 | ))) | ||
241 | |||
242 | ((( | ||
243 | (% style="color:#037691" %)**AT+RXCHS **(%%)**:** Get or Set the transmit frequency of RX (default:869000000) | ||
244 | ))) | ||
245 | |||
246 | ((( | ||
247 | (% style="color:#037691" %)**AT+RXSF **(%%)**:** Get or Set the spreading factor of RX (7 to 12) (default:12) | ||
248 | ))) | ||
249 | |||
250 | ((( | ||
251 | (% style="color:#037691" %)**AT+BW **(%%)**: **Get or Set the bandwidth [0:125khz,1:250khz,2:500khz] (default:0) | ||
252 | ))) | ||
253 | |||
254 | ((( | ||
255 | (% 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) | ||
256 | ))) | ||
257 | |||
258 | ((( | ||
259 | (% style="color:#037691" %)**AT+TDC **(%%)**:** Get or set the application data transmission interval in ms(default 10 minutes) | ||
260 | ))) | ||
261 | |||
262 | ((( | ||
263 | (% style="color:#037691" %)**AT+VER **(%%)**:** Get firmware version number | ||
264 | ))) | ||
265 | |||
266 | ((( | ||
267 | (% style="color:#037691" %)**AT+SEND **(%%)**: **Set Custom sent hex data | ||
268 | ))) | ||
269 | |||
270 | ((( | ||
271 | (% style="color:#037691" %)**AT+GROUPMOD **(%%)**: **Set or Get the grouping (% style="display:none" %) (%%)mode of the device (default: 0) | ||
272 | ))) | ||
273 | |||
274 | ((( | ||
275 | ((( | ||
276 | (% 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" %) | ||
277 | |||
278 | ((( | ||
279 | (% style="color:#037691" %)**AT+INTMOD **(%%)**:** Get or Set the trigger interrupt mode | ||
280 | ))) | ||
281 | |||
282 | ((( | ||
283 | (% style="color:#037691" %)**AT+BAUDR **(%%)**:** Get or set the baud rate of rs485. (default: 9600) | ||
284 | ))) | ||
285 | |||
286 | ((( | ||
287 | (% style="color:#037691" %)**AT+DATABIT **(%%)**:** Get or Set databit(7:7 bits,8:8 bits) of rs485 (default: 8) | ||
288 | ))) | ||
289 | |||
290 | ((( | ||
291 | (% style="color:#037691" %)**AT+PARITY **(%%)**: **Get or Set parity(0:none,1:odd,2:even) of rs485(default: 0) | ||
292 | ))) | ||
293 | |||
294 | ((( | ||
295 | (% style="color:#037691" %)**AT+STOPBIT **(%%)**: **Get or Set stopbit(0:1 bit,1:1.5 bit,2:2 bit) of rs485(default: 0) | ||
296 | ))) | ||
297 | |||
298 | ((( | ||
299 | (% style="color:#037691" %)**AT+CMDDL **(%%)**:** Get or Set the delay waiting time after receiving RS485 command (default: 400) | ||
300 | ))) | ||
301 | |||
302 | ((( | ||
303 | (% style="color:#037691" %)**AT+CRCCHECK **(%%)**:** Get or set to receive and verify RS485 sensor data (0: Disable,1:CRC16_MODBUS) (default: 1) | ||
304 | ))) | ||
305 | |||
306 | ((( | ||
307 | (% style="color:#037691" %)**AT+SCHEDULE **(%%)**:** Each TDC sends command data to the receiver. | ||
308 | ))) | ||
309 | |||
310 | ((( | ||
311 | (% style="color:#037691" %)**AT+CFGDEV **(%%)**:** Instantly send RS485 commands to the receiver. | ||
312 | ))) | ||
313 | |||
314 | ((( | ||
315 | (% style="color:#037691" %)**AT+RS485 **(%%)**: **Send commands to the local RS485 device. | ||
316 | ))) | ||
317 | |||
318 | ((( | ||
319 | (% style="color:#037691" %)**AT+MOD **(%%)**:** Get or set the host send mode.(default: 0) | ||
320 | ))) | ||
321 | ))) | ||
322 | ))) | ||
323 | |||
324 | ((( | ||
325 | |||
326 | ))) | ||
327 | |||
328 | ((( | ||
329 | |||
330 | ))) | ||
331 | |||
332 | ((( | ||
333 | (% style="color:#4f81bd" %)**Example 1:** | ||
334 | ))) | ||
335 | |||
336 | ((( | ||
337 | **AT+SEND=01020304 **will send a payload of 01020304 | ||
338 | ))) | ||
339 | |||
340 | ((( | ||
341 | |||
342 | |||
343 | |||
344 | ))) | ||
345 | |||
346 | ((( | ||
347 | ((( | ||
348 | (% style="color:#4f81bd" %)**Example 2: ** | ||
349 | ))) | ||
350 | |||
351 | ((( | ||
352 | **AT+INTMOD=aa** (0:Disable,1:falling or rising,2:falling,3:rising) (default: 2) | ||
353 | ))) | ||
354 | ))) | ||
355 | |||
356 | ((( | ||
357 | ((( | ||
358 | RS485-LN support external Interrupt uplink since hardware v1.2 release. | ||
359 | ))) | ||
360 | |||
361 | [[image:image-20220704104958-6.png]] | ||
362 | |||
363 | ((( | ||
364 | Connect the Interrupt pin to RS485-LN INT port and connect the GND pin to V- port. When there is a high voltage (Max 24v) on INT pin. Device will send an lora packet. | ||
365 | ))) | ||
366 | ))) | ||
367 | |||
368 | ((( | ||
369 | |||
370 | |||
371 | |||
372 | ))) | ||
373 | |||
374 | ((( | ||
375 | ((( | ||
376 | (% style="color:#4f81bd" %)**Example 3: ** | ||
377 | ))) | ||
378 | |||
379 | ((( | ||
380 | **AT+SCHEDULE: **This command will be sent to Group RX during each transmission, Max command length is 14 bytes. The grammar is: | ||
381 | ))) | ||
382 | |||
383 | ((( | ||
384 | AT+SCHEDULE =xx xx xx xx xx xx xx xx xx xx xx xx,m | ||
385 | ))) | ||
386 | |||
387 | ((( | ||
388 | xx xx xx xx xx xx xx xx xx xx xx xx: The RS485 command to be sent | ||
389 | ))) | ||
390 | |||
391 | ((( | ||
392 | m: 0: no CRC, 1: add CRC-16/MODBUS in the end of this command | ||
393 | ))) | ||
394 | |||
395 | ((( | ||
396 | For example, if we have a RS485 sensor. The command to get sensor value is: 01 03 0B B8 00 02 46 0A. Where 01 03 0B B8 00 02 is the Modbus command to read the register 0B B8 where stored the sensor value. The 46 0A is the CRC-16/MODBUS which calculate manually. | ||
397 | ))) | ||
398 | ))) | ||
399 | |||
400 | ((( | ||
401 | |||
402 | ))) | ||
403 | |||
404 | ((( | ||
405 | |||
406 | ))) | ||
407 | |||
408 | ((( | ||
409 | ((( | ||
410 | (% style="color:#4f81bd" %)**Example 4: ** | ||
411 | ))) | ||
412 | |||
413 | ((( | ||
414 | **AT+CFGDEV :** This command will be sent to Group RX. | ||
415 | ))) | ||
416 | |||
417 | ((( | ||
418 | The grammar is: | ||
419 | ))) | ||
420 | |||
421 | ((( | ||
422 | AT+CFGDEV =xx xx xx xx xx xx xx xx xx xx xx xx,m | ||
423 | ))) | ||
424 | |||
425 | ((( | ||
426 | xx xx xx xx xx xx xx xx xx xx xx xx: The RS485 command to be sent | ||
427 | ))) | ||
428 | |||
429 | ((( | ||
430 | m: 0: no CRC, 1: add CRC-16/MODBUS in the end of this command. | ||
431 | ))) | ||
432 | ))) | ||
433 | |||
434 | ((( | ||
435 | |||
436 | |||
437 | |||
438 | ((( | ||
439 | (% style="color:#4f81bd" %)**Example 5:**(%%)** ** | ||
440 | ))) | ||
441 | ))) | ||
442 | |||
443 | ((( | ||
444 | **AT+RS485:** This command will be sent to local RS485 device. | ||
445 | ))) | ||
446 | |||
447 | ((( | ||
448 | The grammar is: | ||
449 | ))) | ||
450 | |||
451 | ((( | ||
452 | AT+RS485 =xx xx xx xx xx xx xx xx xx xx xx xx,m | ||
453 | ))) | ||
454 | |||
455 | ((( | ||
456 | xx xx xx xx xx xx xx xx xx xx xx xx: The RS485 command to be sent | ||
457 | ))) | ||
458 | |||
459 | ((( | ||
460 | m: 0: no CRC, 1: add CRC-16/MODBUS in the end of this command. | ||
461 | ))) | ||
462 | |||
463 | |||
464 | |||
465 | ((( | ||
466 | (% style="color:#4f81bd" %)**Example 6:** | ||
467 | ))) | ||
468 | |||
469 | ((( | ||
470 | **AT+MOD=0** Commands are transparently transmitted through UART. | ||
471 | ))) | ||
472 | |||
473 | ((( | ||
474 | **AT+MOD=1,500** Commands are transparently transmitted through RS485. 500 ms after the first character is received from RS485, all characters are commands. | ||
475 | ))) | ||
476 | |||
477 | |||
478 | |||
479 | ((( | ||
480 | (% style="color:#4f81bd" %)**Example 7:** | ||
481 | ))) | ||
482 | |||
483 | ((( | ||
484 | **AT+GROUPMOD=0** Set to point to point mode | ||
485 | ))) | ||
486 | |||
487 | ((( | ||
488 | **AT+GROUPMOD=0,aa** Set the TX group that controls the number of aa (The maximum value of aa is 8) | ||
489 | ))) | ||
490 | |||
491 | ((( | ||
492 | **AT+GROUPMOD=1,bb** Set to the RX group controlled by the TX group, numbered bb(The maximum value of bb is 8) | ||
493 | ))) | ||
494 | |||
495 | |||
496 | ((( | ||
497 | **AT+GROUPMOD=0,2** Set to control the TX group of the two RX groups | ||
498 | ))) | ||
499 | |||
500 | ((( | ||
501 | **AT+GROUPMOD=1,1** Set the RX group numbered 1 | ||
502 | ))) | ||
503 | |||
504 | ((( | ||
505 | **AT+GROUPMOD=1,2** Set the RX group numbered 2 | ||
506 | ))) | ||
507 | |||
508 | |||
509 | |||
510 | = **5. Data Format** = | ||
511 | |||
512 | |||
513 | ((( | ||
514 | 8 bytes of GROUPID +n payload + 4 bytes of checksum | ||
515 | ))) | ||
516 | |||
517 | |||
518 | ((( | ||
519 | Payload(S12, SF11, SF10 maximum length is 59, SF9 maximum length is 123, SF8, SF7 maximum length is 230): | ||
520 | ))) | ||
521 | |||
522 | (% border="1" cellspacing="10" style="background-color:#f7faff; color:black; width:430px" %) | ||
523 | |=(% style="width: 60px;" %)**Size (bytes)**|=(% style="width: 60px;" %)**1**|=(% style="width: 60px;" %)**1**|=(% style="width: 60px;" %)**1**|=(% style="width: 80px;" %)**1**|=(% style="width: 100px;" %)**payloadsize** | ||
524 | |(% style="width:100px" %)**Value**|(% style="width:71px" %)address|(% style="width:71px" %)request|(% style="width:49px" %)ACK|(% style="width:99px" %)payloadsize|(% style="width:139px" %)((( | ||
525 | command data or | ||
526 | |||
527 | return data | ||
528 | ))) | ||
529 | |||
530 | ((( | ||
531 | (% style="color:#037691" %)**The first byte: **(%%)00 is the broadcast address, 01-08 is the RX group number | ||
532 | ))) | ||
533 | |||
534 | ((( | ||
535 | (% style="color:#037691" %)**The second byte:**(%%) send request when not 0, not request when it is 0 | ||
536 | ))) | ||
537 | |||
538 | ((( | ||
539 | (% style="color:#037691" %)**The third byte:**(%%) ACK returned to the sender. | ||
540 | ))) | ||
541 | |||
542 | ((( | ||
543 | (% style="color:#037691" %)**The fourth byte:**(%%) The command length of the sender or the data length of the RS485 sensor returned by the receiver. | ||
544 | ))) | ||
545 | |||
546 | ((( | ||
547 | (% style="color:#037691" %)**The Fifth byte:**(%%) RS485 command or RS485 return data. | ||
548 | ))) | ||
549 | |||
550 | |||
551 | ((( | ||
552 | |||
553 | ))) |