Extraction of Data from an RS-485 enabled Multi Function Meter Using Raspberry Pi-3. Have used the following code but it throws an error?

66 views Asked by At

Have used the following code to extract data from Rs-485 enabled multifunction meter using Raspberry Pi-3

The Multifunction meter used is L&T WL4440.

NOTE-- Register addresses are offset from 40001 so inputting register 0 in the code is            actually 40001, 3 = 40004 etc...
Arguments - (register start address, number of registers to read, function code)


import minimalmodbus
mb_address = 1
modbus_read = minimalmodbus.Instrument('/dev/ttyUSB0',mb_address)
modbus_read.serial.baudrate = 38400
modbus_read.serial.bytesize = 8
modbus_read.serial.parity = minimalmodbus.serial.PARITY_NONE
modbus_read.serial.stopbits = 1
modbus_read.serial.timeout = 0.5
modbus_read.mode = minimalmodbus.MODE_RTU
modbus_read.clear_buffers_before_each_transaction = True
modbus_read.close_port_after_each_call = True
print("")
print("Requesting Data ...")
data =modbus_read.read_registers(148, 1, 3)
print("")
print("The totalcurrent is",data)
modbus_read.serial.close()

THE ERROR IS displayed below and the image attached:

Traceback (most recent call last):
  File "/home/sanjeevi/Modbus_read/modbus_read.py", line 37, in <module>
    data =modbus_read.read_registers(148, 1, 3)
  File "/home/sanjeevi/.local/lib/python3.9/site-packages/minimalmodbus.py", line 927, in read_registers
    returnvalue = self._generic_command(
  File "/home/sanjeevi/.local/lib/python3.9/site-packages/minimalmodbus.py", line 1276, in _generic_command
    payload_from_slave = self._perform_command(functioncode, payload_to_slave)
  File "/home/sanjeevi/.local/lib/python3.9/site-packages/minimalmodbus.py", line 1359, in _perform_command
    payload_from_slave = _extract_payload(
  File "/home/sanjeevi/.local/lib/python3.9/site-packages/minimalmodbus.py", line 1918, in _extract_payload
    _check_response_slaveerrorcode(response)
  File "/home/sanjeevi/.local/lib/python3.9/site-packages/minimalmodbus.py", line 3584, in _check_response_slaveerrorcode
    raise error
minimalmodbus.IllegalRequestError: Slave reported illegal data value

screenshot shoring image

0

There are 0 answers