After setting up a functional system for collecting solar power, I turned my attention to monitoring it. I find data fascinating, but I had to start by gathering it. This wasn’t exactly a plug-n-play process, but a Raspberry Pi provided a good platform to work off of.
Connecting to the solar charge controller was simple, as it uses RS-485 for communication and came with a RS-485 <=> USB adapter. It communicates using Modbus RTU, a well-defined protocol that is fairly common in industrial equipment. I was able to find two libraries that provided a good starting point for start collecting data, called Pymodbus and epsolar-tracer. Using these libraries (with a small amount of tweaking), I was able to read values from the solar charge controller. This provides access to information such as solar power coming in and battery charger status.
I also wanted to measure the load and be able to determine how much of the solar power was going towards battery charging vs. powering the inverter. This required a few more components for measuring DC current at the battery bank and AC power, and an analog-to-digital converter to read the signals from them. I had an MCP3008 on hand and the Adafruit Python libraries to communicate made that an easy path forward.
With all the pieces in place to gather data, I had to decide what was actually worth collecting and recording. The low-hanging fruit were solar power, battery voltage, and battery current. Load power consumption and battery temperature also seemed interesting. Initially, I was collecting data every 15 minutes, but I soon realized that the conditions I was monitoring changed much more frequently than that. I split the collection interval into day/night values (once per minute during the day, once per ten minutes at night) to get more real-time feedback during the day, when the most interesting data was available. This was quick enough feedback for me, but it was a bit jumpy yet because I was only collecting data at an instant (second) in time. I cut the collection interval down again, this time to five seconds, but added averaging of the values and kept the recording intervals at one and ten minutes. This seemed to provide a stable view of the data without going too crazy with data storage requirements. Real-time stats now in place, I put together a dashboard to display them in an easily-readable fashion. This can be seen on the front page of my site.
All this live data is great, but what about longer-term statistics? I’m still working on that. Currently I’m rolling up the live data into daily stats, calculating the length of day, total power generated, and whether or not the batteries were fully charged. Knowing that allows me to determine if I got the maximum amount of solar power possible for a given day, or if it tapered off because my batteries were fully charged. Monthly stats have yet to be determined, but as of right now I’m thinking of calculating total power generated and average day length. I’m working on maintaining a GitHub repo as I’m going through the development of these utilities. Hopefully it can provide some inspiration!