Skip to content

Instantly share code, notes, and snippets.

@Elwell
Last active February 8, 2020 01:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Elwell/6418662 to your computer and use it in GitHub Desktop.
Save Elwell/6418662 to your computer and use it in GitHub Desktop.
simple test script to poll serial modbus
#!/usr/bin/python
# script to poll growatt PV inverter and spit out values
# Andrew Elwell <Andrew.Elwell@gmail.com> 2013-09-01
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
import time
import sys
start = int(sys.argv[1])
count = int(sys.argv[2])
client = ModbusClient(method='rtu', port='/dev/ttyUSB0', baudrate=9600, stopbits=1, parity='N', bytesize=8, timeout=1)
client.connect()
rr = client.read_input_registers(start,count)
print rr.registers
client.close()
@Elwell
Copy link
Author

Elwell commented Sep 3, 2013

usage: ./read_values.py start_add count

ie:
$ ./read_value.py 2 3
[5368, 3251, 16]

ie, output (536.8W), string volt (325.1v), Power? (1.6A)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment