Skip to main content

A new modpoll tool for modbus communication

Project description

ModPoll - A new modpoll tool for modbus communication

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.

Moreover, you can also run this program on any PC or server with Python 3 support. One common use case is to deploy the program onto a server and keep it running as a gateway, i.e. polling data from local Modbus devices and forward to a centralized cloud server. In that sense, this program helps to bridge between the traditional world of fieldbus network and the modern world of IoT edge/cloud infrustructure.

This program is designed to be a standalone tool, it shall work out-of-the-box. If you are looing for a modbus python library, 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 192.168.1.10 --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 --tcp-port 5020 --config examples/modsim.csv --mqtt-host iot.topmaker.net
    
  • Connect to Modbus TCP device and export data to local csv file

    modpoll --tcp modsim.topmaker.net --tcp-port 5020 --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 --help

To load local configure file, you need to mount a local folder to the container volume, 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 --tcp modsim.topmaker.net --config /app/examples/modsim.csv

The other way is to load configure file from a remote URL, for example,

docker run helloysd/modpoll --tcp modsim.topmaker.net --tcp-port 5020 --config https://raw.githubusercontent.com/gavinying/modpoll/master/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.6.tar.gz (11.9 kB view hashes)

Uploaded Source

Built Distribution

modpoll-0.3.6-py3-none-any.whl (12.1 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