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