Python plugin: Eastron SDM72D-M (modbus)

Python and python framework

Moderator: leecollings

Post Reply
bbossink
Posts: 1
Joined: Tuesday 23 July 2019 20:37
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Python plugin: Eastron SDM72D-M (modbus)

Post by bbossink »

Hi all,

MFxMF made a python plugin for the Eastron SDM630 Smart meter. I modified his original code to make it suitable for the SDM72D-M smart meter.

The meter is connected via modbus and an RS485 USB adapter (very cheap on ebay!) No further coding needed!

:idea: :arrow: Credits to the original developer!
Attachments
screenshot_sdm72d.png
screenshot_sdm72d.png (231.55 KiB) Viewed 3447 times
tux87
Posts: 1
Joined: Thursday 22 August 2019 10:18
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Eastron SDM72D-M (modbus)

Post by tux87 »

Thanks for sharing. I forked the code, and created yet another plugin for the SDM120-MODBUS meter (single phase).
Credits to you, and the original dev!

https://github.com/remcovanvugt/SDM120M ... icz-plugin
lekob
Posts: 2
Joined: Friday 27 September 2019 15:21
Target OS: OS X
Domoticz version:
Contact:

Re: Python plugin: Eastron SDM72D-M (modbus)

Post by lekob »

bbossink wrote: Tuesday 23 July 2019 20:47 Hi all,

MFxMF made a python plugin for the Eastron SDM630 Smart meter. I modified his original code to make it suitable for the SDM72D-M smart meter.

The meter is connected via modbus and an RS485 USB adapter (very cheap on ebay!) No further coding needed!

:idea: :arrow: Credits to the original developer!

Hi buddy, thanks for sharing in such a brief way! Appreciate it.

Regards,
L.Smith

______________
Plex Tutuapp Vidmate
Tweakerd
Posts: 2
Joined: Thursday 14 November 2019 10:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Eastron SDM72D-M (modbus)

Post by Tweakerd »

Hello all,

I'm trieing to get things work, but still got this errors.
2019-11-14 10:29:57.624 Error: (power Modbus) 'onHeartbeat' failed 'OSError'.
2019-11-14 10:29:57.624 Error: (power Modbus) ----> Line 131 in '/home/pi/domoticz/plugins/SDM120Modbus-Domoticz-plugin/plugin.py', function onHeartbeat
2019-11-14 10:29:57.624 Error: (power Modbus) ----> Line 85 in '/home/pi/domoticz/plugins/SDM120Modbus-Domoticz-plugin/plugin.py', function onHeartbeat
2019-11-14 10:29:57.624 Error: (power Modbus) ----> Line 392 in '/home/pi/domoticz/plugins/SDM120Modbus-Domoticz-plugin/minimalmodbus.py', function read_float
2019-11-14 10:29:57.624 Error: (power Modbus) ----> Line 697 in '/home/pi/domoticz/plugins/SDM120Modbus-Domoticz-plugin/minimalmodbus.py', function _genericCommand
2019-11-14 10:29:57.624 Error: (power Modbus) ----> Line 795 in '/home/pi/domoticz/plugins/SDM120Modbus-Domoticz-plugin/minimalmodbus.py', function _performCommand
2019-11-14 10:29:57.624 Error: (power Modbus) ----> Line 930 in '/home/pi/domoticz/plugins/SDM120Modbus-Domoticz-plugin/minimalmodbus.py', function _communicate

I'm running Domoticz on a Pi3+, installed and compiled on the system.
Connected to my energy meter via P1 on USB0 working fine
My Eastron SDM72D-M connected via USB-RS485 on USB1
Found some settings in plugin.py te correct like USB port and in minimalmodbus.py sstandard speed from 19200 to 9600(Standard)

Whatever I'm doing, no result.

Please help :D

Regards,

Rene
Tweakerd
Posts: 2
Joined: Thursday 14 November 2019 10:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Eastron SDM72D-M (modbus)

Post by Tweakerd »

Sorry, made mistake,

My domoticz is running on a Raspberry Pi3+.

Installed Debian Buster on it, and installed Domoticz 4.10717 on it.
OS runs from hard drive to spare the amount of read/writes to the sd card.

As earlyer mentioned, everytthing runs smouthly, but SDM72D-M wont..

Anyone a hint?

Kind regards,

R
RRM13
Posts: 6
Joined: Wednesday 23 November 2016 10:49
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: NL_N-Br
Contact:

Re: Python plugin: Eastron SDM72D-M (modbus)

Post by RRM13 »

Tweakerd wrote: Thursday 14 November 2019 10:36 Hello all,

I'm trieing to get things work, but still got this errors.
2019-11-14 10:29:57.624 Error: (power Modbus) 'onHeartbeat' failed 'OSError'.
2019-11-14 10:29:57.624 Error: (power Modbus) ----> Line 131 in '/home/pi/domoticz/plugins/SDM120Modbus-Domoticz-plugin/plugin.py', function onHeartbeat
2019-11-14 10:29:57.624 Error: (power Modbus) ----> Line 85 in '/home/pi/domoticz/plugins/SDM120Modbus-Domoticz-plugin/plugin.py', function onHeartbeat
2019-11-14 10:29:57.624 Error: (power Modbus) ----> Line 392 in '/home/pi/domoticz/plugins/SDM120Modbus-Domoticz-plugin/minimalmodbus.py', function read_float
2019-11-14 10:29:57.624 Error: (power Modbus) ----> Line 697 in '/home/pi/domoticz/plugins/SDM120Modbus-Domoticz-plugin/minimalmodbus.py', function _genericCommand
2019-11-14 10:29:57.624 Error: (power Modbus) ----> Line 795 in '/home/pi/domoticz/plugins/SDM120Modbus-Domoticz-plugin/minimalmodbus.py', function _performCommand
2019-11-14 10:29:57.624 Error: (power Modbus) ----> Line 930 in '/home/pi/domoticz/plugins/SDM120Modbus-Domoticz-plugin/minimalmodbus.py', function _communicate

I'm running Domoticz on a Pi3+, installed and compiled on the system.
Connected to my energy meter via P1 on USB0 working fine
My Eastron SDM72D-M connected via USB-RS485 on USB1
Found some settings in plugin.py te correct like USB port and in minimalmodbus.py sstandard speed from 19200 to 9600(Standard)

Whatever I'm doing, no result.

Please help :D
Regards,

Rene

Did you solve the problem?
I have exact the same errors.
The SDM72 is only working with the SDM630 plugin.
Unfortunately combining the SDM72 with the SDM120 gives other errors, although the usb-rs485 converters have a static usb port address.
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Python plugin: Eastron SDM72D-M (modbus)

Post by Toulon7559 »

RS485 is a bus-system, and ModBus is assuming that 1 such bus is used for multiple Slaves and 1 Master.
In this case the energy-meters assumed to be the Slaves and the RPI the Master, with Slaves each having a unique address.
Out-of-the-box usually a Slave-device has addres 01, but if you have multiple Slaves at 1 RS485-bus, you must program these Slaves to have different Slave-adresses and the Master must know these addresses!
Obviously the speed & protocol of communication must be compatible between the Master and all Slaves.

Reading about multiple USB-ports in use at the RPI, wondering what kind of configuration you are aiming for (in hardware and software).
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
RRM13
Posts: 6
Joined: Wednesday 23 November 2016 10:49
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: NL_N-Br
Contact:

Re: Python plugin: Eastron SDM72D-M (modbus)

Post by RRM13 »

Indeed, I use the RPI3b+ as master for the SDM72 and SDM120 on Domoticz version 2020.2 (Debian desktop version through raspberry imager). The SDM72 with address 2 and SDM120 with 1.
The SDM72 for monitoring the electric consumption of the unit outside of the heat pump and the SDM120 for the inner part.
The speed/baud is different; 9600 and 2400, therefore I use two RS485-USB converters, with static USB port, because of the lack of an unique ID.

Unfortunately the SDM72 only funtions with the SDM630 plugin and not with the SDM72 or 120 plugin.
Connecting only the SDM72 through the SDM630 plugin works flawless, but as soon as I try to connect the SDM120 through 120 or 630 plugin gives several errors or a system which freezes in minutes.

That's the reason why I wondered if Tweakerd solved this problem, because one of the errors that passed, is exactly as he mentioned.

May be I have to dig into the crash log files (which I haven't found yet) or the problem is in the RS485 converters, which have the possibility to connect a 5V device. May be the PSU (5v3A) lacks the power to supply both converters.
For the last possibility I ordered 2 "simple" converters, without this option to connect a 5V device.
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Python plugin: Eastron SDM72D-M (modbus)

Post by Toulon7559 »

The SDM72 with address 2 and SDM120 with 1.
The SDM72 for monitoring the electric consumption of the unit outside of the heat pump and the SDM120 for the inner part.
The speed/baud is different; 9600 and 2400, therefore I use two RS485-USB converters, with static USB port, because of the lack of an unique ID.
Reading the above quoted text (correct me if misunderstood) I have the feeling of a misunderstanding of the operational concept of the RS485-Bus:
- Different Slave-bus-address for the 2 Slaves is OK to functionally 'separate' the Slaves on the common RS485-bus
- The SDM72 and the SDM120 have an RS485-interface which can be directly chained in 1 RS485-Bus [because that is principle of RS485-Bus]
Different speeds to different Slaves is allowed within the bus-concept, IF the Master has functional capabilities to handle that difference on it's one & same RS485-Bus-interface. Then no need to have 2 USB-converters: with the above background only 1 converter between Master and RS485-Bus should be sufficient.
- The easier solution is to set both Slaves at the same speed for communication: the data protocol for both SDMs has commands to change the speed of communication.
- Regardless of above, if you have used a separate USB-converter for direct interfacing from the RPI to each SDM, in practise you have created an RPI dealing with 2 separate RS485-Busses: are the 2 plugins in the same RPI functionally compatible with that configuration?

Note: Small other detail, but an RS485-Bus must be properly terminated for correct operation, according to the bus-spec.
;-) Otherwise possibly 'surprises'.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
RRM13
Posts: 6
Joined: Wednesday 23 November 2016 10:49
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: NL_N-Br
Contact:

Re: Python plugin: Eastron SDM72D-M (modbus)

Post by RRM13 »

Toulon7559 wrote: Sunday 28 June 2020 16:09 - The easier solution is to set both Slaves at the same speed for communication: the data protocol for both SDMs has commands to change the speed of communication.
The easier solution gave the best result.
- Now I use one RS485 to USB converter for both SDM meters. (after reading the link of de RS485)
- The SDM72 switched to Baud rate 2400 (instead of 9600) due to the maximum rate of 2400 of the SDM120
- Added twice hardware through the SDM630 plugin; one with the Device ID (address) 1 and the other 2, reading interval 1 min

Up and running in the past 6 hours without freezes or errors, thanks!
Toulon7559
Posts: 843
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Python plugin: Eastron SDM72D-M (modbus)

Post by Toulon7559 »

All SDM-devices can be set to 9600bps:
less occupation on the USB-port for the Raspberry.

;-) But if it works, don't touch, if not needed!
;-) ;-) Sometimes 'improvement' just causes new problems ....
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
DickNL
Posts: 5
Joined: Saturday 05 September 2020 18:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Contact:

Re: Python plugin: Eastron SDM72D-M (modbus)

Post by DickNL »

Toulon7559 wrote: Sunday 28 June 2020 16:09
Note: Small other detail, but an RS485-Bus must be properly terminated for correct operation, according to the bus-spec.
;-) Otherwise possibly 'surprises'.
Thank you for this really useful remark with a tiny link referring to 'all you should know about RS485'. :D It helped me undo my stupidity.
I expanded an proper working setup consisting of only one Eastron SDM630v2 (630 plugin) with three Eastron SDM72DMv2 meters with ID set 2,3 and 4. (baud9600, added 3 times 'hardware-through plugin' with corresponding ID's, no other settings altered)
At first glance, it worked. But the plugin stalled, did not read all 4 meters, with repeated 'Connection problem' in the log file.
My mistake was an Y-shape cabling setup and I also forgot to terminate the bus (I should have know better). So, data-reflection etc occurred.
Even twisted-paired cabling seems to be important since data wiring runs along wires carrying serious AC loads.

In addition: as you may know: SDM72DMv2 has more parameters than SDM72DM(v1) which are not fully covered by the 72DM-plugin.
My recommendation is: for SDM630v2 and SDM72DMv2 stick to the 630 plugin, although many 'expert/nerd' parameters mapped by the 630 -plugin will remain unused in Domoticz by most users.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest