User Tools

Site Tools


A blackout detector for the Raspberry PI


This are my first steps into electronics. I have power problems at my current home, with random blackouts that are driving me crazy. These are specially annoying when you are out of home (vacation) and there is nobody there to put the big switch again on.

Instead of complaing to the gods for my misfortune, I tried to workaround this problem in the nerd's way: I have constructed a blackout detector that sends me a message to my phone when the power goes off at home. So, if I am outside, at least I will know it.

The idea

I one of those fortunate guys who have an UPS at home. It is not a powerfull one, but at least is enough to save your data and prevent a disaster. Having this and a Raspberry PI, the only thing is a power detector to wire it to the GPIO bus and I will have my blackout detector.

I did this by stabilizing a spare power source from an old phone and tame its output to 3.3V, the voltage needed by the input pins of the GPIO bus.

Ladies and gentlemen, the power source

I've started with this power source, and my initial idea was to use a simple resitor to lower the voltage to 3.3V, but when I went to measure the output given, I received a big surprise: the output was 8V, very far from the 4.5 expected.

I've asked around and I found out that you can lower this value in a safe way by connecting it to an voltage stabilizer. It is a circuit that outputs some voltage regardless of the input voltage you have.

In essence, this is made by an integrated cirtuit called LM317, a pair of resistors and two capacitors. Here is the schematics:

Picking the values of the resistors is the most complicated thing. To ease it, I've selected one fixed and the other a variable resistor: by trimming it afterwars you can fix the voltage to a very precise value. Moreover, I've discovered how handy is it when the output voltage changed when I've enlarged the output cable.

Here is a picture of the resulting circuit:

I've bought a box to protect it. Here is the final product:


raspberrypi/blackoutdetector.txt · Last modified: 2014/12/24 10:42 (external edit)