This release is a pre-release and may not be stable for production use.
2.x development branch. This checkout accepts WoT TM/TD JSON using profile 0.2. CSV remains supported on the 1.x
mainbranch. Install the current preview withuv tool install --prerelease allow 'modpoll[serial]==2.0.0a2'; stable 1.x remains available withuv tool install 'modpoll<2'. For development, runmake install, then prefix project commands withuv run.
Modpoll - A New Command-line Tool for Modbus and MQTT
Learn more about modpoll usage at documentation site.
Motivation
The idea for creating this tool originated from my need to efficiently check new devices during site surveys. These surveys are often time-constrained and space-limited, with on-site work adding to the pressure. In such situations, a portable Swiss Army knife toolkit becomes a valuable companion.
This tool can be easily deployed on a Raspberry Pi or similar embedded devices, polling data from a Modbus network or connected devices. Users can choose to log the data locally or publish it to an MQTT broker for further troubleshooting.
The MQTT broker can be set up either on the same Raspberry Pi or in the cloud. Once data is successfully published, users can subscribe to the relevant MQTT topics and conveniently view the data on their smartphones.
Moreover, you can also run this tool continuously on a server as a Modbus-MQTT gateway, i.e. polling from local Modbus devices and forwarding data to a centralized cloud service.
In fact, modpoll helps to bridge between the traditional field-bus world and the new IoT world.
💡 Tips: This tool is designed to be a standalone executable application, which works out-of-the-box on Linux/macOS/Windows. If you are looking for a Modbus python library, please consider the following great open-source projects, pymodbus or minimalmodbus
Feature
- Support Modbus RTU/TCP/UDP devices
- Show polling data for local debugging, like a typical modpoll tool
- Publish polling data to MQTT broker for remote debugging, especially on smart phone
- Export polling data to local storage for further investigation
- Provide docker solution for continuous data polling use case
Installation
This tool requires Python 3.10+ (Ubuntu 22.04+ or equivalent) and is available on the Python Package Index. Install it with uv. Ubuntu 20.04 and Python 3.8 are no longer supported.
Using uv
Install modpoll using the following command,
uv tool install --prerelease allow "modpoll==2.0.0a2"
Optionally, pyserial library can be installed for Modbus-RTU communication,
uv tool install --prerelease allow 'modpoll[serial]==2.0.0a2'
Upgrade the tool via the following command,
uv tool install --upgrade --prerelease allow "modpoll<3"
The same commands work on Windows PowerShell; uv manages the isolated tool environment.
Quickstart
Verify modpoll against the already deployed public Modbus TCP simulator. No local modsim installation or Docker container is needed:
modpoll --once \
--tcp modsim.topmaker.net --tcp-port 502 \
--config examples/modsim.tm.json
Modbus ASCII and framers
- Serial transports: use
--serial PORT --framer ascii(alias:--rtustill accepted); pyserial URLs such assocket://host:portandrfc2217://host:portwork for serial-over-TCP tunnels. - Serial supports framers
asciiandrtu(pymodbus defaults to RTU if--framer default). Binary framer is no longer supported in pymodbus 3.9+.
Prepare a WoT configuration
Use examples/modsim.tm.json for the simulator model or
examples/modsim.generated.td.json for its
generated local TCP instance.
Both preserve the four original blocks and 37 output references. --unit-id
overrides the Unit ID declared consistently in Forms (fallback 1); a concrete TD's Forms must agree before overrides.
The existing transport, polling, output and MQTT arguments remain available.
See the current profile for field mapping,
access flags, byte order, multiplier semantics and supported limits; the
execution contract defines the profile 0.2-only input policy.
The configuration loader rejects CSV and reports invalid model fields before
polling. Each model describes one device; use multiple --config paths for
multiple devices. Give each model a unique title, which is the output device name.
Physical RS485 polling has also been verified by the maintainer with an Eastron meter (2026-10-28). See validation for the evidence scope and contributed mappings for vendor references.
For a complete local simulator/MQTT demonstration, use the repository's Docker Compose example.
MQTT data and write behavior
The local example above uses the adam6024_raw TD title for its default topics:
modpoll/adam6024_raw/data for samples and modpoll/adam6024_raw/set for
write commands. The publish, subscribe and diagnostics topic patterns are
configurable; see the MQTT documentation.
Writes use literal Modbus PDU addresses and raw values. Holding-register arrays use FC16 and must contain 1–123 unsigned 16-bit values within the address range. Invalid, oversized, malformed, ambiguous or retained write messages are ignored and logged. Brokers can clear the retained flag on live forwarding, so configure the broker not to retain commands on the set topic; QoS does not make a write exactly once.
When a sample is invalid in a poll cycle, modpoll omits it from MQTT output and
writes null for that point in the JSON snapshot. Snapshots from multiple
configuration files are combined and replaced atomically. When --timestamp is
enabled, the timestamp is the start time of the poll cycle in Unix seconds; a
device with a point named timestamp cannot use it. A snapshot is
simulation data,
so modsim --config device.tm.json --data snapshot.json replays it locally.
Run with docker
A docker image has been provided for user to directly run the tool without local installation,
docker run --rm topmaker/modpoll:2.0.0a2
It shows the version of the tool by default.
On Linux, host networking connects the container to a simulator on the host.
Mount the JSON configuration into the container; --daemon suppresses tables.
If you want to load a local configure file, you need to mount a local folder onto container volume,
for example, if the child folder examples contains the config file modsim.tm.json, we can use it via the following command,
docker run --rm --network host -v "$(pwd)/examples:/app/examples:ro" topmaker/modpoll:2.0.0a2 \
modpoll -d \
--tcp 127.0.0.1 --tcp-port 5020 \
--config /app/examples/modsim.tm.json
Example Use Cases
-
Connect to Modbus TCP device
modpoll \ --tcp 192.168.1.10 \ --config examples/modsim.tm.json
-
Connect to Modbus serial device
modpoll \ --serial /dev/ttyUSB0 \ --serial-baud 9600 \ --config examples/modsim.tm.json
-
Connect to Modbus TCP device and publish data to MQTT broker
modpoll \ --tcp 127.0.0.1 --tcp-port 5020 \ --mqtt-host broker.emqx.io \ --config examples/modsim.tm.json
-
Connect to Modbus TCP device and export a local JSON snapshot
modpoll \ --tcp 127.0.0.1 --tcp-port 5020 \ --export data.json \ --config examples/modsim.tm.json
-
Replay the snapshot with modsim on this computer (keep snapshots of real devices local)
modsim --config examples/modsim.tm.json --port 5020 --data data.json
Refer to the documentation site for more details about the configuration and examples.
If you find this tool useful, please support us by starring 🌟 our repository to encourage further improvements.
Credits
The implementation of this project is heavily inspired by the following two projects:
- https://github.com/owagner/modbus2mqtt (MIT license)
- https://github.com/mbs38/spicierModbus2mqtt (MIT license)
Thanks to Max Brueggemann and Oliver Wagner for their great work.
License
MIT © 2021-2026, Ying Shaodong
Metadata
Release files for modpoll 2.0.0a6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| modpoll-2.0.0a6.tar.gz | 21.0 kB | Without provenance | Details for modpoll-2.0.0a6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| modpoll-2.0.0a6-py3-none-any.whl | Python 3 | none | any | Details for modpoll-2.0.0a6-py3-none-any.whl |
Total release size: 44.2 kB
Release files / modpoll-2.0.0a6.tar.gz
| Download URL | modpoll-2.0.0a6.tar.gz |
|---|---|
| Size | 21.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
77ba4ca00bf324a65af84cf418b6035b5a05ed91036b7908ee7934a6089103eb
|
|
BLAKE2b-256 checksum How to use checksums |
b6b2dfcde61b8fa2b12097a596b1a977800dadcd60e8836a58e0f9f6a42f19d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / modpoll-2.0.0a6-py3-none-any.whl
| Download URL | modpoll-2.0.0a6-py3-none-any.whl |
|---|---|
| Size | 23.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e423ef6df89f890f54c4090620febf4935121d12bcb30eae594b73334d3c6239
|
|
BLAKE2b-256 checksum How to use checksums |
f5c13d287bcd66aac7be8c1684e86ecbc0db7c9e6a149e45a27877f357e19081
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for modpoll 2.0.0a6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.