Building a reliable uninterruptible power supply DIY for 5V and 3.3V embedded loads requires more than just wiring a battery to a voltage regulator. A robust design demands a buck-boost or boost switching topology for the main rail, an LDO for noise-sensitive RF/ADC sections, and an ideal diode OR-ing controller to seamlessly transition between wall power and battery backup without dropping the rail below the microcontroller's brownout threshold.
This guide breaks down the exact power conversion topologies, dropout mathematics, and component selections needed to build a 5V/3A UPS capable of keeping a Raspberry Pi 5 or an ESP32 cluster alive during mains failures.
Topology Comparison: Switching vs. Linear for Embedded UPS
The most common mistake in embedded power design is attempting to use a linear regulator (like the LM338 or LM317) to drop a 2S Li-ion battery pack (8.4V fully charged) down to a 5V rail. To understand why this fails, we have to look at the dropout and thermal math.
If your Raspberry Pi 5 draws 3A during a heavy computational load, a linear regulator dropping 8.4V to 5V will dissipate the difference as heat: (8.4V - 5.0V) × 3A = 10.2W. A standard TO-220 package has a junction-to-ambient thermal resistance ($\theta_{JA}$) of roughly 50°C/W without a heatsink. A 10.2W dissipation yields a 510°C temperature rise, triggering instant thermal shutdown and potentially melting your breadboard.
For the main 5V rail, a switching topology is mandatory. However, for the secondary 3.3V rail powering an ESP32's RF frontend or a high-resolution ADC, a low-dropout (LDO) linear regulator is preferred to eliminate switching noise.
| Criteria | Synchronous Buck-Boost (Switching) | Low-Dropout Regulator (Linear LDO) |
|---|---|---|
| Efficiency (8.4V to 5V @ 3A) | 88% - 94% | ~59% |
| Heat Dissipation (at 3A) | ~0.9W - 1.5W | 10.2W |
| Output Ripple / Noise | 15mV - 40mV p-p | < 1mV p-p (PSRR dependent) |
| BOM Cost (IC + Passives) | $4.50 - $8.00 | $1.20 - $2.50 |
| Best Use Case | Main 5V Pi/USB rail | 3.3V RF, Audio, or ADC rails |
Design Example: 5V/3A Li-Ion UPS for Raspberry Pi 5
For this design, we will use a 1S Li-ion battery (3.0V to 4.2V) and boost it to 5V, combining it with a 5V USB-C wall adapter input using an ideal diode controller. This avoids the complexity of a 2S battery management system (BMS) while providing ample runtime for graceful shutdown scripts.
Input Range and Protection Circuitry
The primary 5V input from a USB-C PD wall adapter can experience transients, reverse polarity, and overcurrent events. Before the power reaches the OR-ing controller, it must pass through a protection front-end:
- Transient Voltage Suppression (TVS): A SMAJ5.0A TVS diode clamps any inductive spikes from the wall adapter cable to a safe 9.2V maximum, protecting downstream silicon.
- Reverse Polarity Protection: A P-channel MOSFET (e.g., Si2301) configured as a high-side switch. Unlike a standard diode which drops 0.4V and wastes 1.2W at 3A, the P-FET drops only $I^2 \times R_{DS(on)}$. With an $R_{DS(on)}$ of 45mΩ, the drop at 3A is just 135mV (0.4W dissipation).
- Overcurrent Protection: A 3A resettable PTC polyfuse (e.g., Bourns MF-MSMF300) trips if a downstream short circuit occurs, preventing the wall adapter from catching fire.
The Power Path: Boost and OR-ing
To manage the transition between wall power and battery, we use the LTC4359 ideal diode OR-ing controller. This IC drives external N-channel MOSFETs to combine the 5V wall input and the 5V boosted battery rail. When the wall power drops, the LTC4359 switches to the battery path in under 1 microsecond—fast enough that the Raspberry Pi's bulk decoupling capacitors bridge the gap without triggering a brownout.
For the battery boost stage, the TI TPS61088 is an excellent choice. It handles up to 10A of switch current, easily supporting a 3A continuous output.
| Parameter | Specification / Part Value |
|---|---|
| Primary Input | 5V / 3A via USB-C (Protected by Si2301 P-FET) |
| Battery Chemistry | 1S Li-ion (3.0V - 4.2V), 3000mAh minimum |
| Charge Controller | TI BQ24072 (1.5A charge current, power-path management) |
| Boost Converter | TI TPS61088 (1.1 MHz switching freq, 5.0V fixed output) |
| OR-ing Controller | Analog Devices LTC4359 (Ideal Diode, <1μs switchover) |
| Output Voltage | 5.0V ± 2% (4.9V - 5.1V under full load) |
| Maximum Continuous Current | 3.0A (Derates to 2.4A at 60°C ambient) |
Dropout and Headroom Math
When designing the secondary 3.3V LDO for an ESP32's RF section, headroom is critical. If we use the TPS7A47 LDO to drop the 5V UPS rail to 3.3V, we must verify the dropout voltage. The TPS7A47 datasheet specifies a maximum dropout of 310mV at 3A. Our available headroom is $5.0V - 3.3V = 1.7V$. Since 1.7V is significantly greater than 0.31V, the LDO will remain in regulation even if the main 5V rail sags to 4.0V during a heavy Pi boot sequence. Power dissipation in the LDO at a typical 500mA RF load is $(5.0V - 3.3V) \times 0.5A = 0.85W$, which is easily managed by a DFN package with thermal vias to an internal ground plane.
Thermal Management, Derating, and Ripple Expectations
Switching regulators generate heat in the inductor and the MOSFETs, and they inject high-frequency noise into the output rail. Managing both is the difference between a UPS that works on the bench and one that survives in a hot enclosure.
Inductor Saturation and Thermal Derating
The TPS61088 requires a high-current shielded inductor. A common choice is a 4.7μH, 10A saturation current part (like the Würth 744383). However, inductor current ratings are typically specified at 20°C ambient. As ambient temperature rises, the core's saturation threshold drops. At 60°C ambient (common inside a sealed 3D-printed enclosure housing a Raspberry Pi), the inductor's effective current capability derates by roughly 20%. If your peak switch current approaches 8A during a battery low-voltage boost cycle, a 10A rated inductor might saturate, causing a spike in MOSFET current and potential IC destruction. Always select an inductor with a saturation current ($I_{SAT}$) at least 30% higher than the IC's peak current limit.
Ripple and Noise Expectations
A boost converter operating at 1.1 MHz will produce output voltage ripple. The magnitude of this ripple is dictated almost entirely by the Equivalent Series Resistance (ESR) and Equivalent Series Inductance (ESL) of your output capacitors, not the capacitance value itself.
If you use a single 100μF electrolytic capacitor with an ESR of 50mΩ, and the inductor ripple current is 1A peak-to-peak, your output ripple will be $1A \times 0.05\Omega = 50mV$ p-p. While 50mV is acceptable for a Pi's digital logic, it will cause spurious readings on a 12-bit ADC.
The Fix: Use a parallel bank of low-ESR ceramic capacitors. Place three 22μF X7R MLCCs (0805 package) in parallel directly at the IC's output pin, followed by a single 100μF polymer aluminum capacitor for bulk energy storage. The MLCCs have an ESR under 3mΩ, pushing the high-frequency switching ripple down to <15mV p-p, while the polymer cap handles the low-frequency load transients.
Frequently Asked Questions
How do I calculate battery runtime for a DIY uninterruptible power supply?
Runtime calculation must account for the boost converter's efficiency, which drops as the battery voltage sags. The formula is:
Runtime (hours) = (Battery_mAh × Average_Battery_Voltage × Efficiency) / (Output_Power_mW)
For a 3000mAh Li-ion cell (average 3.7V) powering a 5V/2A load (10,000mW) through a TPS61088 operating at 90% efficiency:
(3000 × 3.7 × 0.90) / 10000 = 0.99 hours (roughly 59 minutes). Always subtract 15% from your final calculation to account for the battery's unusable capacity below the 3.0V undervoltage lockout (UVLO) threshold.
Can I use unprotected 18650 Li-ion cells in an embedded UPS design?
Yes, and in fact, it is often preferred for custom PCB designs. Protected cells contain an internal PCB that physically disconnects the cell during overcurrent or undervoltage events. In a DIY UPS, this sudden mechanical disconnect can cause massive inductive voltage spikes that destroy your boost converter IC. By using raw, unprotected high-drain cells (like the Samsung 30Q or Molicel P26A), you allow your dedicated charge controller (e.g., BQ24072) and software to manage the cutoff gracefully. You must, however, ensure your hardware includes a hard undervoltage lockout (UVLO) set to 2.8V to prevent deep-discharge damage to the cell chemistry.
Why does my ESP32 brownout when switching from wall power to battery in my DIY UPS?
Brownouts during switchover are almost always caused by slow OR-ing diode transition times or inadequate bulk capacitance. If you are using standard Schottky diodes (like the 1N5822) for OR-ing, the forward voltage drop ($V_f$) is roughly 0.4V. When the wall power drops, the rail sags by 0.4V instantly before the battery takes over. If your wall adapter was already outputting 4.8V under load, the 0.4V drop pushes the rail to 4.4V, which may trigger the ESP32's internal brownout detector (BOD) if it's configured aggressively. Switching to an active ideal diode controller (like the LTC4359 or LM66100) reduces the voltage drop to under 30mV and switches in under 1μs, keeping the rail completely stable during the transition.






