Energy harvesting WiFi logger and timelapse camera

I recently put up a greenhouse in our backyard. So naturally I’d like to start logging temperature, humidity and maybe soil moisture or solar radiation levels, maybe take some pictures for creating a timelapse of the plants growing through the seasons, perhaps even automate watering the plants or opening and closing the window..

So I started looking into options for doing this. As I’ve found several times before every electronics project seems to start with (and largely revolve around) how to power it.

The way I see it there are several options here:

1) Lay a power cable from the house to the greenhouse. I’m renting the property so don’t know about making permanent changes. Also not clear about whether that would require planning permission.

2) Power it with a battery and then replace the battery when it runs out. With some basic power saving techniques even a small battery would easily last a month. But this just feels inelegant and not like a lot of fun.

3) Keep a battery charged with solar power.

4) Keep a battery charged with a small wind turbine. This is a fairly small backyard and I don’t know how my neighbours would feel about a wind turbine.

5) Skip the battery and charge a supercapacitor with a small solar panel. This is actually the cheapest option, in some ways the trickiest but also the one I find most interesting.

Solar panels have become ridiculously cheap and seem to still be on a technology curve, so still no end to the price drops in sight. Small (less than 10 watt) panels are now only a few dollars each.

Small supercapacitors are also surprisingly affordable. A downside of supercapacitors is the low maximum voltage of typically around 2.7V for EDLCs. This is a bit low for powering 3.3V electronics. You can put them in series to increase the voltage, but it is necessary to balance them to stabilize the voltage due to slight differences in capacitance and ESR caused by manufacturing tolerances. This would slightly increase the complexity of working with them. Alternatively you could use a boost converter that can start up at a very low voltage, but this increases the cost.

However, you can now buy 5.5V or 6V supercapacitors that actually have multiple inside them in series. I’m not sure if they contain balancing circuitry or if they are just “matched pairs”, but the point is that that becomes an implementation detail that’s already taken care of for you. The higher voltage is nice because then you can charge them with USB, power 5V electronics directly (AVR microcontrollers can handle up to 5.5V) and much more of their charge becomes useful or accessible without needing a boost converter.

You also get ultra low dropout (say 350mV or even less) linear regulators that are much cheaper and simpler than a buck/boost converter.

One inefficiency is that you ideally want MPPT charging to get the most out of the solar panel, but you can also just overspec the solar panel. In this kind of application it is bound to be cheaper and even a couple of watts is already overkill for what I’m doing here anyway.

For a low power WiFi and camera module the obvious choice is an ESP32-CAM which (somehow) costs less than $10 each. It runs on 3.3V. It has a 5V input with and “LDO”, but “low” here means +/-1.2V, so not very useful for our purposes so we’ll have to bypass it and power it with 3.3V directly. I’d like to measure the supercapacitor’s voltage which requires ADC, but all the esp32’s ADC pins are already taken up. There are hackish ways to use some of the remaining pins or to repurpose the LED’s pin, but I’m not going to go there. Besides - according to the “datasheet” for the ESP32-CAM it draws 6mA of current even in deep sleep. This is unreasonably high. I didn’t bother testing it myself because I figure they are unlikely to advertise figures that make it sound worse than it really is.

I came up with this solution:

1) A 5.5V maximum (once you include a blocking diode’s drop) solar panel charges a 5.5V (or higher) supercapacitor.

2) The supercapacitor directly powers a 5.5V capable microcontroller. I like the new “mega” attiny series.

3) The attiny sleeps just about all the time, but wakes up every minute or so (configurable) and checks its supply voltage.

4) If the supply voltage is high enough (meaning the supercapacitor is reasonably charged) it turns on power to an LDO that powers the esp32-cam through a P-Channel MOSFET high side switch.

5) The attiny immediately goes back to sleep.

6) The ESP32-CAM reads the temperature and humidity from a sensor and takes a picture. It then asks the attiny for the supply voltage over i2c.

7) The attiny wakes up from the i2c connection, reads the voltage, sends it and goes straight back to sleep.

8) Then the ESP32 sends the temperature, humidity, voltage and photo to a server over wifi.

9) Once it is done it asks the attiny to turn it off, again over i2c.

10) The attiny wakes up from the i2c connection, toggles the power to the esp32-cam and goes back to sleep.

I breadboarded this and it works remarkably well. The entire cycle uses very little power. Everything is as “off” as it can be as much as possible. I still need to measure it, but over time this averages out to well under 1mA even though the esp32 uses hundreds of milliamps during the moment it is fully powered and transmitting over wifi.

An obvious optimisation would be if the server could tell the esp32 about sunset and dawn times and it could then communicate back to the attiny how long it should let the esp32 cam sleep before it powers it down. Because at night it would be too dark for timelapse pictures anyway and it would just drain the supercapacitor before the morning. Alternatively we could still log all the stats through the night and just not take any pictures.

I plan to design a PCB and enclosure to turn this into a proper project. Will build it and report back ;)

Le Roux Bodenstein @lerouxb