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:
  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,, and (there should only be a few mentions of the path).
  3. In, insert your own PVOuput user account details for your system ID, inverter serial number, and API key:
    my @PVOUTPUT = (
      API_KEY       => "<REPLACE WITH YOUR PVOutput API KEY>",
  4. Run the script and see if it works:
  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/

That should be it! You can see my system's live output data on 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! 🙂

2 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 site. How do you run the live feed to the site ( I have configured the 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.


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

    Line 88 of 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!

Leave a comment