Blog

The thoughts, opinions, happenings, and just plain ramblings of a seemingly boring person.

Logging Solar Inverter Output with a Raspberry Pi

We've had a 3kW solar array on top of our house ever since we built it about 6 years ago.

Solar panels on our roof. Look at that perfectly competent builder person!

It came to our attention recently that one of our 12 solar panels had shattered glass (seemingly for a while), something you can even see from the latest Google Maps satellite imagery.

dodgy solar panel
Detective work; just like on CSI.

Surprisingly, when we had some guys out to replace it, it is pretty much impossible to source another panel with a similar voltage and current that wouldn't drastically affect the rest of the array. So we ended up just removing the broken panel.

It came to mind that, other than random glances at the inverter's basic LCD display, I had no idea if our solar system is performing as it should. As our inverter (a Samil Solar River SR3K3TLA1) is an old and fairly basic model, it doesn't have fancy wireless/network logging or monitoring, and pretty much only records the total output for the current day (which is reset each day), and the lifetime total output of the inverter.

The only method of external monitoring is through a serial data connection over RS485 or RS232, i.e. the good old serial port that computers have largely ditched for well over a decade.

Sensing the opportunity for a project, I googled around for some monitoring mechanisms. The most popular was having a small computer hooked up to the inverter using a serial cable, and then uploading the data to the online PVOutput service for storage and analysis.

Our inverter (blue box) with the Raspberry Pi attached (the little white box).
Our inverter (the blue box) with the Raspberry Pi attached (the little white box).

I've been waiting to have a decent use case for doing something with a Raspberry Pi, and this seemed a perfect fit: something extremely low-powered that I could stick on the wall (our inverter is inside our garage). I ordered the Raspberry Pi starter kit (which includes the official case, power supply, and SD card in addition to the Raspberry Pi 3 Model B) from Core Electronics, and it was delivered a few days later. The last piece of the pie (ha ๐Ÿ˜‰ ) was a basic serial to USB cable.

For the script itself, I found a lot of references to a perl script from a forum called Solar Freaks, but the website seems to now be defunct. Luckily, some kind person had uploaded the script onto GitHub, so I promptly forked it and went to work.

I have to acknowledge this fantastic post for tips on how to use this script for a Samil inverter, as well as modifying it to run as a cron instead of a looping program. Most of the changes recommended there I have made in my own GitHub repository for the project.

You can find my fork on GitHub.

For a similar Samil inverter, the latest commit from my fork should work fine on a Raspberry Pi, although there are also config files included for some other manufacturers' inverters.

Here are the steps I needed to do to get it working:

  1. On your Raspberry Pi, install the required Perl modules (Perl should already be installed by default on Raspbian).
    1. Open the Perl CPAN module manager:
      sudo cpan
    2. Install the modules:
      install AppConfig Device::SerialPort HTTP::Request::Common LWP::UserAgent
    3. Exit CPAN to return to the bash terminal:
      exit
  2. Download the script from my GitHub repository and extract it to your Raspberry Pi home directory.
    The script assumes that it resides in /home/pi/inverter_monitor/ , but you can put it anywhere and change the paths in config.ini, inverter.pl, and runSolarStats.sh (there should only be a few mentions of the path).
  3. In pvoutput.pl, insert your own PVOuput user account details for your system ID, inverter serial number, and API key:
    my @PVOUTPUT = (
     {
      SERIAL_NUM    => "<REPLACE WITH YOUR INVERTER SERIAL NUMBER>",
      API_KEY       => "<REPLACE WITH YOUR PVOutput API KEY>",
      SYSTEM_ID     => "<REPLACE WITH YOUR PVOutput SYSTEM ID>",
     },
    );
  4. Run the script and see if it works:
    bash runSolarStats.sh
  5. Create a cron so that the script runs according to your desired schedule. I used the following which runs it every 5 minutes between 4am and 8pm:
    */5 4-19 * * * bash /home/pi/inverter_monitor/runSolarStats.sh

That should be it! You can see my system's live output data on PVOutput.org. Below is a graph of yesterday's output.

Let me know if this helps you, and feel free to fork my version of the script for your needs! ๐Ÿ™‚

64 thoughts on “Logging Solar Inverter Output with a Raspberry Pi”

  1. Hi Lucas,
    Thanks so much for your informative post!
    At Christmas 2017 I have a very similar epiphany and have sourced code to connect my Australian Orion 2.5 kW (aka Phenotexic) inverter to the Raspberry Pi via the RS 232 port/USB.
    Have had great success.. to a point.
    I am now running your run SolarStats shell and that is creating nice current logs and cumulative data tables at 5 minutely intervals.

    My problems are now uploading to the PV output.org site. How do you run the live feed to the site ( I have configured the pvoutput.pl with my API and id number.) When I run this in the terminal it seems to indicate I had an unauthorised number near the serial number ( line 88) or there abouts.
    I then added the pvoutput file to the run stats to see if I could drive 5 minutely uploads. The "current" file in my log indicates that it has run the file...but my outputs in pv output look odd.

    Do you have any other comment son how you achieved the pvoutput link?
    I have also been trying to get the rrdtool to work and have struggled with that as well.

    I will keep trying, but i just thought I would see if you had any other advice or recollections on how you made this work.
    Cheers - and thanks again.

    Chris

    Reply
  2. No worries, Chris! Glad you found it useful!

    Line 88 of pvoutput.pl is checking the serial number of the inverter, which you need to specify on line 59. Are you sure you have provided the inverter serial number correctly on line 59? (you will also need to specify your PVoutput API key and System ID on lines 60 and 61 respectively).

    The inverter serial number is mainly if you are running multiple inverters, but even if you are running one inverter, the script still needs you to provide it.

    I hope this helps!

    Reply
  3. Thanks, Andrew! I haven't had any experience with an ESP8266, but if it can run a Linux-like OS, it should be able to use my version of the script as long as Perl can run on it.

    You could try modifying the script that you link: as long as you can match the specific values that the inverter outputs via the serial cable to a value that PVoutput uses, it _should_ be possible.

    But that probably sounds a lot easier than what might be required (it almost always is... ๐Ÿ™‚ )

    Reply
  4. No worries! BTW, have you tried comms over RS485 on the Samil? Iโ€™m struggling to get anything from that interface for some reason. I wonder if it has to be โ€˜enabledโ€™ in some way?

    Reply
    • Iโ€™ve managed to get some output over RS485. I had been struggling for a few days, using a USB TTL serial adaptor and a TTL to RS485 module. Basically going from 2 wire to 4 wire on the Samil. I finally realised I had to tie both +ve and -ve wires on the 4 wire to allow 2 wire comms.

      Now to try and adapt the fellas code to suit the Samil and Iโ€™ll have a ESP8266 solution with MQTT to integrate with my smart home build!

      Reply
  5. Nice work!

    If it helps, below is a log from my script if it helps you match up the output data to the values you want (inverter serial number is redacted). You can see at the bottom that the script only sends a few data points to PVoutput.

    Starting up at 04/08/2018 09:40:01 running on linux ...
    Initialise Serial Port... port = /dev/ttyUSB0
    Send -> req init inverter: 55aa000000000004000103
    Send -> req serial: 55aa0000000000000000ff
    Recv <- 55aa0000000000800a5333333131365234353203c7 
    Send -> confirm serial: 55aa0000000000010b5333333131365234353201034a  
    Recv <- 55aa00010000008101060188 
    Send -> req version: 55aa000000010103000104
    Recv <- 55aa000100000183403120203330303056312e3030536f6c6172526976657220332e334b5753414d494c504f57455220202020202053333331313652343532000000000000333630301036 
    CAPACITY : 3000
    FIRMWARE : V1.00
    MANUF    : SAMILPOWER
    MODEL    : SolarRiver 3.3KW
    OTHER    : 3600
    SERIAL   : XXXXXXXXXXXX
    Send -> req param format: 55aa000000010101000158
    Recv <- 55aa00010000018101000183 
    * Parameter Format:
    dataToFollow = hex(01) = 1
     9 = 00
    Send -> req params: 55aa00000001010400015b
    Recv <- 55aa00010000018401000186 
    * Parameters:
    Send -> req data format: 55aa000000010100000101
    Recv <- 55aa00010000018014000104090a0c111213161718313233343536373803d8 
    * Data Format:
    dataToFollow = hex(14) = 20
     9 = 00 = TEMP     =  0 = Internal Temperature
    10 = 01 = VPV1     =  1 = Panel 1 Voltage
    11 = 04 = IPV1     =  2 = Panel 1 DC Current
    12 = 09 = ETOTALH  =  3 = Accumulated Energy (high bit)
    13 = 0a = HTOTALL  =  4 = Working Hours (low bit)
    14 = 0c = MODE     =  5 = Operating Mode
    15 = 11 = ETODAY   =  6 = Accumulated Energy Today
    16 = 12 = HTOTALH  =  7 = Working Hours (high bit)
    17 = 13 = ERR_GV   =  8 = Error message: GV fault value?
    18 = 16 = ERR_GF   =  9 = Error message: GF fault value?
    19 = 17 = ERR_GZ   = 10 = Error message: GZ fault value?
    20 = 18 = ERR_TEMP = 11 = Error message: Tmp fault value?
    21 = 31 = IAC      = 12 = Grid Current
    22 = 32 = VAC      = 13 = Grid Voltage
    23 = 33 = FAC      = 14 = Grid Frequency
    24 = 34 = PAC      = 15 = Output Power
    25 = 35 = ERR_PV1  = 16 = Error message: PV1 fault value?
    26 = 36 = ETOTALL  = 17 = Accumulated Energy (low bit)
    27 = 37 = ERR_GFC1 = 18 = Error message: GFC1 fault value?
    28 = 38 = ERR_MODE = 19 = Error mode?
    Send -> req data as at 04/08/2018 09:40:08 : 55aa000000010102000103
    Recv <- 55aa000100000182280159099e003300006ebc010300e200000000000000000000003709aa139205400004348c000000000787 
    * Data:
    TEMP    :     34.5 deg C = Internal Temperature 
    VPV1    :    246.2 V     = Panel 1 Voltage 
    IPV1    :      5.1 A     = Panel 1 DC Current 
    ETOTALH :        0 kWh   = Accumulated Energy (high bit) 
    HTOTALL :    28348 hrs   = Working Hours (low bit) 
    MODE    :      259       = Operating Mode 
    ETODAY  :     2.26 kWh   = Accumulated Energy Today 
    HTOTALH :        0 hrs   = Working Hours (high bit) 
    ERR_GV  :        0       = Error message: GV fault value? 
    ERR_GF  :        0       = Error message: GF fault value? 
    ERR_GZ  :        0       = Error message: GZ fault value? 
    ERR_TEMP:        0       = Error message: Tmp fault value? 
    IAC     :      5.5 A     = Grid Current 
    VAC     :    247.4 V     = Grid Voltage 
    FAC     :     50.1 Hz    = Grid Frequency 
    PAC     :     1344 W     = Output Power 
    ERR_PV1 :        4       = Error message: PV1 fault value? 
    ETOTALL :   1345.2 kWh   = Accumulated Energy (low bit) 
    ERR_GFC1:        0       = Error message: GFC1 fault value? 
    ERR_MODE:        0       = Error mode? 
    Logging to: /home/pi/inverter_monitor/logs/inverter_XXXXXXXX_20180804.csv
    PVOUTPUT as at 04/08/2018 09:40:09 ...
      ran: /usr/bin/perl /home/pi/inverter_monitor/pvoutput.pl 2260 1344 20180804 09:40 XXXXXXXXXX 246.2 34.5
    Sending to PVOUTPUT [ d => 20180804, t => 09:40, v1 => 2260, v2 => 1344 ]
    
    Reply
  6. Hmm interesting, so only time, date, etoday and pac values by the look of it, much less than I thought!

    Thanks Lucas, will see how I go with this code. ๐Ÿ™‚

    Reply
  7. Hi Lucas,
    Thanks for your site, an interesting article. I'm trying to do similar, using your instructions as guidance. I an absolute newbie wrt raspberry pi and linux.
    I have a query.
    I have followed your page and have a pi zero w attached to the inverter. However, when running the bash command the following error results:
    runSolarStats.sh: line 1: /home/pi/inverter_monitor/logs/current.txt: No such file or directory
    Can you point me in the right direction to this little problem?
    Thanks in advance.
    Rob

    Reply
  8. Hi Robert!

    Hmmm, you might need to manually create the directory it is trying to write the logs to (/home/pi/inverter_monitor/logs/). Try creating that directory and running it again.

    Reply
  9. Hi Lucas,

    Thanks for the post, changed over to the pi today to replace an old Asus eeepc that was doing this. Your instructions worked like a charm and it working happily, whilst drawing less power

    Brad

    Reply
  10. Great work on this blog Lucas!
    I have only just discovered this after my EEEpc finally failed with HDD issues.
    I too have a "newbie question" that I am not sure of.
    In the following lines, what option is replaced with the serial number?
    Options
    1. SERIAL_NUM => "",
    2. SERIAL_NUM => "S501xxxxxx",
    3. SERIAL_NUM => S501xxxxxx,
    4. S501xxxxxx => "",
    I have found some information on-line but not in this application!
    Cheers
    Andy

    Reply
  11. Sorry Lucas,
    That previous Question did not appear exactly as I typed it.
    Do I need to include all of the punctuation or just replace the text?
    I hope this makes sense!
    Cheers
    Andy

    Reply
  12. That's my problem, I wasn't including the inverted commas!
    Just another thing that may help others, I had to modify some of the files where it referred to "inverter_monitor" to "inverter_monitor-master". Not exactly sure if it was something that I cause during my learning process but was quite satisfied when I discovered & fixed it.
    Thanks again for all of your help!
    Andy

    Reply
  13. Great to hear, Andy! Hmm, it looks like GitHub is appending the name of the version branch (master) to the folder. You can just rename the folder if that is easier ๐Ÿ™‚

    Reply
  14. Hi!
    Thank you for this project! I dodnt need much to bring it to work.

    I have opne little Problem:
    Every few Minutes, i cannot connect. I didnt find out why.

    Any Idea?

    Michael

    * Data:
    TEMP : 59.6 deg C = Internal Temperature
    VPV1 : 286.8 V = Panel 1 Voltage
    IPV1 : 10.9 A = Panel 1 DC Current
    ETOTALH : 0 kWh = Accumulated Energy (high bit)
    HTOTALL : 38235 hrs = Working Hours (low bit)
    MODE : 261 = Operating Mode
    ETODAY : 29.52 kWh = Accumulated Energy Today
    HTOTALH : 0 hrs = Working Hours (high bit)
    ERR_GV : 0 = Error message: GV fault value?
    ERR_GF : 0 = Error message: GF fault value?
    ERR_GZ : 0 = Error message: GZ fault value?
    ERR_TEMP: 0 = Error message: Tmp fault value?
    IAC : 13.5 A = Grid Current
    VAC : 237.7 V = Grid Voltage
    FAC : 50.04 Hz = Grid Frequency
    PAC : 3306 W = Output Power
    ERR_PV1 : 7 = Error message: PV1 fault value?
    ETOTALL : 4681 kWh = Accumulated Energy (low bit)
    ERR_GFC1: 0 = Error message: GFC1 fault value?
    ERR_MODE: 0 = Error mode?
    Logging to: /home/pi/inverter_monitor/logs/inverter_S50106L009_20190501.csv
    tail: current.txt: Datei abgeschnitten
    Starting up at 01/05/2019 17:21:03 running on linux ...
    Initialise Serial Port... port = /dev/ttyUSB0
    Send -> req init inverter: 55aa000000000004000103
    Send -> req serial: 55aa0000000000000000ff
    Waited 5 seconds and never saw 55aa0000000000800a
    noTalks=1, reInits=0.
    Sleeping: 10 secs as at 01/05/2019 17:21:09 ...
    Re-Init attempt 1...
    Starting up at 01/05/2019 17:21:19 running on linux ...
    Initialise Serial Port... port = /dev/ttyUSB0
    Send -> req init inverter: 55aa000000000004000103
    Send -> req serial: 55aa0000000000000000ff
    Waited 5 seconds and never saw 55aa0000000000800a
    noTalks=1, reInits=1.
    Sleeping: 10 secs as at 01/05/2019 17:21:24 ...
    Re-Init attempt 2...
    Starting up at 01/05/2019 17:21:34 running on linux ...
    Initialise Serial Port... port = /dev/ttyUSB0
    Send -> req init inverter: 55aa000000000004000103
    Send -> req serial: 55aa0000000000000000ff
    Waited 5 seconds and never saw 55aa0000000000800a
    noTalks=1, reInits=2.
    tail: current.txt: Datei abgeschnitten
    Starting up at 01/05/2019 17:22:03 running on linux ...
    Initialise Serial Port... port = /dev/ttyUSB0
    Send -> req init inverter: 55aa000000000004000103
    Send -> req serial: 55aa0000000000000000ff
    Waited 5 seconds and never saw 55aa0000000000800a
    noTalks=1, reInits=0.
    Sleeping: 10 secs as at 01/05/2019 17:22:09 ...
    Re-Init attempt 1...
    Starting up at 01/05/2019 17:22:19 running on linux ...
    Initialise Serial Port... port = /dev/ttyUSB0
    Send -> req init inverter: 55aa000000000004000103
    Send -> req serial: 55aa0000000000000000ff
    Waited 5 seconds and never saw 55aa0000000000800a
    noTalks=1, reInits=1.
    Sleeping: 10 secs as at 01/05/2019 17:22:24 ...
    Re-Init attempt 2...
    Starting up at 01/05/2019 17:22:34 running on linux ...
    Initialise Serial Port... port = /dev/ttyUSB0
    Send -> req init inverter: 55aa000000000004000103
    Send -> req serial: 55aa0000000000000000ff
    Waited 5 seconds and never saw 55aa0000000000800a
    noTalks=1, reInits=2.
    tail: current.txt: Datei abgeschnitten
    Starting up at 01/05/2019 17:23:03 running on linux ...
    Initialise Serial Port... port = /dev/ttyUSB0
    Send -> req init inverter: 55aa000000000004000103
    Send -> req serial: 55aa0000000000000000ff
    Waited 5 seconds and never saw 55aa0000000000800a
    noTalks=1, reInits=0.
    Sleeping: 10 secs as at 01/05/2019 17:23:09 ...
    Re-Init attempt 1...
    Starting up at 01/05/2019 17:23:19 running on linux ...
    Initialise Serial Port... port = /dev/ttyUSB0
    Send -> req init inverter: 55aa000000000004000103
    Send -> req serial: 55aa0000000000000000ff
    Waited 5 seconds and never saw 55aa0000000000800a
    noTalks=1, reInits=1.
    Sleeping: 10 secs as at 01/05/2019 17:23:24 ...
    Re-Init attempt 2...
    Starting up at 01/05/2019 17:23:34 running on linux ...
    Initialise Serial Port... port = /dev/ttyUSB0
    Send -> req init inverter: 55aa000000000004000103
    Send -> req serial: 55aa0000000000000000ff
    Waited 5 seconds and never saw 55aa0000000000800a
    noTalks=1, reInits=2.

    Reply
  15. Hi Michael!

    Sorry for the delayed response, I've been in hospital since last week :(.

    I'm not sure what could be causing that... it looks like it can't see the inverter over the serial port when it's trying to connect. Do you have another USB-to-serial cable to to test with?

    It's weird that sometimes it works and other times it doesn't.

    Reply
  16. Thanks for your script, working perfectly here.
    Some info that may help others:
    I connected via the rs485 port, which on the samil means twisting the tx+ and rx+ together, and also twisting the tx- and rx- together as well. Using a cheap usb-rs485 converter, connect the two twisted positives to the A, or + side of the adapter, and connecting the two negatives to the B, or - side.
    Your script opens USB0 perfectly, and communicates no problem.
    I also tried connecting using all four wires as an rs422 connection, as the samil appears to have the correct 4 wires (tx+,tx-,rx+,rx-). It wouldn't connect, so twisted the wires back togther, and went back to rs485.
    Many thanks.

    Reply
  17. It's only been running 24 hours, but it got me wondering if the old daily files are deleted? It won't take long to fill a small sd card. I'll keep my eye on it, and if necessary, create a cronjob delete.

    Reply
  18. Hi again,
    I created a cronjob that might be of use to others.
    Run crontab -e and add this line to the bottom of the file (leave a space between it and the preceeding line):

    0 22 * * * find /home/pi/inverter_monitor/logs/ -depth -mindepth 1 -mtime +3 -delete

    That will run at 22:00 hours every day, and delete files older than 3 days.
    Hope this is useful?
    Thanks for the script Lucas, working perfectly.

    Reply
  19. Will this work on older Raspberryโ€™s?
    Like the Model 2 B+?

    Yep, the script should work on any Pi that you can run Raspbian+Perl on and can connect a serial port to (e.g. using a serial-to-USB cable)! ๐Ÿ‘

    Reply
  20. Hello again,
    I've been trying to work out if I could add the panel voltage to the uploaded data. I'm a complete noob at coding, but it does appear that the panel voltage is drawn from the samil inverter (ie VPV1 : 286.8 V = Panel 1 Voltage). I don't want to bork the script by dropping the wrong code into it. Is this possible, has anyone got any pointers?
    Thanks in advance.
    Phil

    Reply
  21. Hi Phil,

    It looks like it should be possible (and probably relatively easy ๐Ÿš€). It looks like the upload script is already being fed the voltage data, so we should be able to just edit a few lines to make it upload it to PVOutput.

    I haven't tested it myself, but hopefully the changes to the pvoutput.pl file shown here should work.

    You can either apply those few changes manually, or download/copy the whole changed file here. (Note that if you download the whole file, you'll need to re-add your PVoutput configuration to it.)

    Reply
  22. It threw an error:

    Global symbol "$voltage" requires explicit package name (did you forget to decla re "my $voltage"?) at /home/pi/inverter_monitor/pvoutput.pl line 101.
    Global symbol "$voltage" requires explicit package name (did you forget to decla re "my $voltage"?) at /home/pi/inverter_monitor/pvoutput.pl line 102.
    Execution of /home/pi/inverter_monitor/pvoutput.pl aborted due to compilation er rors.

    Reply
  23. Followed all the steps, now testing:
    bash runSolarStats.sh
    Can't open /dev/ttyUSB0: No such file or directory at /home/pi/inverter_monitor/inverter.pl line 857.

    Is that because I do not have anything connected yet? So it will work when I connect my Solar Inverter to the Pi?

    Also, what is the exact procedure for creating a cron job deleting the log-files. Im a noob ๐Ÿ™‚

    Reply
  24. Already figured out how to create cronjobs, google is my friend ๐Ÿ™‚
    Leaves the first question. I hope to connect to my inverter this evening.

    Reply
  25. Hi Jacob,
    I tested my setup before the USB dongle arrived, and it threw the same error. The script is looking for USB0, and can't find it (presumably because you've not plugged it in yet?).
    When my adapter arrived, I plugged it in, and it worked straight away.
    Phil

    Reply
  26. Ok, thnx for answering. When testing there was nothing plugged in. Finished the install of my PV setup this evening. Will find out if the setup is working tomorrow.๐ŸŒž

    Reply
  27. Sadly it's not working, no data in PVoutput. Checked the inverter before I left home and it's generating. Unable to debug because I'm not at home and no portforwarding to ssh, will have to debug later. Will come back here for further help I'm afraid.
    Keep up the good work!

    Reply
  28. Looks like the serial to usb connection to the Pi is working and also the cronjobs to get the data from the inverter. Seeing this kind of data in 20200527-output.txt:
    Send -> req data as at 27/05/2020 08:35:08 : 55aa000000010102000103
    Recv "S23143X099"

    Do I need to set something in PVoutput?
    Can someone point me in the right direction?

    Reply
  29. @Jacob Have you edited pvoutput to add your user details?
    It's step 3 in the instructions above. I got my inverter serial number off the box the inverter came in. To get your api key and system ID, log into your pvoutput.org account, click settings, scroll to the bottom, and they are listed there. If there is no api key listed, click the new key button, and it will generate one for you. System ID is at the very bottom next to your username. Copy and paste those into pvoutput.pl, save it, and give that a try.
    I use winscp to edit the file.

    Reply
  30. Here's mine (for security, I've replaced most of the characters):

    # Array of Hashes of pvoutput information for each inverter - add more as required (in extra curly braces)
    #
    my @PVOUTPUT = (
    {
    SERIAL_NUM => "S3XXXXX003",
    API_KEY => "dbee9d8XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXb84",
    SYSTEM_ID => "7XXX4",
    },
    );

    Reply
  31. Hi guys, thnx for your input. I did edit that file. It was lost in my previous comment somehow. I doublechecked that already. In my case I have 2 PV systems. 1st one is a Solaredge, works fine with OVoutput. For the Samil system, I donated to be able to add a 2nd system to PVoutput. So it has its own systemid that I used.

    Reply
  32. So Im debugging a bit. Here's some output in logs/current.txt:
    Send -> req data as at 28/05/2020 09:55:08 : 55aa000000010102000103
    Recv <- 55aa0001000001822801000b8c001f000000140116006400000000000000000000002708fe138e039b000000670000000005c4
    * Data:
    TEMP : 25.6 deg C = Internal Temperature
    VPV1 : 295.6 V = Panel 1 Voltage
    IPV1 : 3.1 A = Panel 1 DC Current
    ETOTALH : 0 kWh = Accumulated Energy (high bit)
    HTOTALL : 20 hrs = Working Hours (low bit)
    MODE : 278 = Operating Mode
    ETODAY : 1 kWh = Accumulated Energy Today
    HTOTALH : 0 hrs = Working Hours (high bit)
    ERR_GV : 0 = Error message: GV fault value?
    ERR_GF : 0 = Error message: GF fault value?
    ERR_GZ : 0 = Error message: GZ fault value?
    ERR_TEMP: 0 = Error message: Tmp fault value?
    IAC : 3.9 A = Grid Current
    VAC : 230.2 V = Grid Voltage
    FAC : 50.06 Hz = Grid Frequency
    PAC : 923 W = Output Power
    ERR_PV1 : 0 = Error message: PV1 fault value?
    ETOTALL : 10.3 kWh = Accumulated Energy (low bit)
    ERR_GFC1: 0 = Error message: GFC1 fault value?
    ERR_MODE: 0 = Error mode?
    Logging to: /home/pi/inverter_monitor/logs/inverter_S23143A070_20200528.csv
    PVOUTPUT as at 28/05/2020 09:55:09 ...
    ran: /usr/bin/perl /home/pi/inverter_monitor/pvoutput.pl 1000 923 20200528 09:55 S23XXXX70 295.6 25.6
    Serial: S23XXXX70 as at: 20200528 09:55
    Now: 923 W
    Today: 1000 Wh

    Reply
  33. In pvoutput.pl I changed DEBUG_SCRIPT to 1.
    Is there a logfile or something for that? Where?
    use constant {
    DEBUG_SCRIPT => 1, # 0 = NO, 1 = YES
    LIVE_DATA_URL => "http://pvoutput.org/service/r1/addstatus.jsp",
    };

    Here my @PVOUTPUT(replaced some with XXX's):

    my @PVOUTPUT = (
    {
    SERIAL_NUM => "S23XXXX70",
    API_KEY => "f0f750a87d25exxxaf74677ab76384d8cxxxxx1db",
    SYSTEM_ID => "7XXX0",
    },
    );

    Reply
  34. Haha succes! Turns out that the serial number on the box is not the serial number of my inverter. Changed it in PVoutput.pl and worked instantly.

    Reply
  35. The serial number is actually like the password to interrogate the inverter, its critical to have this correct when the script does the initial queries to the inverter.

    Reply
  36. in pvoutput.pl it looks like its doing a check on serial number:
    * # Loop through the PVOUTPUT Array of Hashes to find the matching inverter serial number
    # code...

    Reply
  37. I'm looking to use the RRD database to display graphs on a web site on my RPi Zero. The scripts are working fine but I'm looking for advice on how to get RRDgraph to generate the relevant outputs in images. Most documentation on RRD does not actually explain how to get RRDgraph to process the information or how to use the various switches. If anyone can point me at some useful documents or examples I'd be grateful.
    Regards
    Hugh

    Reply
  38. After succesfully configured my rpi to log to PVoutput with your help; Iโ€™m now helping a friend with a similar setup. He has bought a secondhand SolarRiver 1100TL. It is missing the AC connector. Is that universal? And what is it called? So we can google it. Any ideas?

    Reply
  39. It's actually a Vaconn VPAC06EW-3P. And I couldnt find it anywhere online to purchase. Growatt also uses it on some inverters. Got it for free at a local Solarpanel-installer.

    Reply
  40. Hi Lucas,
    Thanks for the great tutorial. I am trying to connect Pi to my old Samil inverter & uploading data to PVPutput using your code and getting below error:
    Error via pvoutput.org: Bad request 400: Energy value [6700] too high for [05:08]
    root@kali:/home/pi/inverter_monitor# bash runSolarStats.sh
    Error via pvoutput.org: Bad request 400: Energy value [6700] too high for [05:09]
    root@kali:/home/pi/inverter_monitor#
    root@kali:/home/pi/inverter_monitor#
    root@kali:/home/pi/inverter_monitor#
    root@kali:/home/pi/inverter_monitor#
    root@kali:/home/pi/inverter_monitor# bash runSolarStats.sh
    Error via pvoutput.org: Bad request 400: Energy value [6710] too high for [05:12]

    ======================================================================
    output from the fiels generated:
    Starting up at 05/08/2020 04:25:53 running on linux ...
    Starting up at 05/08/2020 04:26:08 running on linux ...
    Starting up at 05/08/2020 04:27:33 running on linux ...
    Starting up at 05/08/2020 04:27:41 running on linux ...
    Starting up at 05/08/2020 04:27:44 running on linux ...
    Starting up at 05/08/2020 05:08:31 running on linux ...
    Initialise Serial Port... port = /dev/ttyUSB0
    Send -> req init inverter: 55aa000000000004000103
    Send -> req serial: 55aa0000000000000000ff
    Recv confirm serial: 55aa0000000000010b5333333132384d343334010348
    Recv req version: 55aa000000010103000104
    Recv req param format: 55aa000000010101000158
    Recv req params: 55aa00000001010400015b
    Recv req data format: 55aa000000010100000101
    Recv req data as at 05/08/2020 05:08:37 : 55aa000000010102000103
    Recv 20200805, t => 05:08, v1 => 6700, v2 => 191 ]
    Starting up at 05/08/2020 05:08:57 running on linux ...
    Initialise Serial Port... port = /dev/ttyUSB0
    Send -> req init inverter: 55aa000000000004000103
    Send -> req serial: 55aa0000000000000000ff
    Recv confirm serial: 55aa0000000000010b5333333132384d343334010348
    Recv req version: 55aa000000010103000104
    Recv req param format: 55aa000000010101000158
    Recv req params: 55aa00000001010400015b
    Recv req data format: 55aa000000010100000101
    Recv req data as at 05/08/2020 05:09:04 : 55aa000000010102000103
    Recv 20200805, t => 05:09, v1 => 6700, v2 => 199 ]
    Starting up at 05/08/2020 05:12:29 running on linux ...
    Initialise Serial Port... port = /dev/ttyUSB0
    Send -> req init inverter: 55aa000000000004000103
    Send -> req serial: 55aa0000000000000000ff
    Recv confirm serial: 55aa0000000000010b5333333132384d343334010348
    Recv req version: 55aa000000010103000104
    Recv req param format: 55aa000000010101000158
    Recv req params: 55aa00000001010400015b
    Recv req data format: 55aa000000010100000101
    Recv req data as at 05/08/2020 05:12:36 : 55aa000000010102000103
    Recv 20200805, t => 05:12, v1 => 6710, v2 => 259 ]
    ===================================================================

    Reply
  41. Hi Jibran!

    This looks like a problem on PV Output's end. Search the following page for 'Bad request 400: Energy value [energy] too high for [time]'

    https://pvoutput.org/help.html#api-addstatus

    It says:

    > The energy parameter exceeds the 1.0-4.0kWh/kW thresholds between 6:00am and 8:00am

    I'm not 100% sure what exactly this means, but as a first step, I would make sure you have configured your system size accurately on PV Output and that your PI has the correct time. If your system is configured on PV Output with a low size, it might be rejecting your updates as not being possible for your system at that time.

    Reply
  42. Hi Lucas,

    Thanks for your response. My Pi time is defintely wrong. I will set it correct and test again tomorrow. Will get back to you with the findings.

    Reply
  43. Hi again Lucas. AS I said earlier, thank you very much for your help and great work done. Just wanted to tell you that I've tweaked your code to add voltage and temperature to the output:

    my $panel_vol = $ARGV[5];
    my $temp_deg = $ARGV[6];

    my $request = POST LIVE_DATA_URL, [ d => $log_date, t => $log_time, v1 => $daily_watthrs, v2 => $current_watts , v5 => $temp_deg , v6 => $panel_vol ];

    Here is my pvoutput graph :):
    https://pvoutput.org/intraday.jsp?id=87746&sid=77816

    Reply
  44. Cool! Yep, any data the inverter returns can be put into the request for PVOutput's add status parameters. I left temperature out of the script for myself because it wasn't very accurate. (I think for me it was the inverter's internal temperature rather than ambient temperature).

    Reply
  45. Dear All,
    I am trying to get data from my SunEzy 600E inverter. I have updated the pvoutput.pl file.
    I did not know about the Serial Number of my inverter, i have seen the sticker at the left side of the inverter and seen the follwoing.
    PN:9402-6020-OOP
    SN:YYDDD:10013_AL007
    can anyone guide me what is my inverter serial number.

    currently i have having error:
    Waited 2 seconds and never saw 55aa0000000000800a
    noTalks=1, reInits=0.

    Reply
    • Hi M Salman, I don't think the serial number really matters. It only matters that what you put in the script matches the serial number that you enter for your system on PVOutput.

      You mention that you are using a SunEzy 600E inverter. This script is mainly for Samil inverters. Your mileage may vary on other inverters; it can work if they use the same serial communications format, but it's far from guaranteed.

      Reply
      • Dear Lucas,
        Thanks for update.
        currently i am using following code to send the data in pvoutput. can you please guide me is my inverter SunEzy 600E supported for your code.

        from pv import cms
        inv = cms.Inverter(port)

        inv.reset() # Reset all communications on the serial connection
        sn = inv.discover() # Look for connected devices
        if sn is None:
        print "Inverter is not connected."
        sys.exit(1)
        ok = inv.register(sn) # Associates the inverter and assigns default address
        if not ok:
        print "Inverter registration failed."
        sys.exit(1)

        print inv.version()

        param_layout = inv.param_layout()
        parameters = inv.parameters(param_layout)
        for field in parameters:
        print "%-10s: %s" % field

        status_layout = inv.status_layout()
        status = inv.status(status_layout)

        for field in status:
        print "%-10s: %s" % field
        from pv import pvoutput
        api_key = 'f70ce3XXX686e94XXX1fd0c5f13a458XXXX0ae55'
        system_id = 4XXX7
        conn = pvoutput.Connection(api_key, system_id)
        import time
        status = dict(status)
        conn.add_status(
        time.strftime('%Y%m%d'),
        time.strftime('%H:%M'),
        energy_exp=status['E-Total'],
        power_exp=status['Pac'],
        cumulative=True)
        print conn.get_status()

        Reply
        • can you please guide me is my inverter SunEzy 600E supported for your code.

          I don't know. I only have a Samil inverter, and I don't know if other inverters produce the same format of data over serial. You can only try it for yourself using the instructions I provided in the blog post above and see.

          My script also sends the data to PVOutput, so if you are using your own code for that, it makes things more complicated.

          I should also say that this script is 99% not my code. I have made it work on a Pi with some small modifications, but I'm not an expert in how it works.

          Reply

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.