Read outh kWh meter (PM5100) with modbus RTU on RPI

Viewed 364

My goal is to read out a PM5100 from Schneider with a Python script on a raspberry pi using modbus rtu.
I've been able to do it for another meter (SDM220) with modbus that worked just fine but I just can't seem to do it right on this one.

The PM5100 I configured as:
slave adr: 1
baud: 19200
parity: none

Cabling should be fine I think, GND and shielding are not connected but D1 and D0 are with a RS485 to USB connector.

Simple code:

#!/usr/bin/python3

import minimalmodbus

mb = minimalmodbus.Instrument("/dev/ttyUSB0", 1)
mb.serial.baudrate = 19200
mb.debug = True

val = mb.read_float(3212,3,4)
print(val)

This generates error InvalidResponseError:

MinimalModbus debug mode. Will write to instrument (expecting 13 bytes back): 01 03 0C 8C 00 04 86 B2 (8 bytes)
MinimalModbus debug mode. Clearing serial buffers for port /dev/ttyUSB0
MinimalModbus debug mode. No sleep required before write. Time since previous read: 439371243.54 ms, minimum silent period: 2.01 ms.
MinimalModbus debug mode. Response from instrument: 7F 7E DE CE F7 F3 13 (7 bytes), roundtrip time: 0.1 ms. Timeout for reading: 50.0 ms.

Traceback (most recent call last):
  File "1.py", line 9, in <module>
    val = mb.read_float(3212,3,4)
  File "/usr/local/lib/python3.7/dist-packages/minimalmodbus.py", line 717, in read_float
    payloadformat=_Payloadformat.FLOAT,
  File "/usr/local/lib/python3.7/dist-packages/minimalmodbus.py", line 1245, in _generic_command
    payload_from_slave = self._perform_command(functioncode, payload_to_slave)
  File "/usr/local/lib/python3.7/dist-packages/minimalmodbus.py", line 1330, in _perform_command
    response, self.address, self.mode, functioncode
  File "/usr/local/lib/python3.7/dist-packages/minimalmodbus.py", line 1867, in _extract_payload
    raise InvalidResponseError(text)
minimalmodbus.InvalidResponseError: Checksum error in rtu mode: 'ó\x13' instead of '\\>' . The response is: '\x7f~ÞÎ÷ó\x13' (plain response: '\x7f~ÞÎ÷ó\x13')

So, what am I doing wrong?

  1. not sure if I'm using the right register but it doesn't work with another number either.
  2. wrong library? would be weird as it worked on the other meter (SDM220)
  3. I have tried changing to "read_register" and changing the parameters but no luck

Anyone with any experience, tips, guesses or answers is welcome to reply. Thank you!

Sources:
PM5100: https://www.se.com/be/nl/product/METSEPM5100/pm5100-meetcentrale---tot-15de-h---1do-33-alarmen--paneelmontage/
Register list: https://www.se.com/ww/en/download/document/PM5100-PM5300_PublicRegisterList/
RS485 to USB: https://www.bol.com/be/nl/p/usb-to-rs485-485-converter-adapter-support-win7-xp-vista-linux-mac-os-wince5-0/9300000012988342/?Referrer=ADVNLGOO002013-G-120928976848-S-1076696512011-9300000012988342&gclid=Cj0KCQiAsqOMBhDFARIsAFBTN3epmK66KNj2IufWmjeGY_nkGep_roirDZxfyLu0H3UaVYvewlDRMx4aAhgwEALw_wcB
minimalModbus: https://minimalmodbus.readthedocs.io/en/stable/readme.html

1 Answers

Cabling should be fine I think, GND and shielding are not connected but D1 and D0 are with a RS485 to USB connector.

Sorry, wrong assumption.

RS-485 or RS-422 do need a third wire for the current to return (ground).

These Checksum error in rtu mode that you are having are caused by noise or common-mode voltages screwing with your signal.

When using these cheap USB-to-RS485 transceivers with no GND connection you need to make sure the GNDs on both sides are connected through the power supply.

If you have your power meter and laptop in the same room that should be easy enough: just connect the laptop's charger to the same power outlet. Note that you won't be able to get a reliable link if you are running your laptop on battery power unless you link the grounds with a third cable as indicated below.

If you are in a different environment (your meter and laptop are in different buildings or your power outlets are not properly grounded, for instance) then you need to add a third wire to your cable. Since you don't have a place to connect on the stick itself you will probably need to connect it to a different USB shield somehow. This will probably not be a very handsome solution so maybe investing in another USB-to-RS485 adaptor is not such a bad idea.

You can find many more comments, references, and mad-scientist theories regarding this topic on EESE.

Related