This is a sample project for battery operation of Raspberry Pi Pico.
External circuit described in Schematic is mandatory to operate this project.
This project supports:
- power state transition for stand-by (RP2040 off), normal operation, deep sleep and shutdown.
- control of peripheral 3.3V power
- battery voltage monitor and low battery shutdown function
- USB plugged detection
- Raspberry Pi Pico
- SSD1306 OLED display 128x64 pixels
- TP4056 Project (Li-po battery charger)
- achieve very low power consumption by shutdown of DC/DC converter on Raspberry Pi Pico
- RP2040 and peripheral power are completely set to power-off
- power consumption is under 0.5 mW
- transition to Normal state by power switch long push (power-on by H/W circuit)
- transition to Charge state by detection of USB plugged (power-on by H/W circuit)
- in this project sample, LED is blinking in this state
- toggle peripheral power by user switch single push (in this project OLED display runs under peripheral power)
- detectable for power provided from battery or USB power
- transition to DeepSleep state by user switch long push
- transition to Shutdown state by power switch long push or low battery detected
- achieved by dormant mode served in pico-sdk
- to disable peripheral power minimizes power consumption in DeepSleep state
- power consumption is around 5 mW (under peripheral power off)
- transition to Normal state by power switch single push
- goto Charge state in 3 seconds
- When USB plugged, indicate "Charging" display then enter and keep dormant to minimize charge current
- When USB unplugged, return to Stand-by
- transition to Normal state by power switch single push
- Firmware update is also available in this state
- optimized version with SMD devices
RPi_Pico_battery_operation.pdf
- Alternative schematic for the case non-SMD devices are desirable for bread board test
RPi_Pico_battery_operation_breadboard.pdf
- T1 switches battery power to be used only when USB is unplugged. Please refer to "Using a Battery Charger" section of pico-datasheet.pdf
- T2 controls EN signal of DC/DC converter on Raspberry Pi Pico Board. To enable DC/DC converter, EN signal needs to be High by switching T2 off. T2 is on in Stand-by and gets off when power switch is pushed or USB is plugged or POWER_KEEP signal gets High.
- While USB unplugged, VBUS voltage can be around 0.8V by battery power through reverse current from Shottky diode on Raspberry Pi Pico Board. That is why voltage divider (R4 and R5) is needed at Gate of T4 to keep T4 off while USB unplugged.
- T1 and T5 (P-ch MOSFET) are used as Hi-side switches. To drive Raspberry Pi Pico and peripheral devices in stable, those P-ch MOSFETs should be choosed as low On-Resistance (~0.1ohm) and low threshold voltage (~2.5V).
- See "Getting started with Raspberry Pi Pico"
- Put "pico-sdk", "pico-examples" and "pico-extras" on the same level with this project folder.
- Set environmental variables for PICO_SDK_PATH, PICO_EXTRAS_PATH and PICO_EXAMPLES_PATH
- Confirmed with Pico SDK 2.0.0
> git clone -b 2.0.0 https://github.com/raspberrypi/pico-sdk.git
> cd pico-sdk
> git submodule update -i
> cd ..
> git clone -b sdk-2.0.0 https://github.com/raspberrypi/pico-examples.git
>
> git clone -b sdk-2.0.0 https://github.com/raspberrypi/pico-extras.git
>
> git clone -b main https://github.com/elehobica/pico_battery_op.git
- Build is confirmed in Developer Command Prompt for VS 2022 and Visual Studio Code on Windows environment
- Confirmed with cmake-3.27.2-windows-x86_64 and gcc-arm-none-eabi-10.3-2021.10-win32
- Lanuch "Developer Command Prompt for VS 2022"
> cd pico_battery_op
> mkdir build && cd build
> cmake -G "NMake Makefiles" ..
> nmake
- Build is confirmed with pico-sdk-dev-docker:sdk-2.0.0-1.0.0
- Confirmed with cmake-3.22.1 and arm-none-eabi-gcc (15:10.3-2021.07-4) 10.3.1
$ cd pico_battery_op
$ mkdir build && cd build
$ cmake ..
$ make -j4
- Put "pico_battery_op.uf2" on RPI-RP2 drive