added modbusTester
This commit is contained in:
12
piflow/modbusTester.py
Normal file
12
piflow/modbusTester.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import minimalmodbus
|
||||||
|
|
||||||
|
minimalmodbus.BAUDRATE = 9600
|
||||||
|
minimalmodbus.STOPBITS = 1
|
||||||
|
|
||||||
|
instrument = minimalmodbus.Instrument('/dev/ttyS0', 1) #device, modbus slave address
|
||||||
|
instrument.debug = True
|
||||||
|
try:
|
||||||
|
value = instrument.read_float(599) #register -1 for float
|
||||||
|
print("Value: {}".format(value))
|
||||||
|
except Exception as e:
|
||||||
|
print("Error: {}".format(e))
|
||||||
Reference in New Issue
Block a user