Blog

Modbus Unit ID (Slave ID): Valid Range, ID 0, 247 and 255 Explained

2026-11-06 · 13 min read Modbus unit IDslave IDModbus TCPModbus RTUtroubleshooting

Short answer

The Modbus unit ID (also called slave ID or slave address) is one byte that says which device should answer. On Modbus RTU, 1 to 247 are the device addresses, 0 is broadcast (writes only, no reply) and 248 to 255 are reserved. On Modbus TCP the IP address already picks the device, so a plain TCP device usually accepts 255, 0 or 1, while a TCP-to-RTU gateway needs the real slave ID (1 to 247) of the serial device behind it.

The wiring is right, the baud rate matches, the IP address pings, and still: no response. Very often the problem is one small number: the Modbus unit ID, also called the slave ID, slave address or device address.

This guide explains the valid range (1 to 247), what unit ID 0 and 255 really mean, how gateways use the field, and how to find an unknown slave ID in seconds, with real screenshots of ModLens reading the free ModLens Sim.


What is a Modbus unit ID?

The Modbus unit ID is a single byte at the start of every request that says which device must answer. On an RS-485 bus, every device hears every request, and only the one whose address matches replies. On Modbus TCP, the same byte is called the Unit Identifier and is mostly used by gateways.

Manuals use several names for the same field:

Name in the manual Where you usually see it
Slave ID, slave address Older RTU devices, PLC software, Modbus Poll-style tools
Unit ID, unit identifier Modbus TCP devices, gateways, the TCP specification
Device address, node address, station number Energy meters, VFDs, HVAC controllers
Server address Newer Modbus documents (the protocol now says client/server instead of master/slave)

If a VFD manual says "communication address 3", type 3 as the unit ID.

Where the unit ID sits in the frame

On Modbus RTU (serial), the request frame is: address (1 byte) + function code + data + CRC (2 bytes). The address is the first byte the device reads. If it is not its own address (or 0), the device ignores the rest.

On Modbus TCP, the request starts with the 7-byte MBAP header: transaction ID (2 bytes), protocol ID (2 bytes, always 0), length (2 bytes) and unit identifier (1 byte), then the function code and data. There is no CRC.

A real example: reading 12 holding registers from address 0 on unit 1 looks like this.

Variant Bytes (hex)
Modbus RTU 01 03 00 00 00 0C + CRC
Modbus TCP 00 01 00 00 00 06 01 03 00 00 00 0C

In both, the 01 before the function code 03 is the unit ID.


What is the valid Modbus slave ID range?

On Modbus RTU, device addresses run from 1 to 247. Address 0 is the broadcast address and 248 to 255 are reserved. This comes from the MODBUS over Serial Line Specification and Implementation Guide V1.02 published on modbus.org.

Unit ID Meaning on Modbus RTU (serial) Typical use on Modbus TCP
0 Broadcast: every slave executes the request, none replies Often accepted as "this device" by plain TCP devices; check the manual
1 to 247 Individual device addresses The slave ID of the serial device behind a gateway; many TCP devices also answer on 1
248 to 255 Reserved 255 (0xFF) is the value the TCP guide recommends when the unit ID is not used

Some manufacturers use 248 to 255 for their own purposes, but a device on a standard bus should stay in 1 to 247.

How many devices can you put on one bus?

247 is the address limit, not the wiring limit. A standard RS-485 segment (TIA-485) is designed for 32 unit loads, and the Modbus serial specification gives 32 devices per bus without repeaters. Fractional-load transceivers allow more; check each datasheet. Wiring rules are in the Modbus RS-485 wiring guide.


Modbus unit ID 0: broadcast

Unit ID 0 is the broadcast address on Modbus RTU: every device carries out the request, and no device replies. Because nobody answers, the serial specification only allows broadcast for write requests, such as one setpoint or clock sync sent to every device at once. A read with unit ID 0 on a serial bus always times out.

On Modbus TCP, unit ID 0 does not reliably mean "broadcast". Many plain TCP devices simply answer it as if it were their own address, and the TCP implementation guide accepts 0 for talking directly to a TCP device. A gateway may treat it as a broadcast to the serial side, refuse it, or answer for itself. This varies by product, so read the gateway manual before sending writes to unit 0.


Modbus unit ID 255 (0xFF)

Unit ID 255 means "not used" on Modbus TCP. The MODBUS Messaging on TCP/IP Implementation Guide explains that on TCP the server is found by its IP address, so the unit identifier has no job when you talk directly to a TCP device. It recommends 0xFF as the value in that case. The reason is safety: if that IP address is later given to a gateway, a request with 255 will not be sent by mistake to some serial device behind it.

In real life, behaviour is mixed:

  • Many plain TCP devices accept any unit ID and echo it back.
  • Some accept only specific values (for example only 1, or only 255), or only the ID set in their configuration.
  • Some gateways reject 255, because it is not a valid serial address. They need 1 to 247.

So 255 is the "official" choice for a direct TCP device, and 1 is a very common default in device manuals. If one does not work, try the other, then 0.


How does the unit ID work with a Modbus TCP gateway?

Behind a gateway, the unit ID selects which serial device the gateway talks to. The gateway receives a Modbus TCP request, reads the unit identifier, and sends an RTU request with that same address on its RS-485 port. The reply comes back the same way.

Your PC  --TCP, unit ID 5-->  Gateway 192.168.1.50  --RTU, address 5-->  Meter at slave ID 5

That means:

  1. The IP address is the gateway's, not the meter's.
  2. The unit ID must be the serial slave ID of the meter, in 1 to 247.
  3. Two meters behind one gateway share one IP and differ only by unit ID.

When the serial device does not answer, a good gateway replies with a Modbus exception instead of staying silent:

Exception Name in the Application Protocol V1.1b3 What it usually means
0x0A (10) Gateway path unavailable The gateway has no route for that unit ID (often a mapping or port setting)
0x0B (11) Gateway target device failed to respond The gateway asked the serial device and got no answer: wrong slave ID, baud rate, parity or wiring

Exception 11 tells you the TCP side works and the problem is on the RS-485 side. More on gateways in Modbus RTU over TCP vs Modbus TCP: gateways explained.


How to find a Modbus slave ID you don't know

The fastest way to find an unknown unit ID is to scan: ask IDs 1 to 247 one by one and keep the ones that answer. Any answer counts, including an exception. A device that replies "illegal data address" has just told you it exists at that ID.

Before scanning, check the cheap sources first:

  • The device display or setup menu (often under "Comm", "Modbus", "RS-485" or "Address").
  • DIP switches or rotary switches on the board. Some use binary DIP switches, where switch 1 = 1, switch 2 = 2, switch 3 = 4, and so on. Check the manual, because some count the other way.
  • The commissioning sheet or the BMS / PLC program that already talks to it.
  • The factory default in the manual. Many devices ship with ID 1, which is also why duplicates happen.

If none of these works, scan. Here is the method with ModLens. You can follow it on your own laptop with the free ModLens Sim, which simulates three devices on one TCP port: unit 1 is an AHU controller, unit 2 a power meter and unit 3 a tank and weather station.

Step 1: Scan the unit IDs

Open Scanner, go to Find unit IDs (slave addresses), choose the device or bus, set From and To, and click Scan.

ModLens Scanner, Find unit IDs card: range 1 to 10 on the ModLens Sim connection, done in 7.5 s, 3 found: unit 1 answers holding 0 = 145, unit 2 responds with Illegal data address, unit 3 answers holding 0 = 645

The scan of IDs 1 to 10 took 7.5 seconds and found three devices:

  • Unit 1 answered holding register 0 with 145.
  • Unit 2 answered with Illegal data address. It has no holding register 0, but it is clearly there.
  • Unit 3 answered holding register 0 with 645.

IDs 4 to 10 stayed silent; each silent ID costs one full timeout, which is most of the 7.5 seconds.

Step 2: Read the first device

Open Explorer, type the Unit ID found in step 1, choose the table and click Read.

ModLens Explorer reading unit ID 1, holding registers 0 to 11: address 0 = 145, addresses 1-2 decode to 21.94 as float32 ABCD, addresses 5 to 9 do not exist

On unit 1 (the AHU controller), holding register 0 is 145, which is the supply air temperature 14.5 °C stored as int16 ×0.1. Registers 1 and 2 decode to 21.94 as float32 ABCD: the return air temperature. Addresses 5 to 9 "don't exist on this device", which is a normal gap in the map.

Step 3: Same IP, different unit ID, different device

Now change only the unit ID to 2, switch the table to Input registers (3x) and read again.

ModLens Explorer reading unit ID 2, input registers 0 to 11 on the same IP and port: addresses 0-1 decode to 230.3 as float32 CDAB, addresses 2-3 to 10, addresses 4-5 to 6.9

Same IP address, same port 5020, but a completely different device: the power meter. Input registers 0-1 decode to 230.3 as float32 CDAB (the voltage), 2-3 to 10 (current) and 4-5 to 6.9 (active power). This is exactly what happens behind a gateway: the IP picks the gateway, the unit ID picks the device.

Step 4: Recognise a wrong unit ID

Type unit ID 5, which nothing on this connection uses, and read.

ModLens Explorer with unit ID 5: red box "No response from unit 5 (timeout)" with tips to try unit ID 1, 0 or 255, close other software, and increase the timeout

ModLens shows No response from unit 5 (timeout). The IP answered, but nobody replied for that unit ID. A wrong slave ID looks like this: silence, not an error message.

Step 5: Don't know the ID or the register? Search by value

If you can see a value on the device display but know neither the unit ID nor the register, use Find a value. Enter the number shown, put a range of unit IDs (for example 1-5) and click Search.

ModLens Find a value: 230.6 searched on unit IDs 1-5, holding and input registers 0 to 199, done in 4 s, 2 found: unit 2 input 0 float32 CDAB = 230.6, and unit 2 input 1 float32 ABCD = 230

The voltage on the display read 230.6. ModLens searched units 1 to 5, holding and input registers 0 to 199, in 4 seconds. The best match is unit 2, input register 0, float32 CDAB = 230.6. The second line (230 as float32 ABCD at address 1) is a weaker match; change the value or wait for it to move and click Re-check candidates to keep only the real register. More on this method in how to find a Modbus register address.

You can try all of this with the free 14-day trial; the step-by-step screens are also in the install and user guide.


How long does a unit ID scan take?

A full scan takes roughly (number of silent IDs) × (timeout). Devices that answer are fast; silent IDs each wait for the full timeout. Some worked numbers:

Range scanned Timeout Worst case (no device answers)
1 to 247 1 s about 247 s, a little over 4 minutes
1 to 247 0.3 s about 74 s
1 to 247 0.2 s about 49 s
1 to 20 0.2 s about 4 s

On a local RS-485 bus, 0.2 to 0.3 s is usually safe for a scan. Through a gateway, radio link or slow device, keep 1 to 3 s or you will miss slow devices. Restore the normal timeout afterwards.

Scan 1 to 20 first; scan the full 1 to 247 only if that fails.

On RTU, a scan only works if baud rate, parity and stop bits match. If nothing answers at any ID, suspect the serial settings or wiring, not the ID.


How do you change a device's unit ID?

You change the slave ID on the device itself: in its menu, with DIP or rotary switches, or with the vendor's configuration software. Some devices also let you write a new address into a holding register over Modbus.

List the IDs already used, set the new device's ID before wiring it in, power-cycle if needed, then confirm with one read. If the address can be written over Modbus, read the manual twice before doing it. Writing the wrong register, or setting an ID that is already used, can take a device off the bus until someone goes on site.


Common mistakes and troubleshooting

Two devices with the same unit ID

The most common unit ID fault on RS-485: both devices answer at once, their replies collide, and you get CRC errors or intermittent timeouts, typically right after adding a new device still at factory ID 1. Fix: disconnect devices one at a time until the errors stop, or check each device's menu, then give each one a unique ID.

Using the IP address's last number as the unit ID

On plain Modbus TCP, the unit ID has nothing to do with the IP address. A device at 192.168.1.23 does not need unit ID 23. Use what the manual says (often 1 or 255).

Unit ID 255 rejected by a gateway

If a gateway replies with an exception or nothing at unit 255, it wants a real serial address. Use the slave ID of the device behind it (1 to 247).

Device answers in its own software, not in yours

Some devices accept only one TCP connection, or only one master on the serial bus. If the vendor tool or the BMS is still connected, close it before scanning. Two masters on one RS-485 bus will also corrupt each other's frames.

Quick diagnosis table

What you see Most likely cause What to try
Timeout at one ID, others answer Wrong unit ID for that device Scan 1 to 247, check the device menu
Timeout at every ID (RTU) Serial settings or wiring Baud/parity, swap A/B, COM port: see Modbus TCP vs RTU
Exception 11 from a gateway Gateway OK, serial device silent Slave ID, gateway serial settings, RS-485 wiring
Exception 10 from a gateway No route for that unit ID Gateway mapping / port configuration
CRC errors, random garbage Duplicate unit IDs or wiring noise Look for two devices with the same ID
Exception 2 Device found, register missing Check address offset and table: see exception code 2

FAQ

What is the difference between unit ID and slave ID in Modbus?

There is no difference. "Slave ID" and "slave address" are the traditional names on Modbus RTU; "unit identifier" is the name used in the Modbus TCP header. Both are the same one-byte field that selects which device answers.

What is the valid range for a Modbus slave ID?

On Modbus RTU, individual devices use 1 to 247. Address 0 is broadcast and 248 to 255 are reserved, according to the Modbus serial line specification. On Modbus TCP, the field can hold 0 to 255, but behind a gateway it must still be the serial address of the target device, in 1 to 247.

What does Modbus unit ID 0 do?

On Modbus RTU, unit ID 0 is broadcast: every device executes the request and none replies, so it is only used for writes. On Modbus TCP, many plain devices treat 0 as "this device" and answer normally, while gateways handle it in different ways. Check the device or gateway manual before relying on it.

What does Modbus unit ID 255 mean?

On Modbus TCP, 255 (0xFF) is the value the official TCP implementation guide recommends when you talk directly to a TCP device and the unit ID is not needed. Many TCP devices accept it, but some gateways reject it because it is not a valid serial address. On a serial bus, 255 is in the reserved range and should not be used as a device address.

What unit ID should I use for a Modbus TCP device?

Use the value in the device manual. If the manual says nothing, try 1 first, then 255, then 0, because these are the values TCP devices most often accept. If the device is a gateway to RS-485 devices, use the slave ID of the serial device you want to read.

Can two Modbus devices have the same unit ID?

Not on the same RS-485 bus: both would answer and their replies would collide, causing CRC errors or timeouts. Devices on different buses or behind different gateways can share an ID, and two TCP devices with different IP addresses can both use unit ID 1.

How do I find the slave ID of a Modbus device?

First look at the device display, its DIP or rotary switches, or the commissioning documents. If that fails, use a unit ID scanner: it sends a short read to each ID from 1 to 247 and lists the ones that answer, including those that answer with an exception. Lower the timeout to about 0.2-0.3 s to scan faster.

Why does my Modbus device answer in one tool but time out in another?

The two tools are often using different unit IDs (for example 0 in one and 1 in the other), or the device only accepts one connection and the first tool is still connected. Check the unit ID, the timeout and the address offset in both tools, and close the other software before testing.