Help with modbus configuration for SMA TriPower

Hi,

Im a newbie to emonCMS and so far am really enjoying it! I have just recently had 26kW of Solar PV installed which is fed to a 3 phase SMA Sunny TriPower25000 inverter. Currently I have some CT’s reading the generation, but I wanted to pull the data from the ModBus interface if possible.

I’ve configured the emonHub ModBus TCP Interfacer with the IP and port number. I’ve also added the node details for the register. When I restart the emonHub, all is working well and emonCMS is publishing my new node and items as per the configuration. The only trouble is all values are reporting -1 which clearly isn’t right.

I have a link for the register details of the SMA inverter. I note that there is a Device 1 and Device 2, I’ve configured the registers for Device 1 as this is what the TCP interfacer reads by default and that there is possibly a limitation currently that it can only read device id 1.

The actual details I need are on device id 2 according to the SMA documentation, so if this is a limitation currently, I am a bit stuck until it’s resolved, but I wanted to prove the communication method in the mean time.

Would anybody be able to take a look at my configuration below and the SMA documentation to tell me where I am going wrong please?

[[ModbusTCP]]     
    # this interfacer retrieves register information from modbusTCP clients 
    # retrieve register information from modbus TCP documentation for your inverter.
    Type = EmonModbusTcpInterfacer
    [[[init_settings]]]
        modbus_IP = 192.168.5.198   # ip address of client to retrieve data from
        modbus_port = 502          # Portclient listens on
    [[[runtimesettings]]]
        # List of starting registers for items listed above
        register = 30001,30003,30005,30007,30051,30193
        # nodeid used to match with node definition in nodes section below. Can be set to any integer value not previously used.
        nodeId = 27
        # Channel to publish data to should leave as ToEmonCMS
        pubchannels = ToEmonCMS,
        # time in seconds between checks, This is in addition to emonhub_interfacer.run() sleep time of .01
        # use this value to set the frequency of data retrieval from modbus client
        interval = 10 

and in the nodes section…

[[27]]
    nodename = smatripower
    [[[rx]]]
        # list of names of items being retrieved
        # This example retrieves the Inverter status, AC power in watts being produced, AC Lifetime KWh produced,
        # KWh produced for current day,....
        names = sma_profile_number,device_id,serial_no,data_change,device_class,system_time
        datacodes = h,h,h,h,h,h
        scales = 1,1,1,1,1,1
        units = 

link for SMA register details

SMA Modbus Details

Help appreciated as always

Thanks
Barry

Hi Barry,

You might be better running the modbus from a nodered flow. or even better see if you can adapt GitHub - InfernoEmbedded/PowerScraper: A scraper for power devices to feed data to OpenEnergyMonitor

Paul

Hello
you should remove the last line in the node section

units =

You can use

datacode = h

instead of :

datacodes = h,h,h,h,h,h

reading the SMA doc you mention, you are dealing with U32 (unsigned 32bits integer or uint32) and you should use another datacode I or L
so it could be

datacode = I

Registers 30001,30003,3005,30007,30051 and 30193 are on modbus device 1 so there should be no problem but to address the mobdus device 2 on your bus, you should modify your interfacer section with a nUnit command
Moreover, the interfacer was originally coded by @cjthuys by substracting 1 to the registers numbers…don’t know why, I think it should be removed…anyway, you should therefore add 1 to your original registers numbers…

register = 30002,30004,30006,30008,30052,30194,30776
# nodeid used to match with node definition in nodes section below. Can be set to any integer value not previously used.
nodeId = 27
nUnit = 1,1,1,1,1,1,2
# Channel to publish data to should leave as ToEmonCMS
pubchannels = ToEmonCMS,
# time in seconds between checks, This is in addition to emonhub_interfacer.run() sleep time of .01
# use this value to set the frequency of data retrieval from modbus client
interval = 10 

And in the node section

[[27]]
nodename = smatripower
[[[rx]]]
  # list of names of items being retrieved
  names = sma_profile_number,device_id,serial_no,data_change,device_class,system_time,CPW_kwh
  datacodes = I,I,I,I,I,I,i
  scales = 1,1,1,1,1,1,1

in that version, nUnit was added by @btm
see Allow reading Modbus TCP holding registers from multiple units · openenergymonitor/emonhub@d1fd8c2 · GitHub
I’ve got a version which admits singular and plurar keywords for the unit ids, but the one in official OEM library is only plural so you need to give an equal number of unit ids and of registers…If you want to test I can provide this alternative version…

Could you put on line an extract of your emonhub log ?

Please note the interfacer is using modbus function 0x03 (Read Holding Registers). If you need another function (eg Read Input Registers) you need to hardcode it in the interfacer…I can guide you…

tell me if the datacode modification is a solution for your pb…

Alex

These links might be useful:

emonhub/configuration.md at emon-pi · openenergymonitor/emonhub · GitHub or Changing TX NodeID in software | Archived Forum

Note that “Datacodes” are used to interpret values sent as bytes. Values sent as decimal characters (“1234.56”) need no handling - use datacodes = ‘0’

Hi All,

thanks for the replies so far…

Glad to see that if we can get over this that I can address device id 2, for the minute, I’ll stick with getting device id 1 working, even though the useful stuff is in device id 2.

So I tried data code I and L and got the same log output for both codes…

2018-12-16 20:53:49,588 DEBUG ModbusTCP expected bytes number after encoding: 24
2018-12-16 20:53:49,589 DEBUG ModbusTCP datacode I
2018-12-16 20:53:49,589 DEBUG ModbusTCP reading register # :30001, qty #: 2, unit #: 1
2018-12-16 20:53:49,688 ERROR ModbusTCP Connection failed on read of register: 30001 :

2018-12-16 21:00:28,281 DEBUG ModbusTCP expected bytes number after encoding: 24
2018-12-16 21:00:28,282 DEBUG ModbusTCP datacode L
2018-12-16 21:00:28,283 DEBUG ModbusTCP reading register # :30001, qty #: 2, unit #: 1
2018-12-16 21:00:28,429 ERROR ModbusTCP Connection failed on read of register: 30001 :

I also tried, datacode = 0 (tried zero and letter o)

2018-12-16 21:03:52,348 INFO ModbusTCP Not connected, retrying connect{‘modbus_IP’: ‘192.168.5.198’, ‘modbus_port’: ‘502’}
2018-12-16 21:03:52,353 INFO ModbusTCP Opening modbusTCP connection: 502 @ 192.168.5.198
2018-12-16 21:03:52,354 DEBUG ModbusTCP ----------------------------------------------
2018-12-16 21:03:52,355 DEBUG ModbusTCP invalid datacode
2018-12-16 21:03:52,356 DEBUG ModbusTCP ----------------------------------------------

I haven’t had a chance to read through the node red link sent yet, but will make time to do this. I have already reviewed the emonhub configuration link, I used that when I added the configuration initially. I see my error with data type h, being only 2 bytes, whereas the documentation shows 32 bits.

Hopefully the above extracts from the log will help you guide me further?!

Many thanks.
Barry

sorry I forgot to say you have to add 1 to all of your registers numbers
30001 send the interfacer to register 30000 which does not exist
so try with 30002 instead of 30001
Alex

@gadgetbazza : did yu managed to make the interfacer work with your SMA tri power ?

Hi,

apologies for the delay, I’ve not had too much time over the xmas period but have recently picked this back up again.

Thanks for your help thus far. I have been struggling still to read any sensible data out of the Modbus interface. I have however resolved this today after using some of the info provided here and also researching the Sunny TriPower information a bit deeper.

So I know have a better understanding of the emonbase setup thanks to feedback from you guys on here. In particular, the need to add 1 to the register number!

Turns out the document I was using is out of date, and there is better documentation / coverage for wider models / versions of Speedwire interface etc available.

There is also a whole lot more data available! The new documentation also contains information that says all the documented register data is available under unit 3, but unless you actually read the document in detail, you would miss this!

So with the unit set, the correct register numbers (adjusted by 1), I am now showing all the expected data from the ModBus interface which is fantastic news as I can now move the emonTx I have temporarily measuring the solar onto my heat pump so that I have full coverage of my consumption.

Attaching updated Sunny ModBus information for any other users.

SMA_Modbus-de-en_V23.zip (2.6 MB)

Hi all,

I’ve just updated / replaced my SD image with the latest Oct18 image of eMonCMS. I did a backup from my old card installation when it was running and imported it into the new setup.

All the feeds / emon config etc have come across and my emonTx devices along with the Pi are back up and running.

However, my ModBus inputs are no longer updating. I can see the ModBus setup in the emon config, so that all appears to have copied over properly, but there is no evidence of it even trying to run in the emonhub log. Is there something that I needed to add / uncomment for ModBus to work somewhere that I can’t recall?

Thanks
Barry

Is pymodbus installed ?
Best
Alex

1 Like

Thanks @alexandrecuer . I knew it would be something simple, but I couldn’t remember what I needed to install / enable and couldn’t find it using the search!

Installed, rebooted and working now.

Many thanks
Barry

1 Like