Modbus Explained: RTU vs TCP, Registers and BMS Integration
What Modbus is, how RTU and TCP differ, how function codes, registers and word order work, how to wire RS-485, and how to bring Modbus devices into a BMS.
Modbus is an open, royalty-free request and response protocol: a client (formerly called the master) reads and writes numbered data inside a server device (formerly the slave), such as an energy meter, a drive or a chiller controller. It runs over RS-485 serial cable as Modbus RTU or over Ethernet as Modbus TCP.
Modicon introduced Modbus in 1979, and the independent Modbus Organization has managed it since April 2004. It survives because it is simple: no names, no alarms, just registers. This guide goes deeper than our BACnet, KNX and Modbus comparison, and includes a sample energy meter register map and a troubleshooting table you can hand to your contractor.
How Modbus works: one client asks, servers answer
A Modbus network has one client that asks and one or more servers that answer. Servers never speak unless asked and never talk to each other. The client polls each device in turn. The Modbus Organization replaced master and slave with client and server in July 2020, but most manuals still use the old words.
Every request carries a function code (what to do) and data (where, and how much). On a serial line it also carries the server address, 1 to 247, and a CRC-16 checksum; address 0 is a broadcast for writes that no device answers. Over TCP the request is wrapped in a 7-byte header and sent to port 502. If a device cannot comply it returns an exception: the function code plus 0x80 and a code such as 02, illegal data address. The payload is capped at 253 bytes, which is why one read returns at most 125 registers.
Modbus RTU vs Modbus TCP
Same messages, different transport. Almost every meter and drive supports RTU; newer meters, chillers, gateways and inverters add TCP. A third mode, Modbus ASCII, is rare in buildings.
| Aspect | Modbus RTU | Modbus TCP |
|---|---|---|
| Cable | RS-485 pair plus common, daisy-chained | Ethernet and IP |
| Addressing | Server address 1 to 247 | IP address, plus a unit ID for gateways |
| Speed | 9600 and 19200 bit/s required, 19200 default | Device response time is the real limit |
| Error check | CRC-16 in every frame | Handled by TCP |
| Devices | 32 per segment without a repeater | Each device's connection limit |
| Distance | 1,000 m at 9600 bit/s with AWG26 or thicker | 100 m per copper run, more with switches |
| Port | None | 502; 802 for Modbus Security (TLS) |
RTU over TCP is not Modbus TCP
Some gateways offer RTU over TCP: serial frames sent through a TCP socket without the Modbus TCP header. It will not talk to a real Modbus TCP device. If a connection opens but every read times out, check the framing.
RS-485 wiring rules for Modbus RTU
Most Modbus faults in buildings are wiring faults. The Modbus serial line specification (V1.02) sets the first six rules; the last is field practice.
- Daisy chain, never star: one trunk from device to device, with drops under 20 m.
- Terminate both ends only: 150 ohm (0.5 W) across the pair, or 120 ohm plus 1 nF where the line is biased. Never on a drop.
- Bias at one point: one pull-up and one pull-down of 450 to 650 ohm, usually at the client. It cuts the device limit by four.
- Three conductors: the pair (D0 and D1, or A and B, and vendors disagree on which is which) plus a common, in shielded cable grounded at one point.
- Counts and lengths: 32 devices per segment without a repeater; 1,000 m at 9600 bit/s with AWG26 or thicker (AWG24 is always sufficient); Category 5 cable up to 600 m.
- Same settings everywhere: baud rate, parity and stop bits must match. The default is 19200 bit/s, even parity.
- Keep clear of drive cables: VFD motor cables are the classic noise source in plant rooms.
Modbus function codes and the four data tables
Every device is organized into four tables; the maker decides what goes where.
| Table | Size | Access | Read | Write | Typical data |
|---|---|---|---|---|---|
| Coils | 1 bit | Read and write | 01 | 05, 15 | Start/stop, enable, reset |
| Discrete inputs | 1 bit | Read only | 02 | None | Run status, alarm contact |
| Input registers | 16 bits | Read only | 04 | None | Voltage, temperature, flow |
| Holding registers | 16 bits | Read and write | 03 | 06, 16 | Setpoints, configuration, often measurements too |
One read returns up to 125 registers (codes 03 and 04) or 2,000 bits (01 and 02); one multiple write carries up to 123 registers. Code 43/14 reads device identification. Exceptions 01 (illegal function), 02 (illegal data address) and 03 (illegal data value) cover most errors; 0A and 0B come from gateways that cannot reach the device behind them.
Modbus addressing: the 40001 trap
The specification numbers registers from 1 but addresses them from 0 on the wire: holding registers 1 to 16 travel as addresses 0 to 15. Many manuals add a legacy Modicon prefix: 0xxxx coils, 1xxxx discrete inputs, 3xxxx input registers, 4xxxx holding registers. So 40001 is holding register 1, read with code 03 at address 0. Others list raw addresses, sometimes in hex. Same device, three notations.
The rule of thumb
Drop the leading 3 or 4 (it only picks code 04 or 03), subtract 1, and you have the wire address. Then prove it against a value on the device display. Off-by-one errors return plausible wrong numbers, which is worse than an error.
Data types and word order
A register holds 16 bits, high byte first. A 32-bit float or energy counter spans two registers, and the specification does not fix which comes first, so gateways offer a word-swap setting. Integers often carry a scale (2305 at 0.1 is 230.5 V) and can be signed or unsigned. What each mistake looks like:
| Registers received | Correct decode | Common wrong decode |
|---|---|---|
| 0x4366, 0x8000 | Float32, high word first: 230.5 V | Words swapped: -2.4e-41 V |
| 0x0001, 0x86A0 | Uint32, scale 0.1: 10,000.0 kWh | Words swapped: 225,863,270.5 kWh |
| 0xFC7C | Int16, scale 0.001: power factor -0.900 | Read as unsigned: 64.636 |
Where Modbus shows up in Gulf buildings
In a Saudi or Gulf commercial building, Modbus is the language of the plant room and the electrical room. Cooling dominates the bill, so the devices that matter most sit around the chiller plant:
- Energy meters: main incomers, floor and tenant sub-meters, per-unit meters in residential towers.
- Variable frequency drives on AHU fans, chilled-water pumps and cooling-tower fans: speed, power, run hours, faults. See VFDs in HVAC.
- Chillers: controllers often expose Modbus or BACnet through an optional communication card, ordered with the unit.
- Generator sets, BTU meters, solar inverters and UPS units: load, energy, run state and alarms.
In most retrofits, the data energy work needs (kWh, kW, pump and chiller status) is already sitting in Modbus registers. It is rarely missing. It is usually unmapped.
Sample register map: a three-phase energy meter
An illustrative map in the layout most meter manuals use, not copied from any manufacturer. Demand this format at submittal; real addresses come from your meter's manual.
| Register (wire address) | Code | Type | Scale | Unit | Point |
|---|---|---|---|---|---|
| 30001 (0) | 04 | Float32 | 1 | V | Voltage L1-N |
| 30007 (6) | 04 | Float32 | 1 | A | Current L1 |
| 30013 (12) | 04 | Float32 | 1 | kW | Total active power |
| 30019 (18) | 04 | Int16 | 0.001 | None | Total power factor |
| 30021 (20) | 04 | Uint16 | 0.01 | Hz | Frequency |
| 30073 (72) | 04 | Uint32 | 0.1 | kWh | Imported active energy |
| 40001 (0) | 03, 06 | Uint16 | 1 | A | CT primary rating (configuration) |
| 40011 (10) | 03, 06 | Uint16 | 1 | None | Modbus address setting |
Two traps are built in. Measurements sit in input registers (code 04) and configuration in holding registers (code 03), and the CT rating is writable: a BMS that writes the wrong value there silently corrupts every later energy reading. A good map also states word order and writable points.
Modbus security: assume anyone on the network can write
Classic Modbus has no authentication or encryption. Anything reaching port 502 can read every register and write any writable one: a drive speed, a chiller setpoint, a CT ratio. The Modbus Organization announced Modbus Security in 2018: the same messages inside TLS, X.509v3 certificates on both sides, role-based authorization and port 802. Many installed devices predate it, so protection comes from network design:
- Put Modbus TCP devices on a separate network and allow port 502 only from the BMS or gateway.
- Never forward port 502 to the internet; use a managed VPN for remote access.
- Map points read-only by default and enable writes only for named points.
- Change gateway default passwords and log every write.
Modbus trusts everyone who can reach it. Your network design decides who that is.
Integrating Modbus into a BMS: gateways and point maps
Three common paths: a BMS controller with a Modbus driver polls devices directly; a Modbus-to-BACnet gateway presents each register as a BACnet object; or supervisory software reads Modbus TCP devices over the network. All three depend on the point map: for every point, the device, address, register, code, data type, word order, scale, unit, read or write, poll rate and BMS name.
Plan polling on serial lines. At 9600 bit/s and 11 bits per character, a full 125-register reply (255 bytes) takes about 0.3 seconds on the wire alone. Read neighboring registers in one block request, not one by one. Size the job early with the BMS points budget estimator. In our audits we document what speaks BACnet, what speaks Modbus, and what speaks nothing standard at all; our BMS solutions page shows how that becomes one vendor-neutral layer, and multi-vendor BMS integration covers mixed brands.
What to put in your tender
- Register maps for every Modbus device in the submittal, with data types, word order and scales.
- A complete point map at handover, in an editable format the owner keeps.
- An address and IP plan with spare addresses for future meters.
- Modbus TCP on a segregated network, with writes disabled unless listed.
- A commissioning sheet comparing each point with the device display.
Troubleshooting Modbus: symptom, cause, fix
| Symptom | Likely cause | Fix |
|---|---|---|
| No device answers | Baud, parity or stop bits differ; pair reversed | Match settings everywhere; swap the data wires |
| One device never answers | Wrong or duplicate address | Unique address per device, 1 to 247 |
| Exception 02 | Off-by-one, or 40001 sent as an address | Drop the prefix, subtract 1, test a known value |
| Exception 01 | Code 03 on input registers, or no code 16 support | Use the manual's code; single writes with 06 |
| Absurd float such as -2.4e-41 | Word order swapped | Toggle word swap, compare with the display |
| Energy counter stops at 65,535 | Only half of a 32-bit pair read | Read both registers in one request |
| Random CRC errors and timeouts | Missing termination, star wiring, drive noise | Terminate, daisy chain, reroute, bias once |
| Gateway exception 0B | Device behind the gateway silent | Check serial address, wiring and gateway timeout |
What is the difference between Modbus RTU and Modbus TCP?
Same messages, different transport. RTU runs over RS-485 serial cable with a server address and a CRC check. TCP runs over Ethernet on port 502 with a 7-byte header. A gateway converts between the two.
Is Modbus the same as RS-485?
No. RS-485 is the electrical layer, the wires and voltages. Modbus RTU is the protocol that runs on it. Other protocols, such as BACnet MS/TP, also use RS-485.
Why does register 40001 become address 0?
40001 is a legacy notation. The 4 means holding register (read with code 03), and registers are numbered from 1 while wire addresses start at 0. So 40001 is holding register 1 at address 0.
Is Modbus better than BACnet?
They do different jobs. Modbus moves raw numbers with no names, alarms or schedules. BACnet describes objects, alarms and schedules for a whole building. Most buildings use both: Modbus at the device, BACnet above it.
More from puniq
What Is SCADA? Components, Protocols and Security Explained
SCADA explained for owners: components, how it differs from DCS and BMS, the protocols, where it meets Gulf buildings, and an IEC 62443 and NCA OTCC security checklist.
7 min readWhat Is MQTT? A Practical Guide to MQTT and IoT in Buildings
MQTT explained for building owners: broker, topics, QoS, retained messages, MQTT 5, Sparkplug B and security, with a sample topic namespace and an architecture checklist.
7 min readKNX Explained: How a KNX System Works in Villas and Buildings
What KNX is, how the bus, group addresses and ETS work, what KNX Secure protects, how KNX links to a BMS, what drives cost, plus a sample villa plan.
7 min readPut this into practice
Talk to puniq's engineers about a vendor-neutral path for your building.