# 8V AC signal into 3.3V digital input pin

I'm a noob and I'm doing this to learn, basically.

I have a typical old-style door bell with a transformer that outputs 8V AC, the wire the goes through the push button on the door and finally hits a solenoid-based ding-dong thingy.

I'd like to tap into this circuit and extract a signal that I can safely feed into one of the digital 3.3V input pins of my very delicate Raspberry PI.

I have a few diodes, capacitors, resistors, a couple of transistors and a lot to learn.

• not really a question ... consider re-wording to make it clearer exactly what you are asking Commented Oct 7, 2014 at 20:09
• @smashtastic I don't agree. It seems like a perfectly fine question to me. Commented Oct 7, 2014 at 20:18

You can use one of your pretty transistors and a couple of the diodes, resistors and capacitors in several ways, here's one:

simulate this circuit – Schematic created using CircuitLab

NOTE ABOUT VALUES: I just estimated the value of capacitor C1. If the RasPi sees a 50Hz or 60Hz (depending on your location) on/off when you keep the button pushed, it's too small. I guesstimate it to run empty in about 200ms, but since the diode doesn't full rectification if I'm off by too much... If it is too large the signal will stay on much longer than the button press, up to you if you mind about that.

For this design it is very very important to always only use AC power supplies that are unrelated to your Raspberry Pi. If the Raspberry Pi is powered from the same AC power source through a rectifier and capacitor, don't connect BELL Wire 2, or this will cause serious problems!

The Diode sends the current only into the capacitor. The capacitor gets charged when BELL Wire 1 is higher than BELL Wire 2, when BELL Wire 2 is higher than BELL Wire 1 the Diode blocks any current that wants to escape out of the capacitor.

The capacitor's "sort of DC" now feeds the resistor's base through R1, allowing it to turn on. This then pulls the RasPi input pin down to its GND, away from the 3.3V Power that it was fed through R2.

Once the BELL transformer's power disappears the capacitor will empty itself into the transistor and after a very short time (much less than a second) the transistor will have depleted it so much it will switch off again, letting the RasPi pin go back high through R2.

So you do need to remember about this: The signal you see at the Raspberry Pi will be inverted: When the bell goes the Input Pin will be tied to GND (0) and when the button is not pushed it will go to 3.3V (1).

• Thanks a lot. Very informative. Just one question: by connecting BELL Wire 2 straight to GND, isn't the 8vac power supply going to somehow feed electrons into the raspberry pi when it shouldn't? I have this (maybe wrong) mental image of GND as being this neutral land of piece, and I'm worried that my GND will instead be a rollercoaster of alternating current. Please forgive my noob-iness. ;) Commented Oct 7, 2014 at 20:36
• @StefanoMasini Very good question in fact. The annoying thing with the word "Ground" is that it means too many different things. But even if the GND was connected to the planet in some way, which is very unlikely to be a direct connection, at worst a 22nF or 1MOhm, then the 8VAC from the bell transformer most certainly is not related to that same ground. The bell transformer isolates the 8VAC from the 230VAC and Ground on the other side, so there is no path at all for the current to run through. Commented Oct 7, 2014 at 20:42
• is 8V (after being rectified) going to be within limits of the Transistor's base-emitter voltage rating? usually they are 6V max, I'd be careful and do a resistor divider with an extra 10K resistor - you only need 650-700mV at the base for most transistors to turn on, so you can do quite heavy voltage dividers if needed Commented Oct 7, 2014 at 21:00
• Thanks, I've checked the specs of my BC547C and indeed it's 6V. But what is a resistor divider? How do I connect this extra 10K resistor? Commented Oct 7, 2014 at 21:15
• @KyranF - You don't need a divider anywhere. In fact, that resistor can be driven up to 24V before anything bad happens. An NPN BJT with emitter to ground is a current driven current sink, forcing the base to 0.7V above emitter, the base is never going to be above that, ever, that's why the base resistor is there to limit the base current below the limit. Commented Oct 8, 2014 at 5:03

One way to go would be the following. Your signal is half rectified by $D_1$, that removes the negative voltage component. It then passes through $R_1$, which effectively raises the impedance of your signal, so that it can be clamped without any major current draw. $D_2$ and $D_3$ clamp your signal to levels roughly between GND and 3.3V. $C_1$ is optional, as it would provide stable-ish signal for you to sample (otherwise you'd end up with a half wave "rectangluoid". This is an extremely crude solution.

simulate this circuit – Schematic created using CircuitLab

What I would recommend instead, is using an optocoupler. It was designed for this exact purpose, that is isolating two domains safely against each other. You can find plenty of info all around the place. (Note that you can still do the $R_1 C_1$ filtering to get your ON-OFF signal)

• Thanks. I'm only confused about what you marked as "Your Signal". I have 2 wires coming out of the 8vac power supply (and after the switch). If I plug one of the two in the place marked "Your Signal", where should I plug the other? Together with the ground? Commented Oct 7, 2014 at 20:31
• Are you sure the extra diode drop caused by D2 is okay? I haven't researched this thoroughly, but I seem to recall something about the RPI not liking any voltage higher than its supply on the input by way of some part of the I/O stage. Feel free to cuss at me if you know better. Commented Oct 7, 2014 at 20:38
• Yes, I also had a similar doubt - though I wouldn't have phrased it so technically ;) I'm pretty sure the RPI doesn't like voltages higher than 3.3v on its pins. Commented Oct 7, 2014 at 20:47
• @Asmyldof with the 10K resistor, and the external diode clamps, this is fine. The RPI inputs will also have their own internal versions of the D2 and D3 setup, which is standard for all CMOS style inputs. Commented Oct 7, 2014 at 20:56
• It is best to use schottky diode clamps with as low forward voltage as possible of course, so the clamping is as good as it can get. 300-400mV forward drop is a good thing to aim for, as the RPI input ports probably have 'max ratings' of VCC (3.3V) + 500mV. Commented Oct 7, 2014 at 20:57

EDIT: I realized I misread the question and thought the OP was trying to power his RPi from the doorbell circuit. I'll leave this answer up for now in case it is useful to the OP, but it is not a direct answer to the question.

The fundamental AC-to-DC converter is called a full-wave rectifier. It's made out of four diodes arranged in a specific way. A bulk capacitor is attached to the output to smooth out the waveform. You can never achieve a perfect DC voltage from this circuit as the natural sinewave from the AC source will manifest itself as ripple in the output. But the larger the capacitor, the smoother it'll be.

simulate this circuit – Schematic created using CircuitLab

The diodes and capacitor you choose is based on the current and voltage requirements of your circuit. You shouldn't have too much trouble finding parts that will work at that small voltage and current.

To achieve the necessary regulated 3.3V for the RPi, assuming it's not doing anything that draws a lot of current, a linear regulator can be connected to the output of the rectifier. As long as the input voltage stays above the drop-out spec of the linear regulator, the regulator will output a nice 3.3V DC for your RPi.