thomasw-1 avatar image
thomasw-1 suggested

Power Meter lib for Modbus-RTU-based meters from ABB, Carlo Gavazzi (Victron) and Eastron

Hi All,

I like to share a power meter library supporting following Modbus-RTU-based 3-phase power meters, which are connected by a ModbusTCP-server gateway:

  • ABB B23 (test on B23 212-100) and ABB B24 series
  • Carlo Gavazzi EM24 series (tests only for Victron related devices EM24DINAV53DISX and EM24DINAV93XISX)
  • SDM630-Modbus v2 and v1.
  • SDM72D-Modbus

Only ABB and Carlo Gavazzi meters support multi-phase aggregated power metering as expected in Germany!

For any usage a donation to with an amount of 5 USD/EUR/GBP or equivalent is expected.

Latest Changes:

  • 2022-03-13: Added SDM72D support / replaced Serial# on Eastron libs with Modbus-ID since serial is identical on all SDM630 meters ;-( > that change allows also the usage of several Eastron meters in the same installation


  • unzip TWE Meter Library into directory /opt/victronenergy/dbus-modbus-client.
  • Add in file /opt/victronenergy/dbus-modbus-client/ below the expression "import carlo_gavazzi " for that meter that you want to use the relevant bold marked expression
    • for ABB meters the expression: import TWE_ABB_B2x
    • for Gavazzi (Victron) meters the expression: import TWE_EM24RTU
    • for Eastron meters SDM630v2 the expression: import TWE_Eastron_SDM630v2
    • for Eastron meters SDM630v1 the expression: import TWE_Eastron_SDM630v1
    • for Eastron meters SDM72D the expression: import TWE_Eastron_SDM72D
  • OS versions >=2.80: For updates of this library delete all files with prefix "TWE_" in directory /opt/victronenergy/dbus-modbus-client/__pycache__
  • OS versions <2.80: For updates of this library delete all files with file extension ".pyc" and prefix "TWE_" in directory /opt/victronenergy/dbus-modbus-client/
  • reboot VenusOS
  • Go to "Settings" > "Modbus TCP devices" and perform a "Scan for Devices" or directly add a device via "Devices" > "Add" using relevant IP and ModBus ID and port. Last option is much quicker and also supports non-default unit-IDs.
    A few seconds later the meter should appear in your main menu.

Important Notes

  • The installation is not resistant for VenusOS updates. After any Venus OS update the adapter installation has to be repeated.
  • Only EM24 meters from Victron are supported. Tests on other OEM-meters have shown that they have obviously limited capabilities implemented.
  • ABB does obviously not properly support the "current" value on the B23 meter. Only positive values are shown, which are not necessarily compliant with the current power value.
    This constraint however has no impact on general functionality to control Victron solution and VRM measurements (except current values in extended graphs.
  • ABB meters a famous that Modbus-port A and B are used conversely. Consider that for your cabling.
  • For Eastron SDM630v1 devices a connectivity >9600 baud has to be configured on meter and gateway.

Exclusion of liability: Although the module has been tested in depth, I don't take any liability for any potential damage on your installation.

Thanks to Victron for their open platform and especially for the support of Matthijs Vader. Thanks to Michael for his extensive support to check the Victron meter support.

Energy Meterpower meterabb
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

mvader (Victron Energy) avatar image
mvader (Victron Energy) commented

holymoly Thomas, that looks like quite an effort that you did there!

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

jurekz avatar image
jurekz commented

After last bugfixing works perfectly with SDM630 Modbus V2 !!!

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Hi Jurek,

After my direct support, have you honestly donated already?
The world will appreciate that to you.

0 Likes 0 ·
Yes, You are right, world will be better with such action.
0 Likes 0 ·
johnny-brusevold avatar image
johnny-brusevold commented

Hi @ThomasW.

Is it possible to get help reading Eastron SDM120M modbus energy meter.

Has connected sdm120m to a 485 to usr-tcp converter, and can read all the registers from linux command line with a small program written in C

This is a single-phase reader and I think part of the code in the python script can be removed, but since I'm lousy at python it's just experimentation and try to learn some new things.

This meter has a register for meter code, serial and bios as in those in SDM630, but in the manual meter ID is specified in register 464515 as

FC 02 Meter code = 00 20 Length: 2 bytes

Data Format: Hex

gives me at address FC02 the value u32b 2097668

Will this be the same as the other meters? , since I can not find the address and specification for sdm630 'type' address

This is adresses for the main readings

Reg_f32b 0x0000 Voltage V
Reg_f32b 0x0006 Current A
Reg_f32b 0x000c Power W
Reg_f32b 0x0046 Frequency Hz
Reg_f32b 0x0048 Forward kWh
Reg_f32b 0x004a Reverse kWh
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Hi Johnny,

My experience shows that Eastron does not necessarily stick to the documented values. As you described according to the manual for that device the ID would be 0x0020 what mean 32 in decimal context. In case you have meters with the sames production series, the ID will be identical. With subreleases however the ID can change.

As I see, you extracted 4 instead of 2 bytes. 2 bytes result only in 16 bits.
The Eastron documentation clearly defines 2 bytes.

In case I didn't do any calculation mistake und your extraction was right, the ID value for your device should be 516.

How did I get this value?
Your decimal extraction 2097668 is a hex value of 0x00200204.
The last 2 bytes (green color) result in a decimal value of 516.

I am also not sure, if you extracted as big endian. In the hex-expression (red color) I can also discover the value, which is defined in the Eastron manual. Then the ID would be 32 in decimal.

Thumbs up appreciated and don't forget the donation!

Good Luck

0 Likes 0 ·

Thank you for your answer @ThomasW.

Have read through what you write several times, but there is something I do not get here. From the linux program I get the same answer as from windows modbus poll. when I read from one of the programs I can from USR-TCP232-304 see in the log that I get sent data in return. I can not see that by communication from dbus-modbus-client. It sends 12 bytes but no response, so I think there is something wrong with the communication here, or something I do not get with me here.

It's the same if I try with 'serial number' or 'meter id' and switch

(0xfc00, models to (0xfc02, models

and['/Serial'] to['/HardwareVersion']


0 Likes 0 ·
2022-02-05-1.png (189.6 KiB)
thomasw-1 avatar image thomasw-1 johnny-brusevold ·
Hi @Johnny Brusevold ,

In your case value 32 should work fine.

  1. Next step would be that all used registers answer proper values via Modbus poll.
  2. Check that in the lib the right format is used (16-32 bit, signed-unsigned, float)

0 Likes 0 ·

thanks for your tests with sdm120. I would like to know if it's working fine for you now since i plan to buy a single phase power meter for victron and the sdm would be perfect (bacause it's very small and i don't have much space...).

If not, is there any other meter that works in this form factor with victron ess?


0 Likes 0 ·


Yes, Eastron SDM-120M Modbus works with venus-os 2.82. Have not tested with newer version.

My SDM-120M config

0 Likes 0 ·
thomasw-1 avatar image
thomasw-1 commented

Looks promising!
Please consider that the modul won't work, even if only a single register is not properly defined.
First indication about successfulr recognition you can retrieve from /var/log/dbus-modbus-client/current.

If the device as such is recognized, then begin to adapt every single register.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Hi @ThomasW.

Thanks for the input! it does not look like I'm cracking this nut. I think I'm starting to understand a bit of that, but .......

Now I have set up a slave simulator with FC00, modified so I only have one register. FC00 / Serial, but venus-os just sends the same query as with all the registers enabled in the py script

Really appreciate if you can help me further.

One thing I think about is RTU over TCP / IP, if there is anything there

Received from venus

Rx:000011-00 01 00 00 00 06 01 03 00 0B 00 01
Rx:000012-00 02 00 00 00 06 01 03 FC 02 00 01
Rx:000013-00 03 00 00 00 06 01 03 13 88 00 01
Rx:000014-00 04 00 00 00 06 01 03 16 20 00 01

Received and respons from other programs

Rx:000028-01 03 FC 00 00 02 F4 5B
Tx:000029-01 03 04 01 4D 31 1D BE 41
0 Likes 0 ·

I'm giving this up here. Venus-os does not even try to read slave address 1

0 Likes 0 ·
thomasw-1 avatar image thomasw-1 johnny-brusevold ·
@Johnny Brusevold ,

If a donation to a charity organisation in a range of 30Euro/USD would be worth for you, I would be willing to look into your issue, after you provided a proof for that donation and a VPN access to your Gateway and GX.
I would spend 4 hours in trying to get your issue fixed. A final success however cannot be promised.

0 Likes 0 ·

Hi @ThomasW.

Now everything seems as expected, but do not know why I have to add one. (dot) to get the decimal values. Possible it is after updates of venus-os?

 Reg_f32b(0x0000 + s, '/Ac/L%d/Voltage' % n,        1., '%.1f V'),

Anyway, thanks for all the work in creating this library.

0 Likes 0 ·
thomasw-1 avatar image thomasw-1 johnny-brusevold ·

Hi @Johnny Brusevold ,

Thanks for your feedback. I would wonder, if the "dot" was the issue.

  • Recently I adapted that lib for a SDM72 meter using the latest GX-OS. I think the issue would have shown up here as well. I would wonder that the dot was the actual solution.
  • I experienced that using "tab"-characters instead of whitespaces causes the pyhthon files not to work anymore with impacted instruction lines. If you have still a old version, check, if you had a tab-character in.

0 Likes 0 ·


Have gone through the code and found three tabs that I removed without it making any difference, so (dots) must be allowed to be there :)

Used files from 'Eastron SDM meters'

So there was some difference in v1.3 so used it from this version and also no difference

0 Likes 0 ·

Hi @ThomasW.

There are a number of things I wonder about choices during setup where I can select 'Grid Meter' 'PV Inverter' 'Generator' 'AC Load'

If I choose one of the first 3, I think it appears correctly, but only 'Wat' appears in the Remote Console tile.

If 'AC Load' is selected, nothing is displayed in the tile. Is there anything I need to add to the qml files to view this correctly?

Another thing is that if I choose a layout then the old one appears as 'Not connected' and the option 'press to remove'

When I press 'press to remove' the Remote Console freezes and has to run 'killall gui'

It's the same with stock venus-os and guimod

Here is the link to the working file for SDM120M


0 Likes 0 ·
thomasw-1 avatar image thomasw-1 johnny-brusevold ·
Hi Johnny,

it is standard behavour, when you changed the type, that you have to remove the preovius setup in GX.
In terms of missing information I cannot advice you about potential issues, since I have that type not available for test purposes.
There could be potentially an issue that the single phase support is not properly recognized.

0 Likes 0 ·
muffinoch avatar image
muffinoch commented

Hi guys,
my SDM630v2 will not work correctly.

I only sse the following values

1644573900765.pngHas anyone an idea how to fix this problem?

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Hi @Muffinoch ,

This can have various reasons. Beginning from physical connection (termination), Gateway configurations and meter release changes. Therefore your question cannot be answered generically.

In your case I would connect modbus poll and see, if you get reliable results.
If any connectivity issue can be excluded, I assume an incompatibility of your used meter.

0 Likes 0 ·

Hi @ThomasW.
thanks for your support.

I did a test over modbus poll.

I´m not an expert, but for me it looks fine.

I use the Eastron SDM630v2 so I think it should work.


0 Likes 0 ·
1644668954532.png (22.0 KiB)

Have you configured the meter as "3p4w", "3p3w" or differently?
Could you please export holding register "a" (hex) "10" (dec)?

0 Likes 0 ·

Hi @ThomasW.

I configured the Enerymeter as 3p4w.

Here is holding register 10


Here my FC00


Thx for your help

0 Likes 0 ·
1647102464844.png (3.6 KiB)
1647106748734.png (31.5 KiB)

Hi @Muffinoch ,

It seems that you have not configured format "float 32 - big endian" in your export, right?
In that case every second entry would show a hyphen sign.


The FC00 register is ok.

In addition I would recommend to check your stop bit config between meter and ModbusTCP-gateway. Typically standard config is 0 (One stop bit and no parity).

0 Likes 0 ·
1647112557242.png (9.3 KiB)
sgrigor1 avatar image
sgrigor1 commented

Hi, Can someone share the holding register for Eastron SDM630v2 ? Starting from FC00.

I'm wondering if I can configure the modbus simulator with those values to be recognized by RaspPi Venus OS as SmartMeter. I installed the profile for Eastron SDM630v2 in VenusOS.


2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

maspe avatar image
maspe commented

Hi everybody,
my SDM630v2 is not recognized by CerboGX.
With ModbusPoll I can get some values from input registers:modbuspoll-inputregister.pngAnd also some from holding registers:modbuspoll-holding0000.pngBut NOT from FC00 or FC02:
modbuspoll-holding-fc00.pngGuess this is the reason CerboGX is not showing / finding the meter?
Does anybody has any hint what I can do here? Would like to avoid buying a new meter as it is working fine (reading via Modbus from ESP8266 with EspEasy since many months).
Hope someone can help me.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Hi @maspe, could it be that your SDM630 is not a v2, but a v1 device?

Please check register holding register 1c and export the value as unassigned.

0 Likes 0 ·

Hi @thomasw-1, thanks for your reply.
SDM label shows definitvely v2 (maybe fake :-) )
sdm630.png1c holding:
holding-1c.pngWill try now Cerbo with version1
Thanks, Martin

0 Likes 0 ·
sdm630.png (226.2 KiB)
holding-1c.png (8.0 KiB)

You have not the ordinary Eastron meter, but the "BG e-Tech" one.

Relevant modbus-manual does not mention any holding register for that device. Maybe you contact the supplier and try to clarify, where to extract the device type.

I would not exclude that it got another firmware applied.

0 Likes 0 ·

Got a very general answer from GB e-tech:
"during production process it is always possible that firmware is changing, new features are only available on new devices, firmware update is not possible"
So I am lost, my meter is too old :-(
Maybe a stupid question, I'm not a software/Python specialist:
Wouldn't it be possible to change the python script to not ask register FC02 but write directly 112 hard coded in it? Shouln't it be possible that VenusOS is then getting the other (power, current,..) values from meter?

Otherwise I must purchase another meter.

Thanks, Martin

0 Likes 0 ·
alexander-christian avatar image
alexander-christian commented

According to the source code, FC02 should contain the HardwareVersion.... No idea why your's is showing 0.

My citron setup is not yet available (not yet ordered), but I have same meter (SDM630v2). Will check if mine is giving me all required information in all used registers.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

gesiima avatar image
gesiima commented

Hello, great work!
I am using a Janitza UMG604
Modbus table for download
It will be nice if some one can tell me how to begin try to connect this to Venus OS.
I have already connect it to iobroker. To readout the data it was necessary to add 1 to value from that list to get the messured value. Is this normal for modbus?
I am just a user with only that bit of experance in modbus or programming but I am able to understand wat I can see in other profiles.
I tryed out to import and enable all that new profiles and make a autoscan, but as expected, nothing is working.

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Hi gesiima,

in order to implement it into VenusOS you have to write a library that supports that device.
What I can see from its manual, it should be possible, however it the devopment is more than difficult without having the device.

0 Likes 0 ·
alexander-christian avatar image
alexander-christian commented

Just installed VenusOS on an old Pi and tried to setup a connecting to my working SDM630 ModBus v2 with help of an rs485 ethernet gateway (PE11).

I have another software that is able to read data from the meter. But VenusOS with this lib does not do anything. At least it seems so...

/var/log/dbus-modbus-client/current just shows nothing special. If I do the search, I get:

@4000000062a2120c257370c4 INFO     Starting background scan
@4000000062a2120c273d24a4 INFO     Scanning
@4000000062a2127d310391bc INFO     Scan complete

But that's it. Even if I configure an modbus tcp device by hand (correct IP and port used), the logs shows nothing, and VenusOS also shows nothing. No device, no measurement, nothing. Just like ti's not configured/setup at all.

My Ethernet-RS485 gateway just tells me, that there is an open connection, but it seems that no data is transferred.

How can I further debug this?


Checked: FC02 contains "112"


My Protos PE11 RS485->Ethernet converter has a setting for serial communication protocol. My existing application (java based, self developed) works only, if I select "none". To my understanding, "Mosbus Poll" works similar to Venus OS MOdbus TCP... And to get "Modbus Poll" to work, I need to switch from "none" to "modbus". But all in all, I have no idea what the difference is. The serial communicationelectrically RS485, and the protocol that is used to send and read data is Modbus.
So I don't see a reason why I can select the protocol on RS485->Ethernet converter. In any case, the application processing the data needs to use the correct protocol. Okay, anyhow.. If I select "modbus", the Modbus POll application seems to work and I can read data.

But in both cases, VenusOS does not do anything. Right now, I'm completely lost :-(


Ok, getting used to it ... read some date via modpoll

0xfc02 --> 112 (matching v2 model)
0xfc03 --> 0
0x000a --> 3 (3 phase)
0x0014 --> 1 (modbus id)

tested also the single input registers for each phase:

Seems to work for all ... getting a lot of data that updates rapidly. I can read V, A, W, and both kWh (forward/reverse). Also W, A, Hz and the other two kWh can be read...

So, all registers are readable and give me plausible values.

Why is VenusOS not doing anything? Maybe I need to use wireshark to spy my own network to see whats happening.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Hi @alexander-christian, in case register FC02 does only show 0 for your device, then the device simply cannot be discovered. Before you spend any additional time with VenusOS, I recommend to check your connectivity with a Modbus-tool first by testing other common registers of the SDM.

I assume that your rs485-gateway does potentially not work as expected. Any SDM630 meter, which I tested so far, delivered also a model type on that register.

0 Likes 0 ·

> in case register FC02 does only show 0 for your device, then the device simply cannot be discovered

That's simply not the case. Check my update above. All registers, except FC03 (whoch gives me 0) deliver proper values.

The SDM630 is working with this gateway fine for over 18months now.

For further testing, I added a modbus proxy ( between the client and the gateway to see what's happening.

What I can see: VenusOS is repeatingly opening connections .. So some communication is not working. Agt the same time (the proxy is able to handle multiple modbus connections at a time), Modbus Poll is working fine.

0 Likes 0 ·

Tried line by line to add log comments and enable/disable ...

If I do this:

    def __init__(self, *args):
        super(Eastron_SDM630v2, self).__init__(*args)'SDM630v2 info regs START')
        self.info_regs = [
            Reg_u16(0xfc02, '/HardwareVersion'),
            Reg_u16(0xfc03, '/FirmwareVersion'),
#            Reg_f32b(0x000a, '/PhaseConfig', text=phase_configs, write=(0, 3)),
            Reg_u32b(0x0014, '/Serial'),
         ]'SDM630v2 info regs END')        

I added log-output to the init method at start, and at end...

If I follow the log files, I only see the "END" log output, If I disable the line with reading the phase-config.

No idea why. 0x000a is readable and contains value "3" ...
I also tried to dig into "Regf_f32b" ... But I'm not that familiar with python, so I have no idea where to look into. I also grepped the other files for this function name, but nothing...

So I guess it's something with this line or the register... Any hints on that?


If I simply disable the above mentioned line and further con the code do this to hard-code the value to 3:

##        phases = nr_phases[int(['/PhaseConfig'])]
        phases = 3

it almost works... I can see a new device in the UI, and for a short time see also the product ID and firmweare version (0xB023), but a second later it's again gone. "unconnected" and "unknown". A few seconds later it starts from the beginning.

Something is still wrong.


I think I found the issue for the not working Reg_f32b ... in are classes exactly for this things. And there is no Reg_f32b ... Only Reg_f32l ... Think I need to update VenusOS or so ...

Will report back any findings...

0 Likes 0 ·

I updated now to 2.66 on my RaspberryPi.
What am I doing wrong if there is no "Reg_f32b" in, which will then of course fail to execute all float-32bit-bigendian modbus reads...

Need to check how to switch to 2.87 ... because there is no image for this.


Updated to 2.87 ... and the damn class is still missing. wtf?
Is this not working on a Raspberry Pi?

I don't get it... even the latest from github does not contain "Reg_f32b" ... ?!

0 Likes 0 ·
thomasw-1 avatar image thomasw-1 alexander-christian ·

Hi Alex,
Do you have also the "BG eTech" verison as "maspe" (see above comments) in use?
Would explain your restriction.

0 Likes 0 ·
alexander-christian avatar image
alexander-christian commented

OK, starting a new "answer thread" as my last was to messy :-)

I had problems getting SDM630v2 to work with multiple version of VenusOS on my older Raspberry Pi 2.
I debugged a lot and finally think I found the reason: makes use of a class called "Reg_f32b", used to read 32bit float values in BigEndian order. Interestingly, the class was not present/implemented in ...
Also github with it's latest source ( does not contain anything like this. It only contains "Reg_f32l", the little-endian version.

I added this

# added by Alexander Christian        
class Reg_f32b(Reg_num):
    def __init__(self, base, *args, **kwargs):
        super(Reg_f32b, self).__init__(base, 2, *args, **kwargs)
        self.coding = ('>f', '>2H')
        self.scale = float(self.scale)        

just below the Reg_f32l definition in, cleared all .pyc files in cache and rebooted. And .... tada ... My meter works as expected.

Why the hell is this class/definition missing? Am I the only one? Has this been tested before? Has anyone any clue on this?

P.S. I filed a PullRequest on GitHub:

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

"Reg_f32b" is defined in "", which is imported by "", since this method is not available in standard libs. In addition this method is only used to read production parameters, but not those for model identification.

I think you are looking currently into a wrong direction. I strongly assume a support issue of your meter (see my comment before).

In case you are willing to donate 20EUR to charitable organisation, I would be willing to log onto your system trying to locate the route cause after my return on 24.06.

0 Likes 0 ·

Hi Thomas,

as a software engineer, I want 1st to investigate myself.

I check It does not contain a String like "f32b". So I don't see how this is defined in there?!
If I remove my Reg_f32b implementation from, Reg_f32b must come from somewhere else...

Assuming that your that you're refering to is not the one that comes in your, the missing class Reg_f32b must be added.

To get this to work, I added the class and needed to extend one import. Here's the diff:

< from register import Reg
> from register import Reg, Reg_num
> class Reg_f32b(Reg_num):
>     def __init__(self, base, *args, **kwargs):
>         super(Reg_f32b, self).__init__(base, 2, *args, **kwargs)
>         self.coding = ('>f', '>2H')
>         self.scale = float(self.scale)  
< ]
\ Kein Zeilenumbruch am Dateiende.
> ]

I'll attach both files (zipped). The one that comes with the ZIP, and the one that I modified:

I changed nothing else (I of course reverted the changes in

There's no need to remotely visit my system. Just continue the discussion and explain where else the Reg_f32b should be where I don't find it :-)

And yes, saving the ocean is important. Check my donation ...1655028917891.png
Best regards,

P.S. maybe it would be a good idea to host the source on a github/gitlab project? And I'm sure there are ways to solve the "all ins gone in case of venusos update". See:

0 Likes 0 ·

Oh, grepped a bit more... Reg_f32b class is not in, but in ... But somehow it is not recognized?! Without my modification, script will crash/stop/not work as soon as "Reg_f32b" used/accessed (without any further exception or so).

That is really strange. How can the implementation in not see/work with the implementation of Ref_f32b class?! Very confusing.
And even more confusing: My added code in matches the Reg_f32b in ... but mine is working?!

0 Likes 0 ·

Your Opinion Counts

Share your great idea, or help out by voting for other people's ideas.