UPS Module
Using UPS HAT UPS Module with Raspberry Pi
What is the UPS HAT?
UPS HAT practical reference
An uninterruptible power supply HAT that seamlessly switches a Raspberry Pi to battery power during outages, common in always-on home servers. It sits between the main power source and the Pi's power input, continuously trickle-charging an onboard Li-ion/LiPo battery while mains power is present, and instantly switching over to battery when power is lost — keeping projects like home automation hubs, network-attached storage, or security camera servers running through brief outages, or at least allowing a graceful shutdown before the battery depletes.
Key specifications
- Form factor: Raspberry Pi HAT — mounts directly on the 40-pin GPIO header, matching standard Pi board dimensions
- Input power: 5 V via micro-USB or USB-C, or direct DC barrel input depending on model
- Output power: Regulated 5V to the Raspberry Pi via the GPIO header pins (bypassing the Pi's own USB power input)
- Battery: Single or dual-cell Li-ion/LiPo (18650 cells are common), charge-managed onboard
- Switchover behavior: Automatic, near-instantaneous switch to battery power on mains loss with no reboot of the Pi
- Monitoring: Many models expose battery voltage/percentage over I2C so software running on the Pi can log status or trigger a graceful shutdown before battery depletion
- Backup runtime: Model and battery-capacity dependent, commonly tens of minutes to a few hours depending on Pi model and attached peripherals
Pinout and connection notes
Because most UPS HATs deliver power through the GPIO header rather than the Pi's normal USB/barrel power input, they typically require running the Pi's official low-voltage warning to be disabled or reconfigured, and it's worth checking whether the specific HAT model leaves the rest of the 40-pin header accessible for stacking other HATs. Battery status is usually read over I2C so a background script can trigger a clean shutdown before the battery is fully drained.
- 40-pin GPIO header (pass-through): Mounts on and passes through the Pi's GPIO header, supplying regulated 5V power while typically leaving GPIO pins available for other HATs/wires
- Battery terminals: Connection points for the onboard Li-ion/LiPo cell(s), usually via a JST connector or solder pads
- Power input (micro-USB/USB-C/barrel): Main 5V power input from the wall adapter
- I2C (SDA/SCL, via GPIO pass-through): Used by many UPS HATs to report battery voltage/capacity to software running on the Pi
Integration checklist
- Confirm the exact part number and breakout-board revision.
- Verify supply voltage, current demand, logic levels, and signal direction against the datasheet.
- Check controller pin assignments and bus address or interface mode against the example code.
- Power up with external loads disconnected, then test signals before full integration.
- If readings or communication fail, check power and ground first, then pin mapping, interface settings, and library initialization.
Troubleshooting and reproducibility
Record the board used, wiring, library/version, supply arrangement, and measured behavior. Use the selected board-specific wiring example as the source of truth. Never assume visually similar modules share identical voltage tolerance or pin order.
Setting Up UPS HAT with Raspberry Pi
Library
smbus2 (Python) by Community (varies by HAT vendor)
pip3 install smbus2 — the exact register map/library differs by manufacturer (Waveshare, Geekworm, PiSugar all differ); check your specific HAT's wiki page.
Wiring
| Component pin | Raspberry Pi pin | Note |
|---|---|---|
| HAT connector | GPIO header (all 40 pins) | Sits directly on the Pi's GPIO header — no jumper wires. Physically screw-mount with standoffs if provided. |
| SDA/SCL | GPIO2/3 (I2C) | Most UPS HATs report battery voltage/capacity over I2C to an onboard fuel-gauge IC — used by the monitoring script, not for wiring. |
Swipe sideways to see every column →
- UPS HATs vary significantly between manufacturers — some use a MAX17040-family fuel gauge (as in the example register map above), others use a completely different IC and I2C address. Always pull the exact code from your specific HAT's product page rather than assuming this generic example matches yours.
- Enable I2C first via
sudo raspi-config→ Interface Options → I2C, then confirm the HAT is detected withi2cdetect -y 1before writing any code against it. - Most UPS HATs report "capacity" as a battery-model estimate (like the MAX17043 fuel gauge covered elsewhere in this catalog), not a precise coulomb count — treat percentages as approximate, especially near empty.
- This is a power-continuity HAT, not a component you wire with jumpers — it physically mounts on the 40-pin header, so there is no "component wiring" step beyond seating it correctly and connecting its battery.
Related Components
Related Guides & Projects
Raspberry Pi Pico W and Pico 2 W: Install MicroPython with Thonny or UF2
Hold BOOTSEL, drag the correct UF2 file, open the REPL and blink the onboard LED. Includes the Pico vs Pico W vs Pico 2 W firmware differences and what to do when the drive does not appear.
Raspberry Pi Pico W Web Server in MicroPython: Control an LED and Read a Sensor
Connect the Pico W to WiFi, serve a responsive control page, switch an LED and display the onboard temperature or an external sensor, with timeouts and reconnect handling.
Raspberry Pi Pico Oscilloscope with MicroPython
Convert a Raspberry Pi Pico into a basic 500 kSPS oscilloscope using its 12-bit ADC and MicroPython. Displays waveforms on an SSD1306 OLED or streams samples over USB serial to a Python plotter on your PC.
Self-Hosted Nextcloud NAS on Raspberry Pi 4
Build a private, durable Nextcloud NAS on a Raspberry Pi 4 -- SSD boot instead of a failure-prone SD card, Docker Compose with Redis caching, Tailscale for remote access with zero ports forwarded, and an automated backup strategy that actually runs.