Basic Usage
The config option is required.
Commandline Usage
Connect to Modbus TCP device
modpoll --tcp 192.168.1.10 --config examples/modsim.csv
Connect to Modbus serial device
modpoll --serial /dev/ttyUSB0 --serial-baud 9600 --config contrib/eniwise/scpms6.csv
Connect to Modbus TCP device and publish data to remote MQTT broker
modpoll --tcp 192.168.1.10 --config examples/modsim.csv --mqtt-host broker.emqx.io
Connect to Modbus TCP device and export data to local csv file
modpoll --tcp modsim.topmaker.net --config https://raw.githubusercontent.com/gavinying/modpoll/main/examples/modsim.csv --export data.csv
Configuration File
The configuration file (–config) is a CSV file that defines the devices, pollers, and references to be read.
For register references (i.e., Holding or Input registers) with a dtype of bool, you can specify a single bit to be extracted from the 16-bit register. This is done by appending :bit to the address, where bit is an integer from 0 to 15.
40110: Reads the entire 16-bit register at address 40110.40110:15: Reads the 16-bit register at address 40110, extracts bit 15, and returns a boolean value.
The bit is extracted from the final 16-bit value after byte/word swapping based on the poller’s endianness configuration.
Framers and transports
Serial (–serial, alias –rtu) supports framers rtu and ascii (e.g., –serial … –framer ascii). Binary framer was removed in pymodbus 3.9+. If –framer default is used, pymodbus defaults to RTU framer.
TCP/UDP (–tcp/–udp) use the socket framer; other framers are rejected. If –framer default is used, pymodbus defaults to socket framer.