Skip to main content

A command line tool to communicate with modbus devices

Project description

ModPoll - A command line tool to communicate with modbus devices.

pipeline status License Downloads

Learn more about modpoll usage at documentation site.

Motivation

The initial idea of creating this tool is to help myself debugging new devices during site survey. A site survey usually has limited time and space, working on-site also piles up some pressures. At that time, a portable swiss-knife toolkit is our best friend.

This program can be easily deployed to Raspberry Pi or similar embedded devices, continuously polling data from the connected modbus devices, you can choose to save data locally or forward uplink to a MQTT broker for easy debugging, the MQTT broker can be setup on the same Raspberry Pi or on the cloud. On the other hand, a smart phone (Android/Iphone) can be used to visualize collected data and control the devices remotely via the same MQTT broker.

However, beside the above recommended setup, you can actually run this program on any PC or server with Python 3 support. One popular use case is to deploy the program onto a server and keep it running as a gateway to bridge between traditional industrial network and modern IoT edge/cloud infrustructure.

This program is designed as a standalone tool, if you are looing for a python library to communicate with modbus devices, please consider the following two great open source projects, pymodbus or minimalmodbus

Installation

This program is tested on python 3.6+.

  • Install with pip

    The package is available in the Python Package Index,

    pip install modpoll
    

    Upgrade the tool via pip by the following command,

    pip install -U modpoll
    

Basic Usage

  • Connect to Modbus TCP device

    modpoll --tcp modsim.topmaker.net --config examples/modsim.csv
    
  • Connect to Modbus RTU device

    modpoll --rtu /dev/ttyUSB0 --rtu-baud 9600 --config examples/scpms6.csv
    
  • Connect to Modbus TCP device and publish data to MQTT broker

    modpoll --tcp modsim.topmaker.net --config examples/modsim.csv --mqtt-host iot.eclipse.org
    
  • Connect to Modbus TCP device and export data to local csv file

    modpoll --tcp modsim.topmaker.net --config examples/modsim.csv --export data.csv
    

Please refer to documentation site for more configures and examples.

Notes: some of the examples use our online modbus simulator at modsim.topmaker.net with standard 502 port, it helps user to quickly test the functions of modpoll tool.

Run in docker

A docker image has been provided for user to directly run the program,

docker run helloysd/modpoll modpoll --help

To load the modbus register configure file, user may need to mount the volume to container, for example, if the child folder examples contains the config file modsim.csv, we can mount it using the following command,

docker run -v $(pwd)/examples:/app/examples helloysd/modpoll modpoll --tcp modsim.topmaker.net --config /app/examples/modsim.csv

Credits

The implementation of this project is heavily inspired by the following two projects:

License

MIT © Ying Shaodong

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modpoll-0.3.3.tar.gz (11.4 kB view hashes)

Uploaded Source

Built Distribution

modpoll-0.3.3-py3-none-any.whl (11.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page