PyModbus Docs
Python library for Modbus TCP and RTU communication. Connect to PLCs, sensors, and industrial devices with clean synchronous and async APIs.
PyModbus connects Python to any Modbus device: PLCs, power meters, temperature sensors, VFDs, building controllers. It supports TCP (Ethernet), RTU (serial RS485/RS232), and ASCII protocols with the same API.
from pymodbus.client import ModbusTcpClient
client = ModbusTcpClient('192.168.1.100')
client.connect()
result = client.read_holding_registers(0, 10, slave=1)
if not result.isError():
print(f"Registers: {result.registers}")
client.close()Get Started
Installation
pip install, conda, serial extras, virtual environments
Quick Start
Connect, read registers, write values, close
Basic Concepts
Function codes, data model, addressing, byte order
Clients
TCP Client
Ethernet connections, timeouts, context managers
RTU Client
Serial RS485/RS232, baud rates, multi-slave polling
Async Client
async/await for high-throughput polling
Reference
Function Codes
Read/write coils, holding and input registers
Data Types
Floats, strings, and multi-register values
Error Handling
Exception codes, retries, connection recovery
Community & Support
Join the Discord community for help, discussions, and to connect with other developers using PyModbus.