Monitor Raspberry Pi Backup Power with Waveshare UPS HAT (B)

Read battery telemetry and record supply changes before designing an automatic shutdown policy.

PineMux Editorial 29 Sep 2026 3 min read

Industrial & Connectivity

Waveshare UPS HAT (B) — source hardware reference
Reference photo: Waveshare. Hardware or source project shown; see the guide for the proposed build.

01 / Project overview

The UPS HAT (B) offers an I2C telemetry example based on INA219 readings. Use this project to observe voltage and current during normal charging and backup operation. A first version should log behavior; a reliable shutdown system needs additional recovery and threshold testing.

02 / Materials & software

ItemWhat to check
UPS HAT (B)Use the B manual and exact board revision.
Compatible Raspberry PiCheck the HAT’s supported output and load.
Manufacturer-specified batteriesUse the required type and installation procedure.
Specified input supplyCheck polarity and charging guidance before assembly.

03 / Connections & first setup

Follow the manufacturer’s battery installation, polarity, and power connection sequence. Keep terminals clear of loose metal. This article does not replace the HAT’s battery instructions; use those instructions for cell selection and handling, then keep the bench setup mechanically stable.

04 / Build the project

  1. Read telemetry first

    Enable I2C and run the official INA219 example. Record battery voltage and current with external input present. Identify units and the example’s sign convention before assigning charging or discharging labels.

  2. Record a controlled transition

    Following the manual, remove external input for a brief observation while the Pi continues running. Save the telemetry change and restore input. Avoid draining the battery merely to prove the graph can go down.

  3. Build a timestamped log

    Append voltage, current, and operating state to a file. Treat a failed sensor read as unavailable. Do not infer an exact remaining runtime from one voltage reading or an uncalibrated percentage.

  4. Add a trend view

    Show recent measurements and mark input transitions. Keep raw values available alongside any smoothing. A sudden load change can be informative and should not disappear completely behind a moving average.

  5. Plan shutdown separately

    Before adding automatic shutdown, define low-battery criteria, persistence, clean OS shutdown, and how power will return. Test those behaviors with the documented hardware controls as a separate milestone.

Suggested log fields

time_utc,battery_voltage_v,current_ma,reported_state,read_status

05 / Check the result

CheckExpected behavior
External inputBaseline telemetry is stable and labeled.
Backup intervalThe current direction changes as documented.
Read failureThe monitor reports unavailable rather than zero volts.

Troubleshooting. A reversed current label is often a sign-convention issue. Read the example carefully before changing the hardware. If the Pi resets during a supply transition, check the supported load and power path; a prettier dashboard cannot correct an inadequate power setup.

06 / Sources & build notes

Prepared by PineMux from the official sources above. These are editorial build instructions; this project has not been bench-tested by PineMux. The cover shows reference hardware or a source project; image credit is provided above. Use the manufacturer’s revision-specific diagrams for exact wiring.

Shopping Cart
Scroll to Top