(Smart Irrigation RS485-Modbus-RTU)
This document details the Modbus-RTU and 4G-MQTT communication protocols for solar-powered smart motorized UPVC ball valves used in modern agricultural and commercial irrigation systems. The system operates in a Master-Slave polling architecture, where the Master acts as the main irrigation controller or cloud platform, and the Slave corresponds to individual valve actuators.

1. Physical Layer Specifications
- Physical Interface: RS485, Differential Signals A & B, Common Ground (GND).
- Baud Rate: 9600 bps (default). Data Bits: 8, Stop Bit: 1, Parity: None.
- Slave Address Range: 1–247 (Address 0 is reserved for broadcast).
- Network Topology: Supports up to 32 nodes per RS485 bus. Requires 120Ω termination resistors installed at both physical ends of the line.
2. Protocol Layer (Modbus-RTU)
Frame Structure:
Slave Address (1 Byte) + Function Code (1 Byte) + Data Field (N Bytes) + CRC16 Low Byte + CRC16 High Byte
Supported Function Codes
| Function Code | Description |
| 0x03 | Read Holding Registers (reads valve status, operating voltage, fault codes) |
| 0x06 | Write Single Register (sends open, close, or stop execution commands) |
| 0x08 | Diagnostic Commands |
3. Register Mapping (Holding Registers)
Note: Register addresses are listed in standard 4x decimal notation.
| Register Address | Register Name | Read/Write | Description & Scale |
| 40001 | Control Command | Write | 1 = Open Valve; 2 = Close Valve; 3 = Stop Movement |
| 40002 | Actual Valve Status | Read | 0 = Unknown; 1 = Fully Open; 2 = Fully Closed; 3 = Opening; 4 = Closing; 5 = Fault |
| 40003 | Supply Voltage | Read | Scale: 0.1V (e.g., 240 corresponds to 24.0V DC) |
| 40004 | Fault Code | Read | 0 = Normal; 1 = Overcurrent; 2 = Timeout/Jammed; 3 = Motor Fault; 4 = Communication Error |
| 40005 | Slave Address | Read/Write | Range: 1–247. Address updates take effect immediately. |
| 40006 | Baud Rate Setting | Read/Write | 1 = 9600 bps; 2 = 19200 bps; 3 = 38400 bps |
4. Communication Command Examples (Slave Address = 01)
1) Send Open Valve Command (Write Register 40001 = 1)
- Master Send (TX):
01 06 00 00 00 01 D9 CA - Slave Response (RX):
01 06 00 00 00 01 D9 CA
2) Send Close Valve Command (Write Register 40001 = 2)
- Master Send (TX):
01 06 00 00 00 02 99 CA - Slave Response (RX):
01 06 00 00 00 02 99 CA
3) Read System Parameters (Read 4 Registers: 40001–40004)
- Master Send (TX):
01 03 00 00 00 04 44 09 - Slave Response (RX):
01 03 08 00 01 00 01 00 F0 00 00 XX XX
Data Frame Parsing:
- Control Command =
1(Open Command Active) - Valve Status =
1(Fully Open) - Supply Voltage =
240(24.0V) - Fault Code =
0(Normal Operation)

5. 4G-MQTT Cloud Protocol Extension (Wireless Variant)
- Uplink Transmission: The actuator periodically reports operational status, battery voltage, and fault codes. Reporting interval is configurable between 30 to 300 seconds.
- Downlink Transmission: The cloud platform sends structured JSON formatted control frames.
Downlink Command Structure:
{“devId”:”V001″,”cmd”:1}(cmd parameter definitions: 1 = Open, 2 = Close, 3 = Stop)
Uplink Telemetry Structure:
{“devId”:”V001″,”valveState”:1,”voltage”:24.0,”errCode”:0}
6. Fault Handling and Timeout Policy
- Host Request Timeout: If the Master sends a request and receives no response within 500ms, the request is flagged as timed out. The Master may retry up to 2 times before marking the node offline.
- Action Timeout: The normal travel time for full valve opening or closing is 15 seconds max. If target limit switches are not engaged within 15 seconds, a “Jammed/Mechanical Fault” code is raised.
- Malformed Frames: Any invalid or corrupted frames detected on the RS485 bus are silently dropped by the slave without generating a response.

7. Deployment Guidelines and Responsibilities
- Hardware Vendor: Ensure strict compliance with the defined register map, deliver standard RS485 differential signals, and supply devices with factory default settings (Address
1, Baud Rate9600). - System Integrator: Implement compliant Modbus-RTU Master software logic, including proper handling of system timeouts, retry counts, and status error code parsing.
- Field Installation: Ensure polarity alignment on lines A and B. Shielded Twisted Pair (STP) cabling must be used for long-distance outdoor deployments to protect against industrial noise and ground loops.