# pip install pymodbusfrom pymodbus.client import ModbusTcpClient c = ModbusTcpClient("sim.learnscada.com", port=20417)c.connect() regs = c.read_input_registers(0, count=6).registersprint(regs[0] / 10, "%") # 49.8 % c.write_register(0, 0) # manual modec.write_coil(0, True) # pump on
import time
while True:
r = c.read_input_registers(0, count=6).registers
print(time.strftime("%H:%M:%S"), r[0] / 10, "%")
time.sleep(1)
Input registers 0 to 5
0level498
1flow_in601
2flow_out502
3temp681
4motor_amps115
5heartbeat9120
49.8 %
Writes: holding 0 = 0, coil 0 = Truemanual mode, pump on
14:05:01 49.8 %
14:05:02 49.7 %
14:05:03 49.5 %
Dashboard: 611 requestsand counting