When working with industrial automation, IoT sensors, or PLC communication, the Modbus protocol remains one of the most widely used standards for device interoperability. Python, with its rich ecosystem and simplicity, has become a go-to language for building Modbus clients, servers, and gateways.
But with multiple Python Modbus libraries available — PyModbus, MinimalModbus, pyModbusTCP, Modbus-tk, and others — it can be confusing to choose the right one.
This guide provides a comprehensive comparison of Python Modbus libraries to help you select the best fit for your project, whether you’re building a small data logger or a large-scale SCADA system.
Table of Contents
What Is Modbus and Why Use It with Python?
Modbus is a master–slave (or client–server) communication protocol originally developed in 1979 by Modicon (now Schneider Electric). It’s commonly used for communication between:
- PLCs (Programmable Logic Controllers)
- RTUs (Remote Terminal Units)
- Sensors and meters
- SCADA systems
Why Python?
Python is popular in industrial automation for its:
- Rapid prototyping and readability
- Cross-platform deployment (Windows, Linux, Raspberry Pi)
- Integration with analytics, visualization, and IoT platforms
- Mature Modbus libraries with both TCP and serial (RTU/ASCII) support
Top Python Modbus Libraries
Here are the most popular and actively maintained libraries as of 2025:
| Library | Protocols | Async Support | License | Use Case |
|---|---|---|---|---|
| PyModbus | RTU, TCP, UDP | Yes (asyncio) | BSD | Full-featured client & server applications |
| MinimalModbus | RTU, ASCII | No | MIT | Lightweight, simple serial clients |
| pyModbusTCP | TCP only | Partial (threaded) | MIT | Pure TCP client/server |
| Modbus-tk | RTU, TCP | No | LGPL | Educational and synchronous systems |
| uModbus | TCP, RTU | Yes (asyncio) | MIT | Async-friendly lightweight Modbus library |
1. PyModbus
PyModbus is the most widely used and feature-rich Modbus library in Python. It supports Modbus RTU, ASCII, TCP, and UDP, and can function as both client and server.
Pros
- Active community and documentation
- Full client/server and sync/async API
- Works on Windows, Linux, and embedded systems
- Supports custom function codes
Cons
- Heavier dependency footprint
- Slower for ultra-lightweight devices
Best For: Industrial-grade applications, gateways, and complex Modbus topologies.
Install:
pip install pymodbus
2. MinimalModbus
MinimalModbus is a lightweight library for communicating with Modbus RTU/ASCII devices via serial ports. It focuses on simplicity and reliability.
Pros
- Very easy to use
- Minimal dependencies
- Great for Raspberry Pi and embedded projects
Cons
- No TCP support
- No async or server-side capabilities
Best For: Simple one-device serial communication projects.
Install:
pip install minimalmodbus
3. pyModbusTCP
As the name suggests, pyModbusTCP handles only the Modbus TCP protocol. It’s ideal for Ethernet-based industrial devices and test servers.
Pros
- Lightweight TCP implementation
- Simple server and client modes
- Thread-safe architecture
Cons
- TCP only (no RTU/ASCII)
- Not ideal for embedded serial projects
Best For: Ethernet-based systems or test simulators.
Install:
pip install pyModbusTCP
4. Modbus-tk
Modbus-tk is an older but still useful synchronous Modbus library supporting RTU, ASCII, and TCP. It’s educational and easy to extend.
Pros
- Simple synchronous API
- Multi-protocol support
- Easy debugging and logging
Cons
- No async support
- Slower than PyModbus for large systems
Best For: Educational or small-scale synchronous setups.
Install:
pip install modbus-tk
5. uModbus
uModbus is a lightweight and asynchronous Modbus client/server library built for speed and scalability, supporting both TCP and RTU.
Pros
- Asyncio-friendly
- Minimal overhead
- Modern Python design
Cons
- Smaller community than PyModbus
- Limited advanced examples
Best For: Modern async-based IoT or SCADA projects.
Install:
pip install uModbus
Feature-by-Feature Comparison
| Feature | PyModbus | MinimalModbus | pyModbusTCP | Modbus-tk | uModbus |
|---|---|---|---|---|---|
| RTU Support | Yes | Yes | No | Yes | Yes |
| TCP Support | Yes | No | Yes | Yes | Yes |
| Async Support | Yes | No | Partial | No | Yes |
| Client Mode | Yes | Yes | Yes | Yes | Yes |
| Server Mode | Yes | No | Yes | Yes | Yes |
| Documentation | ⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐ | ⭐⭐ |
| Performance | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐ | ⭐⭐⭐⭐ |
| Ease of Use | ⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐ |
Choosing the Right Library for Your Project
| Use Case | Recommended Library |
|---|---|
| Beginner, single serial device | MinimalModbus |
| Multi-slave network or async TCP | PyModbus |
| Ethernet-based test server | pyModbusTCP |
| Educational or lab environments | Modbus-tk |
| Asyncio SCADA integration | uModbus |
Example: Reading a Modbus Register Using PyModbus
from pymodbus.client import ModbusTcpClient
client = ModbusTcpClient('192.168.1.100', port=502)
client.connect()
result = client.read_holding_registers(100, 2, unit=1)
print(result.registers)
client.close()
This snippet connects to a Modbus TCP device and reads two registers starting at address 100.
Conclusion
All Python Modbus libraries serve different purposes:
- PyModbus → Industrial-grade, async-capable, multi-protocol.
- MinimalModbus → Lightweight and beginner-friendly for serial RTU.
- pyModbusTCP → Simple, TCP-only applications.
- Modbus-tk → Educational and synchronous scenarios.
- uModbus → Modern, async, lightweight IoT integrations.
Choosing the right library depends on your device communication type (TCP vs RTU), project scale, and async needs.
Key Takeaways
- Python has robust support for Modbus across several libraries.
- PyModbus remains the most comprehensive and actively maintained option.
- For lightweight serial use, MinimalModbus is ideal.
- Asyncio-based applications benefit most from uModbus.
- Always consider protocol type (RTU or TCP) before selecting a library.
