User Manual

User Guide
©2008-2020 Seeed Technology Co., Ltd. All rights reserved. solution.seeedstudio.com
22 / 23
For example: to read the register 0x0000-0x0002, that reads the temperature, water content, electrical
conductivity value
Host Ask:01 0400000003 B00B (8 byte)
Address
1byte
0x01
Function number
1byte
0x04
Start register address
2byte
0x0000
Register number
2byte
0x0003
Check
2byte
0xB00B
When the host needs to send data to the sensor, it will need to send Check data stored in the snd array.
(01 04 00 00 00 03 A total of 6 byte), Among them num=6
Pseudo code as follows:
unsigned char request[8]={01,04,00,00,00,03,00,00};// The last two 00,00 are CHECK CRC
unsigned char num=6;// Calculate the array of the first 6 CRC CHECK byte
unsigned int crc16=0;
crc16= calc_crc16 (request, num);
request[6]= crc16%256;// Store check CRC in an array to be sent
request[7]= crc16/256;
CommPort.Send(request, 8);// Send data through serial port
Sensor Respond:01 04 06 08 90 0E 93 02 4E D2 57 (11 byte)
Address
1byte
0x01
Function number
1byte
0x04
Effective byte number
1byte
0x06
Temperature register value
2byte
0x08
0x90
Volume water content register value
2byte
0x0E
0x93
Conductivity register value
2byte
0x02
0x4E
Check
2byte
0xD257