Wed Jun 26, 2013 1:50 pm
Use an opto-coupler with appropriate series resistor (4K7) connected to the opto-couplers LED, and place a small diode (1N4148) anti-parallel over the LED (so that the led is protected against voltages of the wrong polarity for the LED).
connect it across the door bell, the 8V AC will light up the LED 50 times a second.
On the photo-transistor side connect the emitter to GND, and the collector to the GPIO, together with a 4K7 pullup to 3V3.
This will pull down the GPIO 50 times a second. If you would rather have it pulled down as long as the bell rings, simply connect a 100uF elco across the photo-transistor, the photo-transistor will discharge the elco and it will stay discharged in between the 50Hz pulses. If you want to make things foolproof, don't connect the GPIO directly, but put a 2K2 resistance in series, that way outputting a "1" (accidentally) while the bell rings (photo transistor is open) won't damage the GPIO.