Close

will it blend

A project log for battery2pi

a battery operated Pi Zero using a minimum of parts

mincepimincepi 02/21/2017 at 17:200 Comments

soldered a wire to the resistor connected to the CS pin (boy, that resistor is tiny) and tested things out on a breadboard. It works!

Next I needed to figure out how to allow the Pi to shut itself off. I came up with this circuit:

The Pi turns itself off by setting GPIO4 to pull-down (it's normally pull-up). There is a major problem with this circuit: when the Pi power voltage drops below 3.3 volts it will reset the Pi but GPIO4 will not change to pull-down, so the Pi will not power off. It WILL eventually turn off when the battery drops below it's low voltage protect voltage, but that's too late: permanent battery damage may occur. Those Lithium batteries are pretty sensitive!

To fix this I came up with this circuit. It requires removing the 1K resistor from the protection module, but in return it doesn't require a transistor:

This circuit has a small problem: the on switch has to be held down until the Pi can set GPIO4 to a low output. The quickest this can be done is in about 4 seconds, using a device tree overlay, so you have to hold the on button down for 4 seconds. I think I can live with this.

By the way, did you know that if you set a GPIO's pull state, it will survive a reboot? It only gets set back to the default state when the power is cycled. The GPIO's input/output state doesn't survive a shutdown or reset though: they all get set to inputs. So you have to use the input/output state change to power off the Pi if you want it to power off on a low-voltage reset or shutdown.

I tested the final circuit, and it works great! I issue a shutdown command, and after the PI halts, the power turns off automatically. Just like a real computer. It's kind of cool after years of powering off Pis manually! Current draw when off is 55 microamps. This seemed like a lot until I calculated that an 18650 cell could provide this current for 4 years!

Discussions