Talking to an SMA solar inverter from emonPI and emonCMS - MQTT

If you have a USB bluetooth adapter, you can wirelessly capture data from an SMA solar inverter (I've got a 3000HF model)

The code uses MQTT to push data into emonCMS

https://github.com/stuartpittaway/SMASolarMQTT

​Its useful because it captures both AC and DC power readings directly from the inverter - as well as overall yield in kWh.

In emonCMS, the code mimics the appearance of 4 separate notes numbered 50-53

Its still early days for the code, but it's been running for a few days non-stop now, and captures values such as...

  • ACOutputPhase1
  • ACOutputPhase2
  • ACOutputPhase3
  • ACLineVoltagePhase1
  • ACLineVoltagePhase2
  • ACLineVoltagePhase3
  • ACLineCurrentPhase1
  • ACLineCurrentPhase2
  • ACLineCurrentPhase3
  • ACGridFrequency
  • TotalYield
  • DayYield
  • OperatingTime
  • FeedInTime
  • DCVoltage
  • DCCurrent
  • DCPower

​Please let me know if you find this useful.

bruce_miranda's picture

Re: Talking to an SMA solar inverter from emonPI and emonCMS - MQTT

I don't have a Bluetooth adapter, my SMA was one of the newer ones that came with the inbuilt SunnyPortal Ethernet connection. So it sends information to SunnyPortal.
I have been trying to see if I can intercept the messages for my own logging to cms. So am interested in what you are doing.

stuart's picture

Re: Talking to an SMA solar inverter from emonPI and emonCMS - MQTT

Not seen one of the newer inverters, have you tried monitoring the network using wireshark or something similar?

gloorung's picture

Re: Talking to an SMA solar inverter from emonPI and emonCMS - MQTT

Sounds very interesting ! I've tried your code with a SMA 4000HF. It connects and reads out the values from the invertor correctly (based on the print messages), but I'm having some problems getting the values into emoncms. I can't see any mqtt packets in the emonhub log (debug mode). I don't have the emonPI, but I'm running emoncms v8.5 with the emonpi version of emonhub on an odroid, so mqtt should be enabled. Anything you can think of that I might be doing wrong ?

Ian Eagland's picture

Re: Talking to an SMA solar inverter from emonPI and emonCMS - MQTT

Hi

You might find this thread helpful

http://openenergymonitor.org/emon/node/10746

Regards

Ian

derek_j's picture

Re: Talking to an SMA solar inverter from emonPI and emonCMS - MQTT

Hi

New openenergy monitor user here.  Thanks for the code it was just what I needed for my new SMA 3600 inverter.  It has been working for the last day. All I had to do was define a systemd unit to start it.

 

Observations so far :-

* It was not necessary to start the bluetooth service. It runs without it.

* My bluetooth dongle is very temperamental. It is not recognised from boot, I have to unplug and reinsert it.  Also it often disappears while in use and has to be plugged back in again.  It would be handy if there was a way to 'virtually' unplug it from the command line.  Maybe I should just buy a new dongle.

* Node 51 DC_Watts is commented out in the code, but if I uncomment it it works OK

* For reasons I do not understand emoncms lists 10 items in Node51 each item is named with one letter of the words 'SolarDCWatts'

* The code does not retrieve separate DC information for the two strings of solar panels.

 

derek_j's picture

Re: Talking to an SMA solar inverter from emonPI and emonCMS - MQTT

I worked out how to get information on the DC strings.  The data was alteady being collected, but was just not being published.

 

In SMASolarMQTT.py  from line 171

                    print("dc v/a")
                    # These values only update every 5 mins by the inverter.
                    #0x451f String1 DC Voltage V
                    #0x4521 String1 DC Voltage V
            #String1 DC Current A
            #String2 DC Current A
                    L2 = SMASolarMQTT_library.spotvalues_dc(btSocket, packet_send_counter, mylocalBTAddress,
                                                            InverterCodeArray,
                                                            AddressFFFFFFFF)
                    packet_send_counter += 1
                    payload = "{0},{1},{2},{3}".format(L2[1][1], L2[2][1], L2[3][1], L2[4][1])
                    client.publish(topic_spotvalues_dc, payload=payload, qos=0, retain=False)
                    time.sleep(1)

 

 

and in emonhub.conf

[[53]]
    nodename = SMASolarMQTT_DC
    firmware = not_applicable
    hardware = not_applicable
    [[[rx]]]
       names = String1_DCVoltage, String2_DCVoltage, String1_DCCurrent, String2_DCCurrent
       datacode = h
       scales = 1,1,1,1
       units =V,V,A,A

 

This works in my SMA3600. I do not know if it would be the same in other inverters

 

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.