Pengenalan produk:
Produk ini mengadopsi chip tingkat industri, suhu dan kelembaban impor presisi tinggi SHT20 untuk memastikan keandalan yang sangat baik, presisi tinggi, dan pertukaran produk. Menggunakan antarmuka perangkat keras RS485 (dengan desain perlindungan petir), lapisan protokol tersebut kompatibel dengan protokol Modbus industri-rtu standar. Produk ini mengintegrasikan protokol MODBUS dan protokol umum. Pengguna dapat memilih protokol komunikasi. Protokol umum memiliki fungsi unggahan otomatis (menghubungkan RS485 melalui alat penyesuaian port seri secara otomatis akan mengeluarkan suhu dan kelembaban).

MODBUS protocol
Function code used by the product:
0x03: Read holding register
0x04: Read input register
0x06: Write a single holding register
0x10: Write multiple holding registers
Register type |
Register address |
Data content |
Number of bytes |
input register |
0x0001 |
temperature value |
2 |
0x0002 |
Humidity value |
2 |
|
holding register |
0x0101 |
Device address ( 1~247 ) |
2 |
0x0102 |
baud rate 0:9600 1:14400 2:19200 |
2 |
|
0x0103 |
Temperature correction value (/10) -10.0~10.0 |
2 |
|
0x0104 |
Humidity correction value (/10) -10.0~10.0 |
2 |
Modbus communication format:
The host sends a data frame:
slave address |
function code |
Register address high byte |
Register address low byte |
Number of registers high byte |
Number of registers low byte |
CRC high byte |
CRC low byte |
|
|
|
|
|
|
|
|
The slave responds with data frame:
slave address |
Response function code |
Number of bytes |
Register 1 data high byte |
Register 1 data low byte |
Register N data high byte |
Register N data low byte |
CRC high byte |
CRC low byte |
|
|
|
|
|
|
|
|
|
MODBUS command frame
Host reads temperature command frame (0x04):
slave address |
function code |
Register address high byte |
Register address low byte |
Number of registers high byte |
Number of registers low byte |
CRC high byte |
CRC low byte |
0x01 |
0x04 |
0x00 |
0x01 |
0x00 |
0x01 |
0x60 |
0x0a |
The slave responds with data frame:
slave address |
function code |
Number of bytes |
temperature high byte |
temperature low byte |
CRC high byte |
CRC low byte |
0x01 |
0x04 |
0x02 |
0x01 |
0x31 |
0x79 |
0x74 |
Temperature value = 0x131, converted to decimal 305, actual temperature value = 305 / 10 = 30.5℃
Note: The temperature is a signed hexadecimal number, the temperature value = 0xFF33, converted to decimal -205, the actual temperature = -20.5℃;
The host reads the humidity command frame (0x04):
slave address |
function code |
Register address high byte |
Register address low byte |
Number of registers high byte |
Number of registers low byte |
CRC high byte |
CRC low byte |
0x01 |
0x04 |
0x00 |
0x02 |
0x00 |
0x01 |
0x90 |
0x0A |
The slave responds with data frame:
slave address |
function code |
Number of bytes |
humidity high byte |
humidity low byte |
CRC high byte |
CRC low byte |
0x01 |
0x04 |
0x02 |
0x02 |
0x22 |
0xD1 |
0xBA |
Humidity value = 0x222, converted to decimal 546, actual humidity value = 546 / 10 = 54.6%;
Continuously read temperature and humidity command frames (0x04):
slave address |
function code |
Register address high byte |
Register address low byte |
Number of registers high byte |
Number of registers low byte |
CRC high byte |
CRC low byte |
0x01 |
0x04 |
0x00 |
0x01 |
0x00 |
0x02 |
0x20 |
0x0B |
The slave responds with data frame:
slave address |
function code |
Number of bytes |
temperature high byte |
temperature
low byte |
humidity high byte |
humidity low byte |
CRC high byte |
CRC low byte |
0x01 |
0x04 |
0x04 |
0x01 |
0x31 |
0x02 |
0x22 |
0x2A |
0xCE |
Read the contents of the holding register (0x03):
Take reading the slave address as an example:
slave address |
function code |
Register address high byte |
Register address low byte |
Number of registers high byte |
Number of registers low byte |
CRC high byte |
CRC low byte |
0x01 |
0x03 |
0x01 |
0x01 |
0x00 |
0x01 |
0xD4 |
0x36 |
Slave response frame:
slave address |
function code |
Number of bytes |
slave address high byte |
slave address low byte |
CRC high byte |
CRC low byte |
0x01 |
0x03 |
0x02 |
0x00 |
0x01 |
0x30 |
0x18 |
Modify the contents of the holding register (0x06):
Take modifying the slave address as an example:
slave address |
function code |
Register address high byte |
Register address low byte |
Register value high byte |
Register value low byte |
CRC high byte |
CRC low byte |
0x01 |
0x06 |
0x01 |
0x01 |
0x00 |
0x08 |
0xD8 |
0x30 |
Modify slave address : 0x08 = 8
Slave response frame ( same as sending ):
slave address |
function code |
Register address high byte |
Register address low byte |
Register value high byte |
Register value low byte |
CRC high byte |
CRC low byte |
0x01 |
0x06 |
0x01 |
0x01 |
0x00 |
0x08 |
0xD4 |
0x0F |
Continuously modify the holding register (0x10):
slave address |
function code |
initial address high byte |
initial address low byte |
Number of registers high byte |
Number of registers low byte |
Number of bytes |
Register 1 high byte |
Register 1 low byte |
Register 2 high byte |
Register 2 low byte |
CRC high byte |
CRC low byte |
0x01 |
0x10 |
0x01 |
0x01 |
0x00 |
0x02 |
0x04 |
0x00 |
0x20 |
0x25 |
0x80 |
0x25 |
0x09 |
Modify slave address : 0x20 = 32
Baud rate : 0x2580 = 9600
Slave response frame:
slave address |
function code |
Register address high byte |
Register address low byte |
Number of registers high byte |
Number of registers low byte |
CRC high byte |
CRC low byte |
0x01 |
0x10 |
0x00 |
0x11 |
0x00 |
0x04 |
0xD4 |
0x0F |
Ordinary version agreement
The default baud rate is 9600 (the user can set it by himself), 8-bit data, 1-bit stop, no parity
RS485 communication
Serial command |
illustrate |
READ |
Trigger a temperature and humidity report (27.4 ℃ , 67.7% temperature 27.4 ℃ humidity 67.7%) |
AUTO |
Start the automatic reporting function of temperature and humidity ( same as above ) |
STOP |
Stop the automatic reporting function of temperature and humidity |
BR:XXXX |
Set baud rate 9600~19200 (BR:9600 baud rate 9600) |
TC:XX.X |
Set up temperature calibration (-10.0~10.0) (TC:02.0 temperature correction value is 2.0 ℃ ) |
HC:XX.X |
Set up humidity calibration (-10.0~10.0) (HC:-05.1 humidity correction value is -5.1%) |
HZ:XXX |
Set temperature and humidity reporting rate (0.5,1,2,5,10) (HZ:2 automatic reporting rate 2Hz) |
PARAM |
Read the current system settings
|
PARAM instruction:
TC:0.0,HC:0.0,BR:9600,HZ:1 ->Temperature correction value 0.0 Humidity correction value 0.0 Baud rate 9600 Reporting rate 1Hz
SLAVE_ADD:1 ->MODBUS slave address 0x01