So I have been searching for a while for something to create a good looking dashboard for home energy usage / generation. I have had a Raspberry Pi hooked up to my inverter in the attic for a while now which was outputting to PVOutput.org but I wanted something hosted locally.
Queue Grafana! It creates some pretty awesome looking graphs with next to zero effort:
My Raspberry Pi is running a perl script which has been pretty bomb proof. This polls the inverter every 15 seconds or so. This is started from cron in the mornings so long as there is not already a running instance of the script, it gets called.
I can’t take credit for any of that, it can be found here:
You need to include the SQL code block within the inverter.pl file and also make sure you add everything to cron, basically follow the guide 🙂
- You have a running SQL server which you can pipe the output of the script to.
- You have a Raspberry Pi connected via serial or some other means to your inverter.
- This is outputting to an SQL database which Grafana can hook into
Install Grafana onto an Ubuntu / Debian Machine:
#Add Grafana Source to apt - create the file below sudo nano /etc/apt/sources.list.d/grafana.list #Add the below to the file: deb https://packages.grafana.com/oss/deb stable main curl https://packages.grafana.com/gpg.key | sudo apt-key add - sudo apt-get update sudo apt-get install grafana sudo systemctl start grafana-server #enable start on boot: sudo systemctl enable grafana-server.service
Once the above is done you should be able to connect on port 3000 and get the initial setup screen. Step through it until you reach Add a Data Source. Find MySQL and complete the details, I am running this locally on the same server. I created a user that only has access to the DB of interest, and its the same credentials the scripts use.
You can then start building your own dashboards and gauges. Grafana seems to automatically query the database and you can start referencing columns within the tables immediately.
Thats it!, you can now leave this running on a screen somewhere for a customisable home energy monitoring system.
The next steps are to start feeding in Energy Consumption as well as energy production. A side project to monitor the boiler will also feed into this which will provide flow and return temperatures!