Reading data from electricity meter with Rs485

319 Views Asked by At

I want to read the data from the electrical meter I bought via RS485. In principle, I can receive it with 300 baud rate, but I cannot receive it with 9600 baud rate. I need to try hex codes with Python. I read the model number of the meter this way, but I need help with the rest.

    import serial
    import time
    import binascii
Seri port ayarları
ser = serial.Serial()ser.port = "COM4"ser.baudrate = 300ser.bytesize = serial.SEVENBITSser.parity = serial.PARITY_EVENser.stopbits = serial.STOPBITS_ONEser.dtr = Trueser.rts = True
try:# Open to Serial Portser.open()
# First command
#ser.write(('/?!\r\n').encode())  
command_hex = bytearray.fromhex("2F3F210D0A")
ser.write(command_hex)


response = ser.readline().decode()
print("300 baudrate ile alınan cevap:", response)

print(" Henüz 300 baudrate.")
command_hex1 = bytearray.fromhex("060570D0A")
ser.write(command_hex1)

ser.baudrate = 9600
print("9600 baudrate.")




time.sleep(0.5) 
response = ser.readline().decode()
print("9600 baudrate answer:", response)
except serial.SerialException as e:print("Seri port error:", str(e))
#finally:  `

I want to read data from electricity meter with Rs485

1

There are 1 best solutions below

1
balun On

Suggest to use an existing tool, like modpoll, to verify your cable and device works on baudrate 9600 first.