ESP32 Bit Pirate home
  • Modbus
  • Intermediate
  • 5 min
  • Network

Recipe · Intermediate · Modbus

How to open a Modbus TCP session

Wi-Fi and Ethernet modes both document a modbus <host> [port] command that opens an interactive Modbus session.

Modbus TCP connection to a local device.
Useful for lab PLCs, gateways and local devices where you are authorized to test.
Step 1

Commands

Connect the network interface, confirm status, then open the Modbus session.

Result

What success looks like

The session opens after network status is valid. If it fails, debug IP, port and firewall before assuming a Modbus issue.

Troubleshooting

  • Wrong TCP port or service not listening.
  • Wi-Fi/Ethernet not connected before launching Modbus.
  • Firewall allows ping but blocks the Modbus port.
  • Device uses a serial Modbus gateway, not direct Modbus TCP.

Next steps

  • Use ping <host> before opening Modbus.
  • Use nmap <host> -p 502 on authorized lab targets to check the port.
  • Prefer Ethernet for stable bench testing when Wi-Fi is noisy.

Modbus TCP session FAQ

When should I use Modbus TCP from Bit Pirate?

Use it for quick field checks against a known Modbus TCP device, such as verifying that port 502 is reachable and exploring coils, inputs or holding registers.

Why start with Ethernet for Modbus?

Many industrial or lab Modbus devices are wired, isolated from Wi-Fi, or easier to reach through a W5500 bench interface. Wi-Fi also works when the target network is available.

What should I avoid on an unknown Modbus device?

Avoid writes until you know the register map and the equipment is safe to test. Start with status, port checks and read-only operations on devices you are authorized to access.

Go deeper