Reading registers with pymodbus

Try to:

 response = client.read_holding_registers(0x00,4,unit=1)

where the unit value is device id of the slave.

To print all:

print response.registers

Also is possible to directly get one value (for example third register):

print response.getRegister(2)

or

print response.registers[2]  

you could parse the response by yourself, the following is my code snippet:

    result = client.read_input_registers(0x01,1, unit=0x01)
    #print result
    t = result.registers[0]
    print "current temperature:", t, "  ", float(t/100.0)

Tags:

Python

Modbus