Skip to content
LSLab

How Does Modbus RTU Exchange Data?

  • Basic
  • Article
  • Ages 15+
  • 4 min read
An industrial controller and a DIN-rail digital meter are connected by cable on a test bench.

Modbus RTU is how devices exchange data by request and response: a master sends a request; a slave normally answers a valid unicast, while slaves should not reply to broadcasts. The data travels in binary and messages are split by silent gaps on the line.

Contents
Unicast example: the master sends a request and receives a response.
  • Master
  • Slaves

What you will learn

Before you start

It helps to know what UART and differential signals are.

How does Modbus ask and answer?

Modbus is a request-response protocol implemented using a master-slave relationship. The initiating device, the master, is responsible for initiating every interaction. A conversation is always started by a master in the network.

For unicast, the address identifies the receiving slave; the other slaves ignore that request. A slave normally replies to a valid unicast request sent to its address. Address 0 is the broadcast address: slaves should process a valid write request sent to it, and none should reply.

For a unicast request, only the slave with the matching address replies.
  • Master
  • Slave with the matching address
  • Request
  • Response

What parts does a Modbus RTU message have?

With Modbus RTU the data is exchanged in a binary format, where each byte of information is coded in one communication byte. A message holds an address, a function code, data and an error check.

Modbus masters must request access to the slave's data through various function codes. Not all Modbus devices recognize the same set of function codes.

A message holds an address, a function code, data and an error check.
  • Address
  • Function code
  • Data
  • Error check

When answering, a slave normally uses the same function code as in the request. In an exception response, the most significant bit of the original function code is set. An error check is appended so the receiver can check whether a communication error occurred.

How does a receiver know a message has ended?

Modbus RTU uses time gaps of silence on the communication line for framing. So each message has to be sent as a continuous stream; gaps between characters must stay below the framing threshold.

A device configured for Modbus ASCII cannot understand Modbus RTU messages and vice versa, so both sides must use the same mode.

The silent gap tells the receiver that a message has ended.
  • Silent gap
  • One continuous message

Real-world example

With an adult, think of an electricity meter in a building. The monitoring system asks the meter for a value, and only the meter with the right address answers.

Common misunderstandings

A slave can send data whenever it wants. A conversation is always started by a master.

Every Modbus device understands every function code. Not all devices recognize the same set of function codes.

Frequently asked questions

How do master and slave differ?

The master initiates a request; a slave normally replies to a valid unicast request sent to its address. No slave should reply to broadcast address 0.

What is in a Modbus RTU message?

An address, a function code, data and an error check.

What does a function code with its highest bit on mean?

In an exception response, the most significant bit of the original function code is set.

How does Modbus RTU mark frames?

With time gaps of silence on the communication line.

Summary

Terms in this article

English and Vietnamese terms, with the meanings used here. Hover, tap or Tab to a term with a dotted underline for an explanation as you read.

Modbus RTU
The Modbus mode that sends binary data and marks frames with silent gaps on the line.
Master and slaveMaster và slave
The master initiates requests; a slave normally responds to valid unicast, while slaves should not reply to broadcasts.
Function codeMã chức năng
A code in the message telling which operation the master wants the slave to perform on data.
Message addressĐịa chỉ trong bản tin
A field identifying the recipient of a unicast request; address 0 is for broadcast.
Error checkKiểm tra lỗi
A part appended to a message so the receiver can detect a communication error.

This article is not marked as viewed

Spotted something wrong or unsafe?

Tell the administrator by email. The message already has the article title and address.

Report this article
  • A compact microcontroller board with a metal shield is wired to a temperature sensor.
    Basic

    How Does an ESP32 Board Run and Communicate?

    An ESP32 board pairs an ESP32 module with a USB port and pin headers. See its parts, how firmware is loaded over serial, and its Wi-Fi and Bluetooth.

    Internet of Things (IoT)4 min read
  • A microcontroller development board is connected by USB with its amber status LED illuminated.
    Basic

    How Does Arduino Run setup and loop?

    An Arduino sketch has two functions: setup runs once and loop repeats forever. See the run order, why loop never pauses and what delay does.

    Internet of Things (IoT)4 min read
  • A microcontroller board connects by USB to a laptop, with a wireless router behind it.
    Starter

    Overview of Firmware and IoT Networking

    An overview of IoT firmware, the setup and loop cycle, how MQTT sends messages over a network, and security guidance published by NIST.

    Internet of Things (IoT)4 min read
  • An air-quality sensor, two-antenna Wi-Fi gateway and tablet are arranged together on a lab bench.
    Basic

    How Does MQTT Route Messages Through a Broker?

    MQTT is a publish and subscribe protocol: a broker takes messages by topic and passes them to subscribers. Covers topics, wildcards and three QoS levels.

    Internet of Things (IoT)4 min read
See all articles of the topic

Sources

These sources are written for older readers. If they feel hard, read them with an adult.