The best solution for your Raspberry Pi mobile project
The LipoPiZero+ board is a low-profile Raspberry Pi pHAT which is compatible with all the Pi models that have a 40-pin GPIO header, including A+, B+, 2B, Zero, Zero W, 3B, 3B+, 3A+ and 4B. It works with any 3.7V Lithium-Polymer or Lithium-Ion rechargeable battery and delivers up to 2A to your Raspberry Pi board.
Thanks to its very low profile and the additional on-board features, it is one of the best solutions for your battery-powered outdoors project. It fits most enclosures, including the official cases for the A and B models.
Plug in the LipoPiZero+ board to the Raspberry Pi board
Ensure the 40-pin through hole connector is aligned with the 40-pin header on the Pi.
You can use either a Lithium Polymer or Lithium Ion 3.7V rechargeable battery.
Enable boost converter output and i2c
Add the following lines to the file "/boot/config.txt":
Switch on the Pi board
Press pushbutton on the LipoPiZero+ board for ~1 second.
To read battery voltage
Download and run python example script:
chmod 755 mcp3021.py
Returns battery level as a percentage number (0 to 100%).
Returns battery level as a voltage level (3.2V to 4.2V).
GPIO input 3-way slide switch
Uses GPIO22, GPIO27, GPIO17 header pins which need to be configured as inputs and pulled down to 0. See python example script "lipopizero.py" below.
GPIO output general purpose LED's
Uses GPIO23, GPIO24, GPIO25 header pins which need to be configured as outputs. See python example script "lipopizero.py" below.
Shut down Pi board
The on-board pushbutton can be used to gracefully shut down the Pi board. When the pushbutton is pressed, the GPIO18 pin (which needs to be configured as input and initially pulled down to 0) will be pulled up to 1. This can be handled by your script to run the "shutdown -h now" command. See python example script "lipopizero.py" below.
Low battery status
When the battery voltage goes below 3.2V, the GPIO4 pin (which needs to be configured as input and is normally high) will be pulled down to 0. This can be handled by your script to run the "shutdown -h now" command. See python example script "lipopizero.py" below.
Python example script
Download and run the following script:
chmod 755 lipopizero.py
Install lipopizero.py as a service:
sudo cp lipopizero.service /lib/systemd/system/
sudo cp lipopizero.py /usr/local/sbin/
sudo systemctl enable lipopizero.service
sudo systemctl start lipopizero.service
Recharging the battery
The battery can be charged with a +5V power supply with the Raspberry Pi board either switched on or off. You can use either micro USB socket (NOT BOTH at the same time). If the Pi board is running from battery when the USB power is plugged in, it will switch automatically to the external power supply and will start recharging the battery at the same time. If the Pi board was off when the USB power is plugged in, the Pi board will boot up as normal. When unplugging the USB power, the Pi board will automatically switch again to battery power and stay on.
When the battery is charging, an amber LED will be on. When the battery is fully charged, the amber LED will turn off and a green LED will turn on. Also, during normal operation, when the battery goes below 3.2V, a red LED will turn on. When that happens, it is recommended to shut down the board gracefully using the script above.
If configured as in input, the value of the GPIO5 pin indicates whether the Pi is using the battery (value=1) or the external power supply (value=0).
Using the RTC clock
First, insert a CR1025 coin battery into the battery holder.
Add the following lines to the "/etc/rc.local" file:
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
To read the current time from the RTC clock:
sudo hwclock -r
To write the system time to the RTC clock:
sudo hwclock -w
To copy the time from the RTC clock to the system time:
sudo hwclock -s
Using an external pushbutton to switch on/off the Pi board
An external pushbutton can be connected to the LipoPiZero+ board to replace the on-board one. To this end, a Molex 53261-0371 connector is present on the board. The duplicate the action of the on-board pushbutton, the external pushbutton needs to be connected to pins 2 and 3 of the Molex connector (see picture below). A Molex 15134-0302 receptacle to receptacle 3-way cable can be used for this purpose.
Using a TTP223 capacitive touch sensor to switch on/off the Pi board
To use an external a capacitive touch sensor such as the TTP223 breakout board, the two 0 ohm resistors on the bottom of the board (circled in red) need to be removed with a soldering iron. Additionally, the other 3 pairs of pads need to be connected with a small blob of solder. This is shown in green in the image below.
Once this has been done, make the following connections using for instance the same Molex 15134-0302 receptacle to receptacle 3-way cable between the on-board Molex 53261-0371 connector and the external TTP223 breakout board:
Pin 1 <---> GND
Pin 2 <---> I/O
Pin 3 <---> +3.3V