Alongside the performance increases of the Raspberry Pi 4 over previous generations, comes an increased demand for electrical power. The RPI team recommend a USB-C power supply capable of an output current of 3A. So, the easiest way to get up and running with the RPI4 and camera kit is to purchase either:
- https://www.raspberrypi.org/products/type-c-power-supply/ (or equivalent)
- USB-C Power Bank
29-7860 is an affordable power bank with a 2A output that may be sufficient if you are not using any peripherals with the RPI4 with and of course a Type A to Type C cable (like 40Y3308).
Ballpark Power Consumption
To start things off, I just wanted to get an approximate idea of what the power consumption for the RPI4 and camera would be. I connected my bench power supply to the PI4 on the GPIO header and switched on the power and logged the resulting power consumption.
The RPI4 boots in about 30 s and has an idle power consumption of 2.6 W. Minimizing power consumption wasn’t a design goal for the RPI, so it is what it is. I am just happy I am not seeing power consumption figures in the 10 – 15 W range (that is quite high).
To determine if I could operate the PI directly off a battery, I launched raspistill with a long preview timeout and swept the input power from 5.6V down to 3 V while logging the power consumption.
Unfortunately, the Under Voltage Lock Out (UVLO) is very close to the nominal voltage of a Li-Ion battery. So, you may get the RPI4 to boot on a Li-Ion cell when fully charged, but it’s difficult to say at what battery state of charge the PI4 will UVLO trip.
A viable option would be to use 4 good quality Ni-MH AA cells in series. Just ensure the fully charged pack voltage doesn’t grossly exceed 5.5 V and certainly not 6V.
To put this into context my GoPro Hero8 has a runtime of approximately 90 minutes with a 1.2 Ah Li-Ion battery (which is approximately 4.5 Wh). So, we can approximate the power consumption to be approximately 3 W. Now the GoPro is running a number of a real-time video effects for color, perspective, and image stabilization. So, if we end up running a real-time OpenCv application on the RPI4 with a power consumption of 3 to 4 W, I would definitely consider that a great success.
Overly Complicated Approach
Power Tool Battery
I have only used tool battery briefly for a few minutes at time by inserting a wire or spade terminal into the packs positive and negative terminal. The ‘yellow brand’ tool manufacture does not include any protection circuitry into the battery pack, it is essentially just 5 raw 18650 cells in series to achieve their 20V Max output voltage rating. Overvoltage protection and cell balancing is the responsibility of the wall charger. Cell under-voltage protection is left to the consuming appliance, for example a cordless drill/driver. Fortunately, all of the cells are pined out on the battery connector.
Solar Panel
This solar panel is no where near state of the art, but I believe it should certainly perform as advertised. It was priced at $70 CAD including shipping. If you were to subtract the included shipping cost, the panel would be priced at a little over a $1/W, I think that’s fair.
The dimensions of the panel should be similar to say a large backpack.
https://www.renogy.com/content/RNG-50D-SS/50D-SS-Datasheet.pdf
The panel may appear to be overkill for the application, but in reality, on a dark cloudy day this panel might output a mere 5 W or less. Assuming the PI runs under 5W this panel should be large enough to run the PI4 irrespective of weather conditions.
Even a few hours before solar noon with non-ideal mounting geometry the panel was capable of upwards of 40W. I haven't yet traced the actual IV curve. Regardless this is ample power to operate the PI and simultaneously charge a battery bank.
DCDC Converter
I used what I had on hand. I have a number of HW-688 modules that I have previously purchased for various projects.
Running the converter at full load will load the input filter capacitor with upwards of 3 Arms of ripple current. The no-name 100 uF electrolytic input capacitor will cook itself dry within a matter of hours with a 3Arms ripple current, similar form factor electrolytic capacitors are rated for a few 100’s mA ripple current.
Really, the only positives for this converter are its wide input range and price point for a fully assembled module.
DCDC Module Specifications:
Input | DC9-36V |
Output | 5V |
Output current | 6A |
Modifications:
- Red Glitter Nail Polish on Connectors (essential!)
- Removal of series input reverse polarity diode
- Additional quality 10 uF MLCC on the input and output
Telemetry and Control
One of the downsides of using Li-Ion batteries is having to ensure the cells are operated within their safe operating parameters (voltage, current, temperature, etc.). Conversely, it’s also an opportunity to have some analog fun. The design presented here is somewhat atypical in that most of the telemetry and control circuitry is referenced to the system ground versus the battery negative terminal. This is done to reduce the quiescent current to essentially nanoamps when the system load is switched off. The only circuitry continually powered by the battery is a CMOS SR-Latch driving a low-side NFET for discharge control. A simplified schematic of the analog portions of the circuit are shown in the schematic below:
With over 40 resistors and 50 nets on a small little perfboard, the final build looks more like a rats-nest than a work of art.
Once I decide on a final sample rate for the PICO, I can add some filter capacitors to the frontend amplifiers.
The SR-Latch is realized with a pair of 2-input CMOS NAND gates from a CD4011. A cross-coupled NAND SR-Latch has inverting inputs which is a great benefit to this circuit, as when the RPI Pico decides its time to give up the ghost it only needs to signal an output-low with an open-collector driver Q1. A momentary push-button signals the latch to SET, thereby enabling the discharge NFET M5.
Differential Amplifier
The differential amplifier is textbook unity-gain difference amplifier. The positive and negative inputs sample across one desired cell from the battery.
The natural choice for a quad-opamp with a 20+ V supply rating is the LM324.
All the inputs have ideal diodes to prevent any leakage or cross-cell conduction when the telemetry circuitry is powered down.
Testing the difference amplifier for cell-5 involved biasing the the negative input to 16.8 VDC. Then proceeding to sweep positive input terminal from 0 V to 4.2V, simulating a cell under test.
Almost unity-gain! The offset voltage of 22.8 mV is actually mostly due to the effective CMRR of the circuit (which should mostly be due to resistor mismatch).
The first 800 mV plateau is due to the output stage of the LM324 clipping against the ground rail. The LM324 will only swing to 1Vbe + 1Vce sat to the negative supply while sinking any appreciable load, roughly 800 uA in this case from R25 & R26.
To test the common-mode response of the amplifier, I biased the differential input to a constant 3.7 V and swept the negative input potential from 11 V to 16.8V.
Sometimes you just get lucky. Getting a DC CMRR of 58 dB with 1% rated resistors and an LM324 made my day :).
Current Sense Amplifier
The battery discharge current is sampled with a 220 milliOhm current shunt resistor. An inverting amplifier with a gain of -20 V/V amplifies the current shunt potential.
Ideally the current sense circuit would have a sensitivity of 4.4 V/A. I applied a constant current source to the current shunt with my bench power supply and recorded the amplifiers output voltage.
The gain of the current sense circuit is only 3% low, most of gain error is attributed to the 220 milliOhm current shunt.
Control Logic
At this point the control logic is very simple. Just monitor the 5 cells in the battery for an undervoltage trip.
import time,micropython from machine import Pin, mem32, ADC import ctypes micropython.alloc_emergency_exception_buf(100) AMUX_BITS = { "Val": 16 << ctypes.BF_POS | 3 << ctypes.BF_LEN | ctypes.BFUINT32, } AMUX = ctypes.struct(0xd0000000+0x10,AMUX_BITS) A0 = Pin(16,Pin.OUT) A1 = Pin(17,Pin.OUT) A2 = Pin(18,Pin.OUT) REGPWM = Pin(23,Pin.OUT) REGPWM.value(1) DIS = Pin(20,Pin.OUT) DIS.value(0) BAT = ADC(0) Pin(26,Pin.IN) IBAT = ADC(1) Pin(27,Pin.IN) VSYS = ADC(3) Pin(29,Pin.IN) led = Pin(25, Pin.OUT) timer = machine.Timer() AREF = 3.301 BATScale = AREF/256*4.3/3.3 SYSScale = AREF/256*3 IBATScale = AREF/256/4.27*1000
OpenCV Power Consumption
I was able to get this OpenCV tutorial https://docs.opencv.org/3.4/db/d28/tutorial_cascade_classifier.html running on the PI4. The program executed at approximately 4 FPS. I then logged the output of the current sense amplifier with my oscilloscope. The figure below shows the power consumption of the entire system including DCDC converter losses while running an OpenCV application:
As long as the sun is shining, the 50W solar panel could easily power the PI. On battery power alone, the current battery pack would have a runtime of approximately 4.5 hours.
Conclusions
I am just beyond thrilled how everything came together.
As a bonus I am really interested to measure the rated capacity of my cordless drill battery. If I do buy into this brand's battery eco-system I would like to be able to make use of the batteries as I see fit.
Top Comments