Sensor RS485 Communication Description: I Wiring Diagram 4 3 2 1
Sensor RS485 Communication Description: I Wiring Diagram 4 3 2 1
Sensor RS485 Communication Description: I Wiring Diagram 4 3 2 1
I Wiring diagram
4 3 2 1
PIN3 RS485B 485 interface line B; (Note: it does not connect for WiFi
version )
PIN4 RS485A 485 interface line A; (Note: it does not connect for WiFi
version )
II Communication Protocol
1. Communication Convention
Baud rate:9600
Data bit:8
Parity check: no
Stop bit:1
Data flow control: no
CRC check,CRC-16 0xA001-RTU standard,L is in the front, H is in the back.
All operation or response commands are hexadecimal data.
2. Frame format description
2.1 Gas sensor value data frame format. The default device address is 0x02.
00 01 02 03 04 Check 0 to 4 bits
02 03 05
Resolution:
Type Resolution Unit
PM1.0 1 ug/m3
PM2.5 1 ug/m3
PM10 1 ug/m3
CO2 1 ppm
VOC 1 ppb
HCHO 1 ppb
SO2 1 ppb
NO2 1 ppb
Temperature 0.1 degrees Celsius ℃
Humidity 1 %
Wind speed 0.01 m/s
Wind direction 0.01 Due north is 0 degrees, clockwise angle value
2.2 Read the anemometer data. The factory default device address is 0x01. The anemometer can only work in
query feedback mode.
Name/nu
mber of 0 1 2 3 4 5 Check 0 to 5 bits
bytes
Read Read
Device Function Read start Read start
number of number of CRC-16L CRC-16H
address code address H address L
data H data L
Read wind
speed and 01 03 00 00 00 02 C4 0B
direction
Tx:01 03 00 00 00 02 C4 0B
Rx:01 03 04 00 C1 60 AE 02 73
Name/nu
mber of 0 1 2 3 4 5 6 Check 0 to 6 bits
bytes
Wind Wind
Device Functio Wind Wind
Data type direction direction CRC-16L CRC-16H
address n code speed H speed L
H L
Read wind
speed and 01 03 04 00 C1 60 AE 02 73
direction
Value = (high bit * 256 + low bit) * resolution; wind speed 0x00 C1 resolution is 0.01, wind speed = 1.93 m/s; wind
direction 0x60 AE resolution is 0.01, wind direction = 247.5 degrees. (The wind direction is 0 degrees from true north,
and the angle is clockwise.)
2.3 Configure the active upload mode. The gas sensor can be operated in two modes: active upload and query
feedback. The anemometer can only work in query feedback mode.
The gas sensor has two working modes, one of which is optional, the device factory default: address 0x02, working
mode is automatic, the interval time is 5 seconds;
Mode: active upload mode 0x01, query feedback mode 0x00.
Name/number 0 1
2 3 4 5 6 Check 0 to 6 bits
of bytes
command command word
Registe Registe word H L
Functi
Device r r Workin (Active (Active CRC-1
on CRC-16H
address address address g mode upload time upload time 6L
code
H L interval in interval in
seconds) seconds)
Configuration
command
02 06 00 50 01 00 05 B8 65
(active sending
mode)
Configuration: Device 0x02 is the active upload mode, and the upload interval is 5 seconds. (Interval time can be
selected from 1 to 65535 seconds), the configuration command must have a time, and the time cannot be 0.
Tx: 02 06 00 50 01 00 05 B8 65
Rx:02 06 00 5001 00 05 B8 65(Return command successfully)
Note: According to the characteristics of RS485, the active upload detection data mode is suitable when there is only one
sensor connected to the bus, and the query feedback mode should be used when multiple sensors are connected.
2.4 Gas sensor configuration query feedback mode
Name/number
0 1 2 3 4 5 6 Check 0 to 6 bits
of bytes
Functi Register Register Worki
Device
on address address ng Reservation Reservation CRC-16L CRC-16H
address
code H L mode
Configuration
command
02 06 00 50 00 00 00 29 A6
(active
sending mode)
Choose one of two working modes.
Tx: 02 06 00 50 00 00 00 29 A6
Rx:02 06 00 50 00 00 00 29 A6(Return command successfully)
When working in query mode, if no query command is received after waiting for 15 minutes, the sensor will enter a
low-power sleep mode. It starts to work when the query command is received again. After sleep, the first query
command is received, and the returned sensor detection value is 0. You need to wait 30 to 60 seconds before sending the
query command again to get the correct detection value. If the sensor is not required to enter sleep mode, the query
command interval is less than 15 minutes.
2.5 Query gas detection value command in gas sensor query feedback mode
00 01 02 03 04 05 Check 0 to 5 bits
Device Register Register Read number Read number
Function code CRC-16L CRC-16H
address address H address L of data H of data L
02 03 00 03 00 05 75 FA
Read address 0x02:
Tx:02 03 00 03 05 75 FA
Response see 2.1
2.7 Query address command when the sensor address is unknown (used when the 485 bus is only connected to the
sensor)
Name/nu 0 1
mber of 2 3 4 5 Check 0 to 5 bits
bytes
Device Function Read start Read start Read Read CRC-16L CRC-16H
address code address H address L number of number of
data H data L
Query
device FA 03 00 66 00 02 31 9F
address
FA,that is 250, is the general address. When the address is unknown, the address 250 can be used to obtain the real
device address, and 00 66 is the register of the device address.
For the correct query command, the device will respond. For example, the response data is: 01 03 02 07 12 3A 79.
The format analysis is shown in the following table:
Tx:FA 03 00 66 00 02 31 9F
Rx:01 03 02 07 12 3A 79
Name/nu
mber of 0 1 2 3 4 Check 0 to 6 bits
bytes
Device
Function code Data type Model code CRC-16L CRC-16H
address
Query
device 01 03 02 07 12 3A 79
address
In the response data, the first byte 01 indicates that the real address of the current device is, 0x07 12, converted to
decimal 1810, which means that the main model code of the current device is 1810.
2.8 Query working mode commands when the sensor working mode is unknown
Name/number of 0 1
2 3 4 5 Check 0 to 5 bits
bytes
Read Read
Device Function Read start Read start CRC-16 CRC-16
number of number of
address code address H address L L H
data H data L
Query working
02 03 00 50 00 02 C4 29
mode
Tx:02 03 00 50 00 02 C4 29
If Rx:02 03 00 50 00 00 05 E9 F0
Name/number 0 1 4
2 3 5 6 Check 0 to 6 bits
of bytes
Read Read Worki Active Active
Functi
Device start start ng reportin reportin CRC-1 CRC-1
on
address address address mode g time g time 6L 6H
code
H L H L
Query working
02 03 00 50 00 00 05 E9 F0
mode
Device 0x02, the reporting interval of active upload mode is 5 seconds.
If Rx:02 03 00 50 01 00 00 E9 A5
Device 0x02, query feedback mode.
while (len--) {
uindex = crc_h ^* updata++;
uindex = crc_h ^* updata++;
crc_h = crc_l ^ table_CRC_h[uindex];
crc_l = table_CRC_l[uindex];
}
return (crc_h << 8 | crc_l);