Build a Smart UPS & Backup System for Raspberry Pi & Jio AirFiber
After corrupting my Raspberry Pi's SD card twice due to sudden power cuts, I learned an important lesson: running a 24/7 server without backup power is asking for trouble. Add my Jio AirFiber router to the mix, and every power outage meant losing both internet and my cloud server.
Here's how I built a reliable, affordable backup power system for under �4,000 that provides hours of runtime and automatic clean shutdowns.
The Problem
My setup includes:
- Jio AirFiber router 12V, ~12W power consumption
- Raspberry Pi 4 5V, ~10W with external drive
- Power cuts 2-3 times per week, lasting 10 minutes to 2 hours
Sudden power loss causes:
- SD card corruption on the Raspberry Pi
- Interrupted file transfers leading to data loss
- Internet downtime affecting remote work
- Need to manually restart everything after power returns
The Solution: Dual UPS Approach
Instead of one expensive specialized UPS, I use a two-tiered system:
- Standard UPS for the router and main power
- Mini-UPS modules for direct 5V/12V DC power to devices
This combination provides maximum runtime at minimum cost.
Part 1: Main UPS for Router
Recommended Options
Option A: Artis 650VA UPS (�2,400-�2,600)
- 650VA / 360W capacity
- 2-3 hour runtime for router alone
- 4-5 hour runtime for router + Raspberry Pi
- Available on Amazon, Flipkart, offline stores
- Built-in surge protection
- Replaceable battery (easy maintenance)
Option B: Zebronics ZEB-U725 (�2,800-�3,000)
- 725VA / 400W capacity
- Slightly longer runtime than Artis
- Better build quality
- LED indicators for battery status
- Auto voltage regulation
Why These Models?
For low-power devices like routers and Raspberry Pi, you don't need expensive high-capacity UPS units designed for PCs. These entry-level models provide:
- Sufficient wattage (our total load: ~22W)
- Long runtime due to minimal power draw
- Affordable price point
- Wide availability and service support
Runtime Calculations
Approximate runtime with 650VA UPS:
Load: 22W (router 12W + Pi 10W)
Battery: 12V 7Ah typical
Runtime = (Battery Wh � Efficiency) / Load
Runtime = (84Wh � 0.7) / 22W
Runtime H 2.5-3 hours
In practice, expect 2-3 hours of full operation during outages.
Part 2: Mini-UPS for Direct DC Power
While the main UPS works, using AC output � wall adapters � DC is inefficient. Mini-UPS modules provide direct 5V/12V DC with integrated battery backup.
5V Mini-UPS for Raspberry Pi
Search for "5V DC UPS" or "Raspberry Pi UPS" on Amazon/AliExpress:
- Price: �800-�1,200
- Battery: Typically 18650 lithium cells (2-4 cells)
- Output: 5V 3A (sufficient for Pi 4)
- Runtime: 4-6 hours for Raspberry Pi alone
- Features: Pass-through charging, automatic switchover
12V Mini-UPS for Router
For Jio AirFiber or similar 12V routers:
- Price: �1,000-�1,500
- Battery: 12V lithium-ion pack
- Output: 12V 2A
- Runtime: 3-5 hours for typical router
- Bonus: Can also power 12V LED strips, cameras, etc.
How They Work
- Normal operation: Mains power charges battery and powers device
- Power cut: Instantly switches to battery (no interruption)
- Power return: Switches back to mains and recharges battery
No switching delay, unlike traditional UPS which have 5-10ms switchover time.
My Recommended Setup
Configuration 1: Maximum Protection (�4,000)
- Artis 650VA UPS (�2,500) Main power backup
- 5V mini-UPS (�1,000) Raspberry Pi dedicated backup
- 12V mini-UPS (�1,200) Router dedicated backup
Advantages:
- 4+ hours runtime on Pi and router even if main UPS fails
- No power conversion losses (DC directly from mini-UPS)
- Clean power for sensitive electronics
- Modular can replace/upgrade components individually
Configuration 2: Budget-Friendly (�2,500)
- Artis 650VA UPS only
- Power both devices through their standard adapters
Advantages:
- Lower upfront cost
- Simpler setup
- Still provides 2-3 hours backup
Trade-offs:
- Power conversion losses (AC�DC�AC�DC)
- Slightly shorter runtime due to inefficiency
Installation and Setup
Main UPS Setup
- Unbox and charge UPS for 8-12 hours before first use
- Connect router's power adapter to UPS outlet
- If using Configuration 2, also plug in Pi adapter
- Test by disconnecting mains power devices should stay on
Mini-UPS Setup for Raspberry Pi
- Connect mini-UPS input to power source (wall adapter or main UPS)
- Connect mini-UPS output directly to Raspberry Pi USB-C power port
- Verify 5V 3A output is stable using `vcgencmd get_throttled`
- Check that Pi runs correctly on battery power
Mini-UPS Setup for Router
- Identify router's power requirements (12V 1-2A typically)
- Connect mini-UPS input to mains or main UPS
- Connect mini-UPS 12V output to router's DC jack
- Verify router boots and maintains connection
Smart Shutdown Integration
The real intelligence comes from detecting power failure and shutting down the Pi gracefully before battery depletes.
Simple Approach: Monitor GPIO
Some mini-UPS modules have a status pin that goes LOW when on battery. Connect to Pi GPIO and monitor:
import RPi.GPIO as GPIO
import os
import time
POWER_STATUS_PIN = 17 # GPIO pin connected to UPS status
GPIO.setmode(GPIO.BCM)
GPIO.setup(POWER_STATUS_PIN, GPIO.IN)
while True:
if GPIO.input(POWER_STATUS_PIN) == GPIO.LOW:
# Power failure detected
time.sleep(120) # Wait 2 minutes
if GPIO.input(POWER_STATUS_PIN) == GPIO.LOW:
# Still on battery after 2 min, shutdown
os.system('sudo shutdown -h now')
time.sleep(10)
Advanced Approach: UPS HAT
Purpose-built Raspberry Pi UPS HATs (like Geekworm X728) offer:
- Integrated battery management
- Safe shutdown scripts
- Power monitoring via I2C
- Automatic startup when power returns
- Price: �3,000-�4,000
Monitoring and Maintenance
Battery Health
UPS batteries degrade over time:
- Test monthly by simulating power failure
- Replace battery every 2-3 years (�800-�1,200 for 12V 7Ah)
- Keep UPS in cool, ventilated area
- Don't fully discharge hurts battery lifespan
Runtime Testing
Periodically test actual runtime:
- Fully charge UPS
- Disconnect mains power
- Note start time
- Monitor until UPS low-battery alarm
- Record runtime for reference
Declining runtime indicates battery replacement needed.
Logging Power Events
Create a log of power failures:
#!/bin/bash
echo "$(date): Power failure detected" >> /var/log/power-events.log
Helps identify patterns and UPS effectiveness.
Power Consumption Optimization
To extend runtime, reduce power draw:
Raspberry Pi Optimizations
- Disable HDMI: Saves ~25mA
/usr/bin/tvservice -o - Reduce CPU frequency: Lower performance but longer runtime
- Disable unused USB ports
- Turn off LED indicators
- Use efficient storage: SSD instead of spinning HDD
Router Optimizations
- Disable Wi-Fi if not needed during backup (use Ethernet only)
- Reduce transmit power if range isn't critical
- Disable unused features (guest network, USB ports)
Cost-Benefit Analysis
Total Investment
Artis 650VA UPS: �2,500
5V Mini-UPS: �1,000
12V Mini-UPS: �1,200
-----------------------------------
Total: �4,700
What You Get
- Protection from SD card corruption (saved me �2,000+ in lost work)
- Uninterrupted internet during short outages
- Peace of mind for server uptime
- 4+ hour runtime for critical devices
- Clean shutdown capability preventing data loss
Alternative Costs
- Raspberry Pi UPS HAT: �3,500-�4,500 (Pi only, not router)
- Enterprise UPS: �6,000-�15,000 (overkill for this use)
- Generator: �30,000+ (loud, expensive, fuel costs)
Troubleshooting Common Issues
UPS Keeps Beeping
Likely overloaded. Check that total wattage doesn't exceed UPS capacity. For our setup, 22W is well within limitsif beeping, battery may be failing.
Raspberry Pi Shows Under-Voltage Warning
Mini-UPS output voltage dropping below 4.75V. Check:
- Battery charge level
- Output current capacity (need 3A for Pi 4)
- Cable quality (use thick, short cables)
Short Runtime Despite New Battery
- Verify battery is genuine (many fakes on market)
- Check for power-hungry peripherals (external HDDs draw significant power)
- Ensure UPS is fully charged before test
Future Enhancements
- Solar charging: Add solar panel to recharge UPS batteries during day
- Remote monitoring: Webhook notifications when power fails
- Graceful service shutdown: Stop services in priority order before shutdown
- Automatic resume: Pi powers back on when mains returns
- Multiple Pis: Scale system to support additional servers
Lessons Learned
1. Prevention is cheaper than recovery: �4,000 for UPS vs. hours of work recreating corrupted systems.
2. Don't skimp on power supply quality: Cheap UPS with poor voltage regulation can damage devices.
3. Test regularly: UPS sitting unused for months may fail when actually needed.
4. Document your setup: When UPS beeps at 3 AM during power cut, you'll want clear notes on what to do.
5. Clean shutdowns save data: Automated shutdown scripts are worth the effort to implement.
Conclusion
Building a backup power system for Raspberry Pi and Jio AirFiber router is straightforward and affordable. The combination of a standard UPS plus mini-UPS modules provides hours of runtime at under �4,000less than the cost of replacing one corrupted SD card and lost work.
For anyone running a home server, NAS, or critical network equipment, backup power isn't optionalit's essential infrastructure. The peace of mind knowing your systems will survive power outages is well worth the investment.
Power cuts are inevitable. Data loss isn'tif you prepare properly.