Electronic – 8V AC signal into 3.3V digital input pin

raspberry pivoltage

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.

Best Answer

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

schematic

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).