1
\$\begingroup\$

I'm working on my raspberry pi door bell and facing the electricity problems that is beyond my knowledge, please help

What I have: one AC wire from door bell, it's around 0V when Idle, then when someone press the door bell button, it increases to 5V AC

What I want to achieve: My RPi needs the 3.3V DC input to monitor the "Button Press" action, so my first thought was to get a relay or transformer to convert the 5V AC to 3.3V DC. So I brought one from amazon, something called Adjustable Power Module/Regulator, here's the link: http://www.amazon.com/gp/product/B0052YHXOA?psc=1&redirect=true&ref_=oh_aui_detailpage_o02_s01

What's my problem: well, it doesn't work, the multimeter shows 0 or a very low voltage (around 0.3V) from the DC output from that Module, so I guess that I was getting the wrong thing

I'm asking around to find out any idea or any solutions to convert my 5V AC to 3.3V DC, so I can connect to my RPi to continue the project

tks in advance and Merry Christmas to everyone!

\$\endgroup\$
  • 1
    \$\begingroup\$ Do you have access to a soldering station with some protoboard? This problem can be solved pretty easily with 2 resistors and a diode if you do. \$\endgroup\$ – NathanielJPerkins Dec 22 '15 at 6:27
  • \$\begingroup\$ tks for the quick reply Perkins, I'm not too sure about the soldering station with some protoboard, you mean something like a breadboard? sorry the hardware wiring part is just not my expertise, I'd love to learn more if you can provide me a bit more details \$\endgroup\$ – Joe Lu Dec 22 '15 at 6:32
  • 1
    \$\begingroup\$ More something like this. Allows you to build your own small circuits by soldering in components and wire to create connections. blog.mklec.com/wp-content/uploads/2014/07/mk-vb26.jpg \$\endgroup\$ – NathanielJPerkins Dec 22 '15 at 6:34
  • \$\begingroup\$ A breadboard would also work fine. Breadboards are obviously less permanent than protoboard (if that's actually what it's called) and solder. \$\endgroup\$ – user253751 Dec 22 '15 at 6:36
  • \$\begingroup\$ Well I wouldn't use it for any permanent solution, and it sounds like he's after a permanent solution @immibis \$\endgroup\$ – NathanielJPerkins Dec 22 '15 at 6:38
3
\$\begingroup\$

I think using a full-bridge rectifier is a bit too trusting. I don't like connecting digital pins to mains, even through a transformer. A transient fault could obliterate your RPi.

Here's my approach - use an optoisolator to provide an isolation barrier. The diode inside the optoisolator conveniently doubles as a half-wave rectifier. I paralleled a capacitor with the ballast resistor on the optoisolator output. This forms an envelope detector.

enter image description here

Here's what the voltage at the output of optoisolator looks like. I had the AC supply on for half a second, then it switched off:

enter image description here

This would probably be fine to feed into the Pi but I personally didn't care for the ripple, so I added a comparator midway between 3V3 and ground. This is what the 3V3_BELL_DETECT output looks like alongside the input:

enter image description here

LTSpice sim is here if you want it.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ +1 for the optical isolation. This is the best way to ensure safety to pi. Also, I don't think ripples will create a trouble as long as signal is above the LOGIC HIGH threshold. Op might have to experiment a little with R1 and C1 values though. 0.1uF ceramic and 400K seem to work fine in one of the circuits I designed. Opto-coupler was PC817. \$\endgroup\$ – Whiskeyjack Dec 22 '15 at 7:47
  • \$\begingroup\$ From this description I don't think it's actually connected to mains at all. It outputs 5v. There's no mains rectification needed. \$\endgroup\$ – NathanielJPerkins Dec 22 '15 at 7:49
  • 2
    \$\begingroup\$ Considering it's AC it'd be going through a transformer down to 5VAC. That does imply isolation but there's a couple reasons I wouldn't trust that. One, there's a small chance it's not an isolation transformer - it could be an autotransformer (although I admit that's not likely). Two, even it is an isolation transformer there's no guarantee its ground reference is going to be the same as the RPi - it could be referenced to system neutral for all we know. Without ripping apart the wiring to find out I think optoisolation is the safest way to go. \$\endgroup\$ – Peter Dec 22 '15 at 7:55
  • 1
    \$\begingroup\$ @PeterK Eh, I would probably just throw a \$1G\Omega\$ resistor in there to provide a reference. Not that it matters for the simulation. \$\endgroup\$ – Daniel Dec 22 '15 at 8:36
  • 1
    \$\begingroup\$ @Daniel: I think this does the trick: i.imgur.com/R4ROMSv.png \$\endgroup\$ – Peter Dec 22 '15 at 8:38
0
\$\begingroup\$

Edit: It's now obvious that the OP has no idea if the doorbell transformer is fully isolated, and has no way to tell. In that case, this is a bad approach.


Do you have any idea if this circuit is isolated by the doorbell transformer? That would make this very simple.

Something like this:

schematic

simulate this circuit – Schematic created using CircuitLab

Edit: Added R2 to drain off capacitor when doorbell is released.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Hi Daniel, tks for the reply. \$\endgroup\$ – Joe Lu Dec 22 '15 at 7:12
  • \$\begingroup\$ I don't have much knowledge about the physical wiring, in my apartment, I have a single black wire from the wall, where it should connects to the main apartment door. The wire has no voltage at all until someone press the door button, then I read it from my multimeter, it shows 5V AC \$\endgroup\$ – Joe Lu Dec 22 '15 at 7:14
  • 1
    \$\begingroup\$ Maybe you should just use a 5V relay then... \$\endgroup\$ – Daniel Dec 22 '15 at 7:16
  • \$\begingroup\$ Out of curiosity, where do you connect the other lead of the meter? One wire is not sufficient to make a circuit! \$\endgroup\$ – Daniel Dec 22 '15 at 7:17
  • 1
    \$\begingroup\$ What's a "heat pole"? \$\endgroup\$ – EM Fields Dec 22 '15 at 7:45
-2
\$\begingroup\$

For a cheap and easy solution, the following circuit can be used. For further reading, this is a half wave rectifier. Daniel's is a full wave rectifier. For your application though, you don't need a full wave solution, you just need to detect a peak, and this solution will give you that.

schematic

simulate this circuit – Schematic created using CircuitLab

The AC source only has it's positive wave rectified into usable DC, so directly after the diode it's experiencing positive DC voltage of up to 5v - diode voltage. The voltage divider of R1 and R2 then step the voltage down to approximately 3v3, so it will trigger the Raspberry pi.

It's a simple enough circuit to prototype on your own breadboard and get working, as well as solder it yourself on a more permanent piece. Note that the capacitor isn't strictly necessary, but helps to smooth out any potentially damaging voltage spikes. Further protection could be added in the form of a zener diode on the RPi_input node.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ this is simple enough to understand, I will go ahead to give a try on the breadboard first, hopefully it will work, tks again \$\endgroup\$ – Joe Lu Dec 22 '15 at 7:50
  • 2
    \$\begingroup\$ This isn't safe, and probably won't even work for several reasons! 1) How do you know the AC from the doorbell is at the same potential as the Pi ground? 2) Where is your connection to the Pi ground, how does the circuit get its earth reference? 3) 1 kOhm is much too small to save the Pi. 4) 5 volts AC has a peak value of 7 V, so you're not dividing it down enough. \$\endgroup\$ – tomnexus Dec 22 '15 at 8:04
  • 2
    \$\begingroup\$ @joelu this circuit as currently drawn will almost certainly toast your Pi as soon as you connect it. Please use an opto-isolator or a relay. \$\endgroup\$ – tomnexus Dec 22 '15 at 8:11
  • \$\begingroup\$ tks tomnexus, I guess I have to seek some other solutions, my Pi is still not cooked :) however, still appreciate Nathaniel's effort, thank you \$\endgroup\$ – Joe Lu Dec 22 '15 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.