Working with Modbus in Linux

You can use the console python utility modbus-cli <https://github.com/favalex/modbus-cli> to work with Modbus devices.

Installing

sudo apt install python3-pip
sudo pip3 install modbus_cli

Example of operation with a voltage and current sensor PZEM-016

Read register (Input Register) 0 containing the current AC mains voltage value (speed 9600 bps, device address 7):

modbus -b 9600 -s 7 -v /dev/ttyUSB0 i@0

Example conclusion:

07 04 00 00 00 01 31 ac
Read 1 registers: [2235]
0: 2235 0x8bb