Logging SolarEdge inverter data using MODBUS over TCP

Hi @the_phil_pxie and @richardsmith99 - sorry I’m out of the country until April at the moment so I’m not able to ssh into my emonpi to confirm the full path. You could try using the linux find command to search for the file location. If you’re still stuck hopefully someone else in the community can point you in the right direction.

Justin.

I’ve created a new emoncms module called processext (short for process extension) that includes both input processors contributed by @justinknight, it’s available for download here: https://github.com/emoncms/processext and just needs to be placed in the /var/www/emoncms/Modules directory to work.

Hopefully that will make things easier for you @richardsmith99

1 Like

Thank you so much for your help! I’ve had a massive break through (don’t laugh!) when I managed to find a program called WinSCP which connects into the pi and lets me view files and move them to/from the laptop.

Anyway - feeling pleased with myself I’ve added the processext_processlist.php into a new folder and nearly jumped for joy when the process appeared in emoncms for me!

The downside is I can’t make it work…

I’ve gone to the ac_total_current input, and added the pow10 input function, and chosen ac_current_scale_factor but the result seems to come out as -2.00 (which is the current scale factor). Adding a log to feed just produces a feed with NULL in the feeds tab. I’ve tried this with a few different ones just to make sure there’s no quirk and it’s producing the same result… So I’m back to feeling stupid again! :thinking:

Update! I’ve added the dual-register reading method that Justin came up with for reading the power (as a test for now) and unpacked it with the value and scale process and it’s producing a result that looks correct (for the gloomy day we are having at least!) - 209W currently!

1 Like

Great to hear that the dual-register approach is working!

1 Like

Yes. I’m not sure why the power10 function isn’t working - it’s only really needed for reading the AC current - where the current and scale factors aren’t in adjacent registers, and it’s not particularly important to me to read that.

Next job is to move the CT from the solar feed onto the battery so I can monitor the flows there :slightly_smiling_face:

Hi Richard - glad you got it working!

I think before you were applying the power10 function to the scale factor, but also needed to multiply it by the actual value before logging the result.

Using as you have it set up now should give you better results though.

Hmmm… I shall have another look at it. It’d be worth getting it to work as there’s a couple of things with non-adjacent registers (AC Current, Heat sink temp for example). Also - sitting reading the SE spec notes, the ‘lifetime energy’ is available - but that has two registers (I think? It says size is 2 and the type shows acc32) as well as the scale factor.

I think I need to go to work for a rest on my brain now!

So I have added the code, however, I am getting this error.

2022-06-24 20:36:50,951 INFO     ModbusTCP  Not connected, retrying connect {'modbus_IP': '192.168.12.11', 'modbus_port': '502'}
2022-06-24 20:36:50,954 INFO     ModbusTCP  Opening modbusTCP connection: 502 @ 192.168.12.11
2022-06-24 20:36:50,956 DEBUG    ModbusTCP  expected bytes number after encoding: 36
2022-06-24 20:36:50,956 DEBUG    ModbusTCP  datacode H
2022-06-24 20:36:50,957 DEBUG    ModbusTCP  reading register #: 40072, qty #: 1, unit #: 1
2022-06-24 20:36:53,962 ERROR    ModbusTCP  Connection failed on read of register: 40072 : 'ModbusIOException' object has no attribute 'function_code'
2022-06-24 20:36:54,795 DEBUG    RFM2Pi     38 NEW FRAME : OK 5 227 1 50 0 21 2 51 94 107 2 240 0 99 2 0 0 0 0 0 0 7 0 0 0 (-0)
2022-06-24 20:36:54,798 DEBUG    RFM2Pi     38 Timestamp : 1656099414.795486
2022-06-24 20:36:54,799 DEBUG    RFM2Pi     38 From Node : 5
2022-06-24 20:36:54,799 DEBUG    RFM2Pi     38    Values : [483, 50, 533, 241.15, 61.900000000000006, 24, 61.1, 0, 0, 0, 7]
2022-06-24 20:36:54,800 DEBUG    RFM2Pi     38 Sent to channel(start)' : ToEmonCMS
2022-06-24 20:36:54,801 DEBUG    RFM2Pi     38 Sent to channel(end)' : ToEmonCMS
2022-06-24 20:36:54,980 DEBUG    MQTT       Publishing: emon/emonpi/power1 483
2022-06-24 20:36:54,982 DEBUG    MQTT       Publishing: emon/emonpi/power2 50
2022-06-24 20:36:54,983 DEBUG    MQTT       Publishing: emon/emonpi/power1pluspower2 533
2022-06-24 20:36:54,984 DEBUG    MQTT       Publishing: emon/emonpi/vrms 241.15
2022-06-24 20:36:54,986 DEBUG    MQTT       Publishing: emon/emonpi/t1 61.900000000000006
2022-06-24 20:36:54,987 DEBUG    MQTT       Publishing: emon/emonpi/t2 24
2022-06-24 20:36:54,989 DEBUG    MQTT       Publishing: emon/emonpi/t3 61.1
2022-06-24 20:36:54,990 DEBUG    MQTT       Publishing: emon/emonpi/t4 0
2022-06-24 20:36:54,991 DEBUG    MQTT       Publishing: emon/emonpi/t5 0
2022-06-24 20:36:54,993 DEBUG    MQTT       Publishing: emon/emonpi/t6 0
2022-06-24 20:36:54,994 DEBUG    MQTT       Publishing: emon/emonpi/pulsecount 7
2022-06-24 20:36:54,995 INFO     MQTT       Publishing 'node' formatted msg
2022-06-24 20:36:54,996 DEBUG    MQTT       Publishing: emonhub/rx/5/values 483,50,533,241.15,61.900000000000006,24,61.1,0,0,0,7

Can you help,

ERROR ModbusTCP Connection failed on read of register: 40072 : ‘ModbusIOException’ object has no attribute ‘function_code’

Cheers
Don

I am now getting data, but need guidance on how to get the corrected values

Hi Don,
first add ac_power_combined to your emonhub.conf, note additional value at end of rName, register, nReg and rType lines:

[[ModbusTCP]]

    # this interfacer retrieves register information from modbusTCP clients 

    # retrieve register information from modbus TCP documentation for your inverter.

    # Information here is designed for Fronius Symo 3 phase inverter.

    Type = EmonModbusTcpInterfacer

    [[[init_settings]]]

        modbus_IP = 192.168.178.36   # ip address of client to retrieve data from

        modbus_port = 502          # Portclient listens on

    [[[runtimesettings]]]

        # list of names of items being retrieved

#        rName = DC_Current_1,DC_Voltage_1,DC_Current_2,DC_Voltage_2,Power,AC_Current,Frequency,Temperature,Residual_Current,Total_Yield,Daily_Yield

        rName = I_AC_Current,I_AC_Current_SF,I_AC_Power,I_AC_Power_SF,I_AC_VA,I_AC_VA_SF,I_AC_VAR,I_AC_VAR_SF,I_AC_PF,I_AC_PF_SF,I_DC_Current,I_DC_Current_SF,I_DC_Voltage,I_DC_Voltage_SF,I_DC_Power,I_DC_Power_SF,I_Temp_Sink,I_Temp_Sink_SF,I_AC_Power_Combined

        # List of starting registers for items listed above

#        register = 30769,30771,30957,30959,30775,30795,30803,30953,31247,30513,30517

        register = 40072,40076,40084,40085,40088,40089,40090,40091,40092,40093,40097,40098,40099,40100,40101,40102,40104,40107,40084

        # List of # of registers used for each item 

#        nReg = 1,1,1,1,1,1,1,1,1,1,1

        nReg = 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2

        # Data type for each item above

#        rType = float32,float32,float32,float32,float32,unint32,unint32,float32,float32,uint64,uint64

        rType = uint16,int16,int16,int16,int16,int16,int16,int16,int16,int16,uint16,int16,uint16,int16,int16,int16,int16,int16,uint32

        # 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 = 1

and a matching node section at the end of the file:

[[27]]
    nodename = inverter
    [[[rx]]]
        names = ac_total_current,ac_current_scale_factor,ac_power_value,ac_power_scale_factor,apparent_power,apparent_power_scale_factor,reactive_power,reactive_power_scale_factor,power_factor,power_factor_scale_factor,dc_current,dc_current_scale_factor,dc_voltage,dc_voltage_scale_factor,dc_power,dc_power_scale_factor,heat_sink_temperature,heat_sink_temperature_scale_factor,ac_power_combined
        datacodes = H,h,h,h,h,h,h,h,h,h,H,h,H,h,h,h,h,h,i
        scales = 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
        units = A,n,W,n,VA,n,VAR,n,%,n,A,n,V,n,W,n,C,n,n

You should see the new input in emoncms:

To unpack the value you need the “value and scale” process from the proccessext module (see installation instructions here: GitHub - emoncms/processext: Additional emoncms input processors)

This is my process list for the solar inverter input:

The first two values calculate and log the current power output of the solar. The 3rd process creates a KwH value, 4-6 adds non-solar input to creates total electricity usage in W and kwH. 7-9 subtract the energy used by our heatpump to give a feed of just electricty used by rest of the house.

Kind regards,
Justin.

1 Like