This article is a work in progress to create a power-controller for the Raspberry Pi based on a PIC microcontroller and MOSFET. The PIC implements an I2C slave to allow power control, and also to approximate the registers of a PCF8563 Real Time Clock (RTC) chip, to allow timed wake-up of the Pi.
- Power the Raspberry Pi off and on with a push-button.
- Fully shut down the Raspberry Pi on ‘shutdown -h’.
- Wake-up at a specified time (one-off or periodic).
- Monitor the supply voltage.
- Log glitches in the power-supply (e.g. caused by USB device activity).
- Maintains the time from a CR2032 button cell.
During power-down, the circuit currently consumes around 5μA of power, useful where a battery is being used to power the Pi (remote solar-power applications, or in-car systems, for example).
The Pi is able to instruct the PIC to power it down using a short I2C command sequence. Wake up events include a push-button, or other voltage-sense on an input pin.
It’s only on a breadboard at the moment, the firmware is very much still a work-in-progress, and the schematics have only been roughly sketched out. I’ll likely paste in another circuit I have to add the options of an LCD display and multi-button inputs using IO expanders.
The PIC chip I’ve chosen is the PIC18F27J13, which has 128K of program memory and over 3K of RAM. This means there’s plenty of room left for custom programs on the PIC to intercept inputs and buffer data while the Pi boots up, and a CR2032 battery backup prevents data-loss in the PIC in the event of power failure.
I’m hoping that the low-voltage programming feature of the ‘J’ family of PIC chips will allow custom firmware to be developed on the Pi and deployed directly to the PIC, but I’ve yet to read up on the implications of this.
For more detail: Raspberry Pi Power Controller
Current Project / Post can also be found using:
- raspberry pi project battery controller