How to monitor your Envoy router with MRTG
So I am into green, whole family is. This past summer, I decided to install solar panels. Got a 4.4KW system installed with Enphase microinverters.
Traditional solar panel system generate DC in the panels, and all of them goes to a battery bank, then a DC-AC converter for the house. It’s big, bulky and wasteful (converting DC-AC, etc). The Enphase microverters uses a DC-AC converter per panel. So no batteries needed, and losing one panel (whether shade, damage, whatever) is not going to stop power production.
Anyway, long story short, along with the microinverter come an Envoy, which is essentially a small embedded computer that talk with each inverter, query their status (power generation, heat, etc.), collects them and send them to a central place (Enphase’s server).
You have the option of subscribing to Enphase Enlighten program which allow you to login to a personalize website and view your power generation history with nice graphs, etc. The first few months are free after installation so you can play with it and see how it work.
I didn’t want to pay for something I can do myself. The microinverters talk with the Envoy over the power lines, so use their own protocol. But since I have access to the Envoy controller, I can query it for the data it collect from the inverters. There is a web interface on the unit that I can login to and see the data. But there is no programmatic way to get that data, e.g no snmp or API that I can use to ask the Envoy.
Hmmm, ok, I’ll screen scrape the web interface. So I wrote a little perl script to do just that, and that script output MRTG data for graphing locally.
12/14
Sorry, didn’t finish this yet. I’ll post my little perl script and the config I used for MRTG when I have chance.
3/9/2011
I posted my MRTG config and perl script in the comment to this post. Too lazy to put it here….
I now have the performance trends, generated with gnuplot, available on my website.
http://simple-pages.homeunix.net/solar/
The data I extract from MySQL using a perl script which is then passed on to my gnuplot script:
#!/usr/bin/gnuplot
reset
#
set grid
set time
set title “Daily generation graph”
set style fill solid 1 border noborder
set key top left box
set style data fsteps
set xtics font “Times-Roman, 12”
set xlabel “Time”
set xdata time
set timefmt “%Y-%m-%d %H:%M:%S”
set format x “%d/%m\n%H:%M”
set ylabel “Watt”
set y2label “kWh”
set ytics nomirror
set y2tics
set tics in
#
set key autotitle columnhead
set terminal png size 800,300
set output ‘/var/www/htdocs/solar/daily.png’
plot ‘/tmp/daily.dat’ using 1:3 smooth freq, \
” using 1:($4/1000) smooth freq axis x1y2
# end of gnuplot script
The datafile (/tmp/daily.dat) is generated using a MySQL query and looks like this:
‘date time’ ‘power’ ‘energy’
2016-08-12 13:45:02 2240 7950
2016-08-12 13:40:02 1880 7770
2016-08-12 13:35:02 653 7610
2016-08-12 13:30:02 1570 7560
All pretty simple I would think.
Cheers,
Frits.
Hi Tin,
I’ve added some SQL to your perl script:
Top of the script:
use CGI qw(:standard);
use strict;use Socket;
use DBI;
Bottom of the script:
#
# update the MySQL database table
#
my ($dbhandle, $qhandle,$query);
$dbhandle = DBI->connect (“DBI:mysql:host=localhost;database=envoy”,
“nobody”, “”,
{PrintError => 0, RaiseError => 1});
$query = ”
INSERT INTO data \
VALUES (0, now(), $ncurrently, $ntoday, $nlastweek);”,
# print(“query: $query\n”);
$qhandle = $dbhandle->prepare($query);
$qhandle->execute();
#
# End of MySQL addition
#
I guess you might like that.
The graphics can you be generated using GNU plot and straight out of the MySQL table 🙂
Oh, and for good measure I added ‘last week’ generation.
Thanks Frits for the contribution.
Hi Tin, here are links to my mrtg graphs. I’ve only got a weeks worth of data, so far:
Day Graph: http://s17.postimg.org/p31t04acv/envoy_day.png
Week Graph: http://s9.postimg.org/85aaaebyn/envoy_week.png
Month Graph: http://s24.postimg.org/633yj5fmd/envoy_month.png
And finally, the year graph: http://s9.postimg.org/3nckw1lan/envoy_year.png
I don’t have a lot data yet for my yearly graph. But, as you can see, the maximum value is about 6kW. Where on the week and month, it is about 12.5kW.
That look about right. Anything based on RRDs will lose details over time as the data get averaged the further back you go.
Tin, thanks for this page. I’ve implemented this to get mrtg graphing of my envoy data. One question: I notice that your screen shot of the mrtg graphs don’t include the yearly data. I’m having issues with my yearly graph. My yearly graph doesn’t seem to be showing the correct daily totals production. Are you having the same issue with your yearly graph?
Can you post a screen cap of your yearly graph? Mine works fine as far as I can remember. I upgraded my server HW and OS last year and broke the monitoring. I’ll get it working again now to take a look.
I got my MRTG monitoring working again with the Envoy and my yearly graph look ok. Note that it take time, at least a day or more for there to be any data to be graphed. Since RRD rolls up data over the time series. You lose precision, but you get cumulative averages.
I’ve also updated my get-envoy-stats.pl script and checked it into my github repo.
Get stats script
@fromport
What method did you use to gain root access to your Envoy?
Just FYI, Enlighten is free now, and there is a data API as well. Not quite the same as direct access to the Envoy, but it’s quite useful.
Eric,
Thanks for the info, I’ve stopped checking Envoy website, so would not have known that.
@fromport
Hi Fromport, is it possible to explain to me how to get the root pasword. I will like to get in to my Envoy. Thanks,
@Joe
At the moment, no. The software is meant to run on Linux or *NIX like systems (including BSD variants, OSX, Solaris, etc.).
This was just a quich hack so I can monitor what my solar panels are generating. Not promising anything, but I’ll look into making it run on other OS, including Windows.
I have a couple of ideas to make it nicer looking.
I’m not a programmer, but I sure would like to be able to install and utilize this software to get better displays of the performance. I have an enphase system out “in the country” where only dial-up is available, and can’t use their monitoring system. I’m NOT a programmer – is there a “finished’ version of this software I can just load up on a windows 7 computer to let me get the more complete data? Sure would appreciate a copy…
The output of my envoy is now uploaded to http://pvoutput.org/list.jsp?userid=1805 using the scripts found on http://pvoutput.org/help.html#integration
In April i am sure there will be no extension of my current enphase subscription
If somebody wants more info, just shout
http://pastebin.com/gtnXPHU5 for the dump of the password file
@fromport
Yes, the Envoy router uses OpenVPN to connect back to Enphase mothership and upload the data through that connection. I block it at my fw.
Ok, here is what I have. There are several pieces you need to graph your system using MRTG. You need to have MRTG setup and working. There is an MRTG cronjob that runs every 5 minutes to grab the data, update the RRDs and generate the graph.
First, create an MRTG config file for your Envoy router. Here is mine, you need to change the IP address to yours. I put mine in a file call envoy.cfg in /var/www/mrtg/cfg directory.
Then you will need the following perl script:
get-envoy-stats.pl script
This is a screen cap of my MRTG screen:
I have 12 Enphase inverters as well an Envoy unit which allows me some access to my data but I sure would like to see it all. I did pay for the equipment.
Please let me know of any progress in this regard.
Fromport I would also love to get a copy of the /etc/passwd so that I can help. @fromport
I managed to gain root access to my envoy.
It makes a vpn to enphase HQ and using ruby it transfers all the data.
Maybe we can do some stuff together ?!
Sorry, I’ve been busy and have not check my blog for a while. I’ve got to clean up my script and post it.
If you can post the /etc/passwd file from the envoy, that should help. More eyes to look at it and have a try at cracking it.
You figure out a way to get the per inverter data out of the Envoy?
No, I wish. I am screen scraping at the moment. I am planning on opening up the router and see if I can get to the OS. If mine is one of the old one with the SD card, then I am in heaven!