Last active
February 8, 2020 01:06
-
-
Save Elwell/6418662 to your computer and use it in GitHub Desktop.
simple test script to poll serial modbus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)