— Blogs —
—Products—
Consumer hotline +8618073152920 WhatsApp:+8615367865107
Address:Room 102, District D, Houhu Industrial Park, Yuelu District, Changsha City, Hunan Province, China
Product knowledge
Time:2026-09-07 16:27:28 Popularity:529
Connecting an RS485 sensor to a PLC or data logger involves more than matching the A and B terminals. The receiving device must also understand the Modbus RTU protocol, device address, register definitions and numerical representation of each measurement.
Many communication problems occur because the electrical connection is correct but the controller uses an incorrect register address, data type or scaling factor.
This guide explains RS485 Modbus RTU communication using practical hexadecimal frames, CRC16 calculations and a NiuBoL soil moisture and temperature sensor example.

RS485 defines the electrical characteristics of a differential serial communication interface. Modbus RTU defines the message structure and communication rules used by compatible devices over a serial connection.
RS485 is the physical communication interface, while Modbus RTU is the communication protocol.
| Term | Function | Example |
|---|---|---|
| RS485 | Electrical communication interface | Differential A/B communication pair |
| Modbus RTU | Serial message protocol | Request and response frames |
| Device address | Identifies the addressed sensor | Slave ID 01 |
| Function code | Identifies the requested operation | 03: Read holding registers |
| Register address | Identifies data within the sensor | 0x0000 |
| Scaling factor | Converts raw register values into engineering values | 272 ÷ 10 = 27.2% |
| CRC16 | Checks frame integrity | C4 0B |
A device with an RS485 interface does not necessarily support Modbus RTU. Similarly, two Modbus-compatible sensors may use completely different register maps.
A typical two-wire RS485 sensor requires a compatible power supply and a differential communication pair.
Before connecting the sensor, check its wiring diagram and electrical specifications. Do not identify power or communication conductors solely by their insulation colors, because wiring conventions may differ between models.
PLC / Data Logger / USB-RS485 Converter
RS485 Communication Pair
↓
Sensor 1 — Address 01
↓ Shared RS485 Bus
Sensor 2 — Address 02
↓
Sensor 3 — Address 03
This diagram illustrates logical bus connectivity. The actual power distribution, grounding, termination and cable arrangement must follow the electrical requirements of the installation.
For initial commissioning, connect only one sensor to one compatible Modbus master. This makes it easier to identify wiring problems and communication-setting mismatches.
| Setting | Common Example |
|---|---|
| Interface | RS485 |
| Protocol | Modbus RTU |
| Baud rate | 9600 bps |
| Data bits | 8 |
| Parity | None |
| Stop bits | 1, where specified by the device |
| Device address | 01 |
The combination of eight data bits, no parity and one stop bit is commonly described as 8N1.
Many industrial sensors use this configuration, but it is not a universal Modbus RTU default. Some instruments use even parity or two stop bits. Always match the actual sensor documentation.
Each independently addressed sensor on a shared Modbus RTU bus requires a unique device address.
Standard Modbus serial addressing uses addresses 1–247 for individual server devices. Address 0 is reserved for broadcast operations, while addresses 248–255 are reserved by the standard.
Some manufacturers provide additional model-specific addressing or configuration conventions. These should not automatically be treated as interoperable standard Modbus addresses.
For example, a monitoring station may use the following device assignments:
Address 01: Soil moisture and temperature sensor.
Address 02: Air temperature and humidity sensor.
Address 03: Wind speed sensor.
Address 04: Solar radiation sensor.
The address identifies the sensor, not the measurement parameter. One sensor may provide several measurements through consecutive registers while using only one device address.
When several new sensors have the same factory-configured address, connect and configure them individually before installing them on a shared bus.
Otherwise, two devices may respond to the same request simultaneously, causing corrupted responses, CRC errors or communication failures.

The function code identifies the operation requested by the Modbus master.
Common function codes relevant to environmental and industrial sensors include:
| Function Code | Operation | Typical Use |
|---|---|---|
| 03 (0x03) | Read holding registers | Read supported measurement or configuration registers |
| 04 (0x04) | Read input registers | Read measurements assigned to the input register area |
| 06 (0x06) | Write single register | Change one supported writable configuration register |
| 16 (0x10) | Write multiple registers | Update supported consecutive configuration registers |
Not every Modbus sensor supports every function code. In particular, functions 03 and 04 should not be assumed interchangeable.
Begin commissioning with documented read-only operations. Use configuration-writing commands only after confirming the exact register purpose, accepted values and required procedure.
Consider the following hexadecimal request:
01 03 00 00 00 02 C4 0B
This is a valid Modbus RTU request to read two holding registers starting at protocol address zero from device address 1.
| Hexadecimal Field | Meaning | Interpretation |
|---|---|---|
| 01 | Device address | Sensor address 1 |
| 03 | Function code | Read holding registers |
| 00 00 | Starting register | Protocol address 0 |
| 00 02 | Register quantity | Two consecutive 16-bit registers |
| C4 0B | CRC16 | Low byte first, high byte second |
The complete request contains eight bytes.
Function 03 permits a standard request quantity of 1–125 holding registers, although a particular sensor may support fewer registers or restrict the available starting addresses.
A correctly calculated frame does not guarantee that the selected device supports the requested register range.
One of the most common Modbus integration problems is confusing the register reference displayed in documentation with the actual address transmitted in the protocol frame.
Holding registers are frequently described using references beginning with 40001. However, the starting address transmitted in a standard Modbus request is zero-based.
| Conventional Holding Register Reference | Zero-Based Decimal Address | Protocol Hexadecimal Address |
|---|---|---|
| 40001 | 0 | 0x0000 |
| 40002 | 1 | 0x0001 |
| 40003 | 2 | 0x0002 |
| 40011 | 10 | 0x000A |
This table illustrates the conventional 40001-based holding-register notation. PLC programming software and Modbus test applications may use different address-entry conventions.
Some applications expect the displayed register reference, while others expect the zero-based protocol address.
Check the software's addressing convention before entering a register number. A one-register offset can cause every subsequent measurement channel to be interpreted incorrectly.
The NiuBoL NBL-S-THR TDR soil moisture and temperature sensor is a practical example of an RS485 instrument providing two measurements through consecutive Modbus registers.
NBL-S-THR soil sensor used as the register-mapping example in this communication guide.
The RS485 version requires a compatible DC power supply and Modbus master. Its published register definitions include soil temperature at address 0x0000 and soil moisture at address 0x0001.
| Parameter | Specification |
|---|---|
| Model | NBL-S-THR |
| Measured parameters | Soil temperature and soil moisture |
| Power supply | 12–24 VDC |
| Power consumption | Approximately 0.3 W |
| Digital interface | RS485 Modbus RTU |
| Default baud rate | 9600 bps |
| Recommended communication interval | More than 1000 ms |
| Register | Measurement | Conversion | Unit |
|---|---|---|---|
| 0x0000 | Soil temperature | Raw value ÷ 10 | °C |
| 0x0001 | Soil moisture | Raw value ÷ 10 | % VWC |
Assuming the sensor is configured at device address 01 and supports function 03 for these registers, the corresponding request is:
TX: 01 03 00 00 00 02 C4 0B
For illustration, suppose the returned temperature is 24.5 °C and the soil moisture is 27.2%.
A simulated, CRC-valid response containing those values is:
RX: 01 03 04 00 F5 01 10 EA 5D
The simulated response can be interpreted as follows:
| Response Field | Interpretation |
|---|---|
| 01 | Responding device address |
| 03 | Read holding registers response |
| 04 | Four measurement data bytes |
| 00 F5 | Hexadecimal 0x00F5 = decimal 245 |
| 01 10 | Hexadecimal 0x0110 = decimal 272 |
| EA 5D | Calculated response CRC16 |
The engineering values are therefore:
Soil temperature = 245 ÷ 10 = 24.5 °C
Soil moisture = 272 ÷ 10 = 27.2% VWC
This response frame has been constructed and CRC-checked for teaching and decoder testing. It is not a recorded response captured from a physical sensor.
Confirm the supplied sensor's function codes, serial settings and register definitions before using the request in an actual installation.
Modbus RTU uses a 16-bit cyclic redundancy check to detect transmission errors within a serial message.
The standard CRC calculation uses an initial value of 0xFFFF and the reflected polynomial 0xA001.
The calculation covers the device address, function code and message data before the CRC field is appended.
The resulting CRC is transmitted with its low-order byte first, followed by its high-order byte.
Consider two requests that read the same registers from different sensors:
Sensor address 01: 01 03 00 00 00 02 C4 0B Sensor address 02: 02 03 00 00 00 02 C4 38
Although only the device address changes in the request body, the calculated CRC is different.
Sending the second request with the first request's CRC would produce an invalid frame.
Recalculate the CRC whenever the device address, function code, starting register, register quantity or other message data changes.
The following Python code calculates the CRC16 value and appends the correct transmission-order bytes to a Modbus RTU message.
def modbus_crc16(data):
crc = 0xFFFF
for byte in data:
crc ^= byte
for _ in range(8):
if crc & 0x0001:
crc = (crc >> 1) ^ 0xA001
else:
crc >>= 1
return crc & 0xFFFF
def append_crc(data):
crc = modbus_crc16(data)
return data + crc.to_bytes(2, "little")
request = bytes.fromhex("01 03 00 00 00 02")
frame = append_crc(request)
print(frame.hex(" ").upper())Expected output:
01 03 00 00 00 02 C4 0B
The Python example generates the frame locally. It does not require a physical sensor or serial communication connection.
Where a PLC function block or Modbus communication library generates CRC automatically, do not append a second CRC manually.
A receiving application should verify more than the presence of returned bytes.
It should check the CRC, responding device address, function code, data length and any exception status before decoding measurement values.
The following example uses the simulated NBL-S-THR response from the previous section. It assumes that the CRC calculation function defined above is available.
response = bytes.fromhex(
"01 03 04 00 F5 01 10 EA 5D"
)
if len(response) < 5:
raise ValueError("Incomplete Modbus frame")
received_crc = int.from_bytes(
response[-2:], "little"
)
calculated_crc = modbus_crc16(
response[:-2]
)
if received_crc != calculated_crc:
raise ValueError("CRC mismatch")
if response[0] != 0x01:
raise ValueError("Unexpected device address")
if response[1] == 0x83:
raise ValueError(
f"Modbus exception: {response[2]:02X}"
)
if response[1] != 0x03:
raise ValueError("Unexpected function code")
if response[2] != 4 or len(response) != 9:
raise ValueError("Unexpected response length")
temperature_raw = int.from_bytes(
response[3:5], "big"
)
moisture_raw = int.from_bytes(
response[5:7], "big"
)
temperature = temperature_raw / 10
moisture = moisture_raw / 10
print(f"Soil temperature: {temperature:.1f} C")
print(f"Soil moisture: {moisture:.1f} %")Expected output:
Soil temperature: 24.5 C Soil moisture: 27.2 %
This example decodes the positive measurement values in the simulated frame. Confirm the sensor's actual negative-temperature representation before extending it to below-zero observations.
A production communication application also requires suitable serial frame collection, timeout handling and recovery behavior.
Modbus registers contain 16-bit data words. The measurement meaning depends on the sensor manufacturer's register definition.
Suppose a sensor returns the raw hexadecimal value 0x09E6.
This represents decimal 2534.
If the documented divisor is 100, the engineering value is:
2534 ÷ 100 = 25.34
If the divisor is 10, the same raw value represents 253.4 instead.
The correct result depends on the actual register definition, not the number of decimal places displayed by the receiving software.
Where a sensor specifies signed 16-bit two's-complement representation, the hexadecimal value 0xFF9C represents −100.
Interpreting the same word as an unsigned integer would produce 65436.
If the documented temperature divisor is 10, the correct signed measurement is −10.0 °C.
The following Python example demonstrates signed decoding:
raw = bytes.fromhex("FF 9C")
value = int.from_bytes(
raw,
byteorder="big",
signed=True
)
print(value / 10)Expected result: −10.0
Use this interpretation only when signed two's-complement representation is specified for the actual sensor.
Some sensors report measurements using two consecutive 16-bit registers.
These registers may represent a signed or unsigned 32-bit integer, an IEEE 754 floating-point value or another manufacturer-defined format.
For example, the IEEE 754 single-precision representation of 25.0 is 0x41C80000.
One possible register arrangement is:
First register: 41 C8 Second register: 00 00
A device using reversed word order could instead return the two register words in the opposite sequence.
Modbus does not establish a universal multi-register floating-point layout for every sensor. Confirm the device's data type and word order before decoding.
Also distinguish the data-byte order within a register from the low-byte-first transmission order of the CRC field.
A valid exception response indicates that the addressed device received a request but could not complete the requested operation under the relevant conditions.
For example, the following is a CRC-valid simulated exception frame:
01 83 02 C0 F1
Its fields represent:
01: Responding device address.
83: Exception response associated with function 03.
02: Illegal data address exception.
C0 F1: CRC16 transmitted low byte first.
| Exception Code | Meaning | Investigation |
|---|---|---|
| 01 | Illegal function | Check whether the device supports the requested operation |
| 02 | Illegal data address | Check the starting address, quantity and available register range |
| 03 | Illegal data value | Check whether the request contains an unacceptable field value |
| 04 | Server device failure | Investigate the device condition and applicable operating procedure |
A Modbus exception is different from receiving no response. An exception provides information about a request that reached a responding device.
After confirming communication with one sensor, additional devices can be connected to a suitably designed shared RS485 bus.
Use an appropriate linear bus arrangement, keep branch connections short and follow the installation requirements for cable impedance, termination and reference connections.
For conventional 120-ohm RS485 cabling, termination is commonly installed at the two physical ends of the bus. Do not automatically install a terminating resistor at every intermediate sensor.
Biasing requirements depend on the communication equipment and bus design. Some controllers already include termination or fail-safe biasing components.
RS485 communication distance and supported device count are influenced by cable characteristics, baud rate, transceiver loading, installation topology and electrical noise. Do not treat a single maximum distance or device-count figure as a guarantee for every installation.
Modbus RTU uses silent intervals to distinguish separate serial frames. A frame boundary normally requires a silent interval of at least 3.5 character times under the applicable serial-line timing rules.
For illustration, at 9600 bps with an 11-bit serial character, one character occupies approximately:
11 ÷ 9600 × 1000 = 1.146 ms
The corresponding 3.5-character interval is approximately:
1.146 × 3.5 = 4.01 ms
This protocol-level timing is different from the sensor manufacturer's recommended measurement communication interval.
For example, the NBL-S-THR product documentation recommends a communication interval greater than 1000 ms.
Sending requests every few milliseconds simply because the RTU frame timing permits it does not establish that the sensor can reliably provide measurements at that rate.
Respect the selected sensor's response time, minimum communication interval and any required measurement stabilization period.

Changing register addresses repeatedly will not resolve a disconnected power supply. Similarly, replacing a sensor will not correct a PLC that interprets signed data as unsigned.
Use the observed communication behavior to narrow the investigation.
| Observed Problem | Possible Cause | Recommended Check |
|---|---|---|
| No response from the sensor | Power, wiring, device address, serial settings or invalid request | Test one powered sensor with the documented communication settings |
| CRC errors | Incorrect CRC, electrical interference, frame handling or response collision | Inspect raw bytes and verify calculated CRC and electrical conditions |
| Valid exception response | Unsupported function, address or request data | Decode the exception and consult the model-specific register map |
| One sensor works, several sensors fail | Duplicate device addresses, wiring topology or bus loading | Verify individual addresses, termination and electrical layout |
| Reading is ten or one hundred times too large | Incorrect decimal scaling | Compare raw register data with the documented conversion formula |
| Negative temperature appears as a very large positive number | Incorrect interpretation of signed data | Confirm and apply the specified negative-value encoding |
| Unreasonable floating-point values | Incorrect register quantity, data type or word order | Inspect both raw register words and the manufacturer's data definition |
| Local measurement is correct but the remote platform is wrong | Gateway mapping, repeated scaling or incorrect engineering units | Compare the sensor response, gateway value and final platform channel |
Where the sensor does not respond, measure the actual supply voltage at the sensor under operating conditions. A nominal 12 V or 24 V cabinet supply does not guarantee that the same voltage reaches a distant field device.
Power down equipment before changing electrical connections. Follow the actual A/B terminal definitions rather than relying on a universal polarity-label convention.
Modbus RTU describes the local serial communication between the sensor and its compatible master.
HTTP, HTTPS and MQTT are different communication arrangements that may be used between a gateway and a remote server.
For an agricultural or environmental IoT installation, the complete data path may be:
RS485 Modbus RTU Sensors
↓
Compatible Modbus Master / RTU / Data Logger
Register Acquisition and Engineering Value Conversion
↓
4G / Wi-Fi / Ethernet
↓
HTTP or MQTT Receiving Server
↓
Monitoring Application
Compatible NiuBoL RTU and data acquisition equipment can acquire supported RS485 sensor measurements and transfer them through selected communication interfaces.
Where a customer uses its own server, confirm the required upstream protocol, authentication, data format and channel mapping before ordering.
A transparent communication device and an active Modbus acquisition gateway do not necessarily provide the same functions. Confirm whether the selected equipment independently polls and decodes the sensor or only forwards serial data.
The standard NiuBoL cloud platform supports viewing monitoring data. SMS and email alarm functions are not included. Separately specify these functions where the project requires them.
When a sensor becomes unavailable, the receiving application should distinguish a missing measurement from a genuine measured zero. A previously acquired value should not be presented indefinitely as a current measurement.
A1. Not when they are independently polled on the same Modbus RTU bus. Duplicate addresses can cause simultaneous responses and communication errors.
A2. CRC verifies message integrity. The controller may still be reading the wrong register, applying incorrect scaling or interpreting an unsuitable data type. Sensor calibration and measurement conditions must also be verified independently.
A3. No. Soil, weather, water quality and hydrological sensors may use different register definitions and numerical formats. Use the communication protocol supplied for the exact model and version.
A4. No. Modbus RTU is a serial protocol format using an RTU CRC field. Modbus TCP uses a different message framing arrangement over TCP/IP. A compatible gateway or conversion arrangement may be required between them.
For general Modbus function definitions, serial framing and CRC behavior, refer to the protocol specifications provided by the Modbus Organization.
The general protocol defines communication behavior, but the individual sensor manual defines its measurements, register addresses, scaling factors and supported configuration operations.
When requesting technical integration support, provide the sensor model, communication settings, receiving controller model, intended measurement channels and the actual hexadecimal request and response captured during testing.
These details allow a communication issue to be investigated more efficiently than a general report that the sensor is not working.
For RS485 soil sensors, weather stations, water quality instruments and industrial data acquisition projects, Contact NiuBoL for model-specific sensor communication protocols and compatible equipment selection.
Related recommendations
Sensors & Weather Stations Catalog
Agriculture Sensors and Weather Stations Catalog-NiuBoL.pdf
Weather Stations Catalog-NiuBoL.pdf
Agriculture Sensors Catalog-NiuBoL.pdf
Water Quality Sensor Catalog-NiuBoL.pdf
Related products
Combined air temperature and relative humidity sensor
TDR Soil Moisture & Temperature Sensor for irrigation| RS485 |4-20mA| NBL-S-THR
Soil pH sensor RS485 soil Testing instrument soil ph meter for agriculture |NBL-S-PH
Wind Speed sensor Output Modbus/RS485/Analog/0-5V/4-20mA
0.2mm Tipping Bucket Rain Gauge for Weather & Hydrology | NiuBoL
Pyranometer Solar Radiation Sensor 4-20mA/RS485
Screenshot, WhatsApp to identify the QR code
WhatsApp number:+8615367865107
(Click on WhatsApp to copy and add friends)