Files
ThingsBoard/meshifyDrivers/piflow/modbusTester.py
2024-07-31 14:02:59 -05:00

21 lines
631 B
Python

import minimalmodbus
minimalmodbus.BAUDRATE = 9600
minimalmodbus.STOPBITS = 1
address = 123
instrument = minimalmodbus.Instrument('/dev/ttyS0', address) #device, modbus slave address
instrument.debug = True
for _ in range(3):
try:
value = instrument.read_float(3873) #register -1 for float
print("Flow Rate from Flow Meter: {}".format(value))
except Exception as e:
print("Error: {}".format(e))
try:
value = instrument.read_float(784) #register -1 for float
print("Frequency from Drive: {}".format(value))
except Exception as e:
print("Error: {}".format(e))