Efficient 230 VAC Power‑Outage Sensor for Raspberry Pi – Low‑Cost, Compact, and Safe
Track the 230 VAC mains with a compact, low‑cost circuit that delivers a clean digital signal to any microcontroller.
While a 12 VAC approach works for low‑voltage monitoring, it is unsuitable for high‑voltage mains because of excessive power dissipation. The circuit below resolves that issue with a minimal component count and negligible energy draw.
There are three viable ways to detect a blackout:
- Use a step‑down transformer, rectify, and condition the output for your logic level.
- Repurpose a phone charger: remove the output capacitor or replace it with a lower value to obtain a fast‑responding 5 VDC signal.
- Build the circuit described here, which is the cheapest, most efficient, and smallest option.
All three methods are valid; the choice depends on your constraints. In my experience, the proposed design offers the best trade‑off between cost, size, and power consumption.
The Circuit
Explanation
For readers unfamiliar with electronics, here’s why the circuit works:
- A 100 nF capacitor presents an AC impedance of roughly 32 kΩ at 50 Hz (Z = 1/(2πfC)). This limits the current to about 7 mA (I = V/Z), keeping power dissipation below 1 W.
- Unlike a resistor, a capacitor does not convert electrical energy into heat; it merely reacts, so the 32 kΩ impedance does not overheat.
- The capacitor effectively drops the mains voltage, allowing the subsequent rectifier to produce a low‑voltage DC output suitable for logic inputs.
- Because the current is limited by the capacitor’s impedance, the output voltage is determined by the load rather than a fixed transformer ratio. Therefore, the component values on the low‑voltage side (resistor, small electrolytic) must be chosen carefully, but the design tolerates minor variations.
Compared with a transformer, this approach uses fewer parts, consumes less power, and offers intrinsic current limiting.
Note for 110 VAC 60 Hz Systems
To adapt the circuit for 110 VAC 60 Hz, replace the 100 nF capacitor with a 150 nF (or 220 nF) component. A 150 nF capacitor works well on both 230 VAC 50 Hz and 110 VAC 60 Hz mains, while the 100 nF version provides a slightly faster response on 230 VAC.
Practical Use
I integrate this sensor into my home‑automation stack. The Raspberry Pi is powered by a standard 5 V adapter and backed by a portable power bank. When mains power fails, the power bank keeps the Pi running, while the sensor detects the outage and triggers a notification via Domoticz. The notification can be sent over a router with a UPS or via the mobile network, allowing me to log blackout duration and automate actions (e.g., turning off Hue lights that would otherwise re‑enable on reboot).
Warning
High‑voltage mains can cause serious injury or death. Treat all components with care. Once the circuit is assembled, seal the enclosure (hot glue or a proper project box) to prevent accidental contact with live parts.
Safety Measures
Additional safeguards improve reliability:
- Use an MOV (V1) rated for 230 VAC to clamp voltage spikes that might reach the capacitor (C1).
- Include a fuse in series to protect against short‑circuit conditions.
- Ensure that the low‑voltage components (R1, C2, U1) have voltage ratings that exceed the maximum post‑rectification voltage (≈325 V). A 400 V electrolytic is excessive; a low‑voltage capacitor with a parallel Zener diode provides a graceful failure mode.
- Film capacitors (like C1) typically fail open, which is safe because the current is limited to about 7 mA.
With these precautions, the circuit remains safe, reliable, and easy to implement.
Source: Power Outage Sensor
Manufacturing process
- PWM Power Controller: Build a Pulse‑Width Modulated Lamp Driver
- Power Supply Circuits: Types, Design Principles, and Performance
- Understanding Power in Electric Circuits: Measurement & Significance
- Understanding Capacitor Transient Response: Charging Dynamics, Asymptotic Behavior, and SPICE Simulation
- AC Capacitor Circuits: Capacitive Reactance, Phase Shift, and Power Behavior
- Three‑Phase Power Systems: Fundamentals and Benefits
- Accurate Power Measurement in AC Circuits: From Electrodynamometers to Hall‑Effect Sensors
- Understanding Flicker: Impact on Power Quality and How Variable Speed Drives Help
- Step-by-Step Guide to Charging Capacitors Safely and Efficiently
- Overvoltage Explained: Causes, Risks, and Prevention