Category Archives: Modbus Protocol

Modbus Parity and Character Format

On a Modbus serial line, every byte you send is wrapped in a few extra bits before it hits the wire. Those extra bits — the start bit, an optional parity bit, and one or two stop bits — make up the character format. Get them wrong on one device and it won’t talk to the rest of… Read More »

Modbus Unit Identifier Explained: Unit ID by Scenario

You just installed a Modbus TCP device. The manual says “set Unit ID to 1.” Your PLC configuration asks for a Unit ID. Another device manual says “Unit ID is ignored.” A third says “Unit ID must be 0xFF.” What is going on? Which one is right? All of them are right. The Unit Identifier — usually called… Read More »

Modbus Client-Server vs Master-Slave Terminology

You just downloaded a new device manual and it says “Modbus client” and “Modbus server.” Your RS-485 documentation says “master” and “slave.” Your PLC code has variables named slaveId. Which is right? Do you need to change your code? Are these different protocols? Short answer: no. The protocol is identical. The terminology depends mostly on the transport you… Read More »

Modbus Broadcast Function Codes: Address 0 Explained

Does anyone actually use Modbus broadcast? Some do. Most engineers go their whole careers without touching it. Broadcast is one of those Modbus features that lives in the corner of the spec, gets one or two paragraphs in most books, and shows up unexpectedly when you have to commission a large multi-drop bus at 3 AM. This article… Read More »

Modbus TCP MBAP Header Explained: 7 Bytes Byte by Byte

Every Modbus TCP packet starts with 7 bytes called the MBAP header (Modbus Application Protocol header). Those 7 bytes are what turn Modbus from a serial protocol into a network protocol. Get them right and everything works. Get them wrong, and the server may ignore the request, close the connection, or return an exception. This article decodes a… Read More »

Modbus TCP Security Explained: TLS on Port 802

Standard Modbus TCP has zero security. No authentication. No encryption. No integrity checks. Anyone who can reach TCP port 502 can issue Modbus requests. Depending on the device configuration, this may allow reading registers, writing coils or registers, changing operating parameters, or disrupting industrial processes. For decades, the answer was “put it behind a firewall and hope for… Read More »

Modbus Byte Order and Word Order: Fix Your 32-Bit Values

You read a float from a Modbus device. The value should be 25.3 degrees Celsius. You get 1.3 × 10³⁸. Or maybe -8.5 × 10⁻⁴¹. Or something that swings wildly between reasonable and absurd every time you re-read. Welcome to Modbus byte and word order. It is the single most common headache when you connect a new device.… Read More »

Modbus Function Codes Explained with Real Examples

Every Modbus message contains a function code. It is a single byte that tells the slave device what operation to perform — read coils, write registers, or diagnose communication. The Modbus specification defines multiple function codes, but in practice you will use about six of them for 95% of your tasks. The rest are either rarely implemented, vendor-specific,… Read More »