Pretty Solar Graphs
The first step on my solar progress is to get some graphs done, to get an idea of how much energy I can get from my solar panels on an average day. From this I can work out what I can conceivably run from my setup.
Background
Previously, I installed a simple solar setup for testing. This is using an EPEver Tracer1210A solar charge controller, from Tracer. It wasn’t the cheapest, but it had a lot of good reviews (watch out for cheap copied). The other benefit was the fact it had a serial output that talked modbus, or rs485. Intended for official devices, they do provide the protocol to allow third parties to read the system details.
After doing some searching, I discovered Jamin on github who had done some coding and circuit design to get the current details from the charge controller and push the results out to a service called Blynk.
My Project
Overview
This project gave me the starting point for what I wanted to do. My idea was to do this:
Controller -> RS485 -> NodeMCU -> MQTT -> OpenHAB -> InfluxDB -> Grafana
A little bit convoluted, I could probably have pushed straight to a database for logging, and do the graphs in grafana. I decided that pushing via MQTT would allow me to integrate the logging into my OpenHAB system, which would give me the capability to trigger home automation actions depending on the statistics from the charge controller. For example, it makes it very easy to use OpenHAB to send an email if the battery level gets low, and not only that it could turn off some of the load running off the battery as it gets to different levels.
Circuit
The circuit is pretty much a direct copy of what Jamin used, only adapted for a NodeMCU rather than a ESP8266 Mini Dev board.
I did look into powering this from the 5V on the serial output of the charge controller, but according to the documentation this can only put out about 50mA of power, which probably won’t be enough to cover the usage by the NodeMCU.
Code
The initial code can be found on my github repository here:
https://github.com/dpoulson/EPSolar
Still a work in progress, but it does the basics so far. Future improvements will allow writing of certain settings, maybe a simple webserver for point in time readings, or an LCD screen.
Logging
So the circuit will transmit the readings over wifi to my central MQTT server, running mosquitto. MQTT is just a simple messaging system when you can subscribe to, or publish to, certain queues.
Readings from the charge controller will be published to set queues on the server, which OpenHAB will be subscribed to, with the following items file:
Number EPSolar_Temp "Temperature [%.2f °C]" { mqtt="<[mymosquitto:EPSolar/1/ctemp:state:default" } Number EPSolar_BattVolt "Battery Voltage [%.2f V]" { mqtt="<[mymosquitto:EPSolar/1/bvoltage:state:default" } Number EPSolar_BattRemain "Battery Remaining [%.2f %]" { mqtt="<[mymosquitto:EPSolar/1/bremaining:state:default" } Number EPSolar_BattTemp "Battery Temp [%.2f °C]" { mqtt="<[mymosquitto:EPSolar/1/btemp:state:default" } Number EPSolar_LoadPower "Load Power [%.2f W]" { mqtt="<[mymosquitto:EPSolar/1/lpower:state:default" } Number EPSolar_LoadCurrent "Load Current [%.2f A]" { mqtt="<[mymosquitto:EPSolar/1/lcurrent:state:default" } Number EPSolar_PVVolt "PV Voltage [%.2f V]" { mqtt="<[mymosquitto:EPSolar/1/pvvoltage:state:default" } Number EPSolar_PVCurrent "PV Current [%.2f A]" { mqtt="<[mymosquitto:EPSolar/1/pvcurrent:state:default" } Number EPSolar_PVPower "PV Power [%.2f W]" { mqtt="<[mymosquitto:EPSolar/1/pvpower:state:default" } Number EPSolar_ChargeCurrent "Battery Charge Current [%.2f A]" { mqtt="<[mymosquitto:EPSolar/1/battChargeCurrent:state:default" } Number EPSolar_PVVoltMax "PV Voltage MAX (today) [%.2f V]" { mqtt="<[mymosquitto:EPSolar/1/stats_today_pv_volt_max:state:default" } Number EPSolar_PVVoltMin "PV Voltage MIN (today) [%.2f V]" { mqtt="<[mymosquitto:EPSolar/1/stats_today_pv_volt_min:state:default" }
My OpenHAB system is configured to store persistence data into an InfluxDB server, which is a common setup amongst the OpenHAB community and is well documented. This InfluxDB stores historic data on items in OpenHAB, which is searchable by Grafana. Grafana gives a nice interface to produce all the pretty solar graphs you might want.
Solar Graphs
This makes it really easy to see just what is happening, including the charging states as it you can see the switch from bulk to float charge on the battery voltage. This should allow me to make sure the charging is correct for the Lithium Ion batteries I want to eventually connect.