## The solar battery monitor

I’ve decided it was time I found a way to monitor my solar panels (see The practicalities of running a laptop on solar power.)

2x 30 solar panels

I wanted to see how much charge there was in the little 12v lead-acid battery

Solar charger connected to a 12v lead-acid battery and a 12v>5v regulator

I have an ulterior motive – I’m hoping to use the setup as a test bed for solar-powering Starway (see The Starway to Reno) when it (touch wood) goes out to Burning Man later this year. Since Starway already uses a BeagleBoneBlack I thought I’d use it here too.

My requirements were to be able to check the voltage of the battery from my android phone from anywhere on the internet. I didn’t want to have to log-in or have a password – I also didn’t want to depend on a cloud service as internet connectivity at Burning Man can be ‘spotty’. I also wanted to collect some statistics so I could tell when the power was likely to run out and plan accordingly.

So I wired up the BeagleBone like this:

Wiring of the power and sample voltages with drop-down and regulator.

The analog inputs on the BBB have a range of 0->1.8 volts – so we need to drop the voltage on the battery (max ~14v) by a factor of roughly 10 – the 10k +1k resistors in series do that.
(well a factor of 11 actually, but that’s just maths….)

The Beaglebone is powered from the battery via a regulator which (efficiently) drops the voltage from 12v to 5v and can supply up to 3amps if needed. (This setup should be well under 0.5amps though).

The first regulator I tried had the unpleasant property that there was a large voltage drop between ground on the 12v side and ground on the 5v side. Which would have resulted in an incorrect reading on AIN – and possibly blown the port. Fortunately I tested it before connecting up the Beaglebone. The more expensive regulator in the image above was better behaved. However I put a wire between the 2 grounds to be absolutely sure.

BeagleBone Black in plastic box with the lid off and a wifi stick

Next I wrote a quick test script to see if things were working.

`awk ' {print (11.0 * \$1)/1000}' <  /sys/devices/ocp.3/helper.15/AIN0`

which gave me : 13.101 – not bad…

Next I extended the YoPet IoT library  to read from the appropriate Analog
input and send it over a WebRTC datachannel to authorized devices that requested it:

Gauge with voltage

Now I wanted to collect some statistics – so I added a cron job that grabs the voltage every 10 minutes and puts it into a Redis store. (see my Github for details )

Finally – I added read-only support to the YoPet IoT library and added a web side charting package.

Graph with 1 day of readings

What I’ve now discovered is that my old lead-acid battery doesn’t hold much charge any more, it can’t power the beaglebone for more than a couple of hours, even after a full day’s sunshine.

I was able to reuse much of this work when I came to implement the Samsung Artik parking sensor app – Samsung parking app. Hopefully it will survive the rigours of Burning Man.