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?
- not sure if I'm using the right register but it doesn't work with another number either.
- wrong library? would be weird as it worked on the other meter (SDM220)
- 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