Testing a Modbus TCP connection
Step 1: Install a Modbus client
You need a tool to connect to and browse your Modbus TCP device. Here are some free and common options:
Each client lets you manually connect to a Modbus TCP device, specify a unit ID (slave ID), function code, register address, and data type, then read or write values.
Step 2: Prerequisites
Before testing, make sure you:
- Know the Modbus slave address (unit ID). Valid slave addresses are 01 to F7 (1 to 247). Address 00 is the broadcast address and is write-only, so it cannot be used to read.
- Know the register address and data type you want to read.
Example: Reading a 32-bit float from register 40001 on slave 01.
Step 3: Test the connection
- Open your chosen Modbus client.
- Enter the IP address and TCP port (default 502).
- Specify:
- Slave ID: e.g. 01
- Function code: typically 3 (Read Holding Registers)
- Start address: e.g. 40001
- Quantity: number of registers to read
- Click Connect or Read to view the result.
Troubleshooting Modbus TCP connection
1. Slave ID format
- The Slave ID in the collector is in hexadecimal notation, not decimal. Example:
- Device ID shown as 10 decimal = 0x0A hex.
- Use an online converter
Slave IDs must always be two digits. For example, 0A instead of A.
2. Unknown Slave ID
If the slave ID is not known:
- Set FF (255). In Modbus TCP this is the unit ID for a device that is addressed directly rather than through a gateway, so a single connected device answers on it.
- The device answers with its own data, which confirms the connection before you know its real unit ID.
Use FF only if one device is connected. A Modbus TCP gateway fronting several serial slaves needs the real unit ID of each one.
Never use FF on a gateway fronting several slaves: it does not address any one of them. Broadcast (00) is write-only and never returns a reply, so it cannot be used to test a connection either.
3. 1-based vs 0-based addressing
- The Go Modbus library used by the collector uses 0-based indexing.
- Example: If documentation says register 1006, use address 1005 in the collector configuration.
4. Modbus TCP vs Modbus RTU
- The Factry Modbus collector supports Modbus TCP only.
- If you have a Modbus RTU (serial) device, use an external TCP-to-RTU gateway or bridge software. Example: Moxa MB3180 or ModbusPal emulator.