I've use the Amp Ripper 3000, from kickstart-design, in previous projects - it is one of the highest quality, most simple to use charger/boost converters available for powering Raspberry Pi and other 5v projects. It's plug-and-play from charger to battery to Raspberry Pi with enough power to run the Pi 4 and has a low-voltage pin to signal when the battery gets low. And its one of the few solutions supporting pass-through-charging so it's suitable for a UPS.
The Amp Ripper 4000 (Kickstarter link) builds on the 3k with loads of improvements:
- Increased 4 amp maximum current supply for more demanding setups.
- I2C reporting of charging/battery voltage, battery percentage, charge/discharge rates via a MAX17084 chip.
- Several large VOUT solder connections.
- Support for a wide range of charging voltages: 5-14v! Charge from 12v automotive systems, solar, etc.
- Battery temperature thermistor support.
- Configurable charging current if you'r adventurous enough to replace a surface mount resistor.
I'll be testing the overall performance of the AR 4k and writing code to query battery values from its i2c. See below for example code to use in your projects. Testing goals:
- Power performance - Does it run an Intel Compute Stick m3? (YES!)
- Reading battery charge stats via i2c using a pi 4 and python.
- Reading battery charge stats via i2c using a pi pico and micropython.
- Verifying battery percentage estimates and high/low cutoff voltages.
BT2.0 plugs in the mail, but for now it's directly soldered to the AR 4k board.
Be careful about using plugs in line with your batteries that aren't rated for 5+ amp. I've had issues in the past using JT/JXT connectors and voltage drop across them.
Raw Power Performance
I have an Intel Compute Stick M3 that is my benchmark for any USB 5v supply. It's finicky and will bootloop if the supply can't keep up so generally it has to be run from a wall wart. The AR3k couldn't run it without hangs.
The AR4k is working flawlessly here. I got a youtube video going in chrome and started playing Hollow Knight in Steam while monitoring with top and no hangs! I alternated between charging discharging and let it run for a couple hours on battery with no issues.
Reading battery charge stats via i2c
Using a Pi 4 and Python
Example Code For Reading Battery Voltage and Percent
The AR4k uses a MAX17048 Li-Ion fuel gauge chip. It will need at least one charge/discharge cycle before it correctly reports battery "cell_percent". I'll update this with more specifics as my current project evolves. There is an easy to use library from Adafruit for this chip that works well with the AR4k.
This is working on the latest (as of March 2023) Raspberry PI OS 32 bit. It should be the same for RP OS 64 bit, but you may need different libraries with Ubuntu or other distros.
$ pip3 install adafruit-circuitpython-max1704x i2c-tools
$ sudo usermod -a -G dialout your_acct_name
Verify you can see the i2c device. You should see a 36 listed for the max17048 chip using i2cdetect:
$ i2cdetect -y 1
30: -- -- -- -- -- 36 -- ...
If that works, you should be able to query the battery voltage:
>>> import time
>>> import board
>>> import adafruit_max1704x
>>> i2c = board.I2C()
>>> max17 = adafruit_max1704x.MAX17048(i2c)
The time.sleep(1) is needed if you put this in a script. You'll see cell_voltage reported and cell_percent both reported as "0.0" if you query them immediately after the max17= line.
Notes for Ubuntu 22.10
If you're using Ubuntu 22.10 on your Pi, there are a couple extra steps to get started - we need to install the raspberry pi gpio library and add our account to the dialout group for access to the /dev/i2c* devices:
$ apt install python3-pip python3-rpi.gpio
$ sudo usermod -a -G dialout your_acct_name
Enabling Safe-Shutdown on Low Voltage
This is a pretty standard feature intended to power off the pi before the battery is completely dead so that it can be shut down cleanly, avoiding file-system corruption from a hard-power-off.
The MAX1704x can be set to toggle the INT pin at a configured voltage, or we can use the LBO pin to trigger at 3.3v. We can trigger a shutdown of the Pi by connecting the pin to a GPIO pin and updating config.txt. - Additional hardware is needed to actually turn off the PSU, so an update will be made here once I sort that out.
To enable auto shutdown on the pi, edit /boot/firmware/config.txt and add the following line at the bottom:
NOTE - I need to verify this. I'll update in a few days when this is confirmed to be exactly correct.
Implementing a kernel module to make the power supply and battery appear as a laptop battery for the Raspberry Pi
This is work in progress. There is a