FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14124 questions

16781 answers

27569 comments

53950 members

0 votes
122 views 1 comments
by
Hello There!

Im trying to read the data of a Slave RUT240 through a Rpi but still I could not get a single answer, an error arise and it has to be with the directioning of the slave itself, maybe I have the wrong IP or UnitID. I will leave here my Modbus configuration of the slave and the code used for reading the registers, I hope to get some help from someone who has had the experience. Thanks in advance:
 

ip            = "192.168.1.1" # ip address of GX device or if on venus local try localhost

# Value Refresh Rate in seconds

RefreshRate = 1

teltonikaID = 1

#===================================

Defaults.Timeout = 25

Defaults.Retries = 5

# Local network ip address of Cerbo GX. Default port 502

client = ModbusClient(ip, port='503')

def modbus_register(address, unit):

    msg     = client.read_input_registers(address, unit=unit)

    decoder = BinaryPayloadDecoder.fromRegisters(msg.registers, byteorder=Endian.Big)

    msg     = decoder.decode_16bit_int()

    return msg

signal=modbus_register(71,unit= teltonikaID)

1 Answer

0 votes
by

Hello,

Could you provide more details, on your setup? What is the topology? What device, application uses this code/interface?

What is GX device, or Cerbo GX?

If default MODBUS port is 502, why do you use 503?

Also, registers starting with address 71 stores Router's name, which is represented in ASCII, yet you decode it as a 16-bit integer.

Best regards,

by
Hello,

I have a raspberry pi and a Cerbo GX (a component that also communicates through Modbus) connected to the LAN and WAN (now LAN configured) ports of the Teltonika Router. Currently, the Cerbo component is using the default port "502", in the Teltonika configurations I changed the port of the router to "503 (that is why Im referring to it in this port). Regarding to the way of reading the data you are right, Im not decoding correctly the name, nevertheless the error Im having is not a parce one, is simply that the Modbus communication cannot be stablished and by now I havent found the reason.

Thanks for your reply