In my apartment, I have a door bell that has a red and white wire, they are 12 V AC, and when I connect them together, the door will open.

My idea is to connect these two wires to the Raspberry Pi (maybe to the GPIO?), and use Wi-Fi to signal the Raspberry Pi to connect two wires to open the door.

So physically, where should I wire to the Raspberry Pi? If it's on GPIO, which pin?

UPDATE::: I purchased a LM2577 step down transformer to convert my 5v AC to 3.3v DC, and I have a 1k resistor

Question: do I still need relay in between? Question2: When someone pushs the door bell, the voltage will increase from 0.1 to 5v, so I should be able to use

GPIO.add_event_detect(channel, GPIO.RISING, callback=my_callback)

to detect the event right?

  • 4
    Hello and welcome. Do not connect those wires directly to the GPIO pins! Have a look for relays. There are affordable add-on boards for the Pi out there that allow for a safe connection.
    – Ghanima
    Commented Dec 20, 2015 at 20:34
  • 4
    DO NOT CONNECT THESE DIRECTLY TO THE GPIO PINS - the PI is not designed for 12volts or AC. If you want to close the door circuit you will need a relay rated for 12v DC AC with a control circuit that can be controlled by the 3.3v DC Pi. Commented Dec 20, 2015 at 20:35
  • hi Ghanima, indeed, i will not connect anything until I understand everything, but I do need to find out which pin from the GPIO for such usage first :) and I will dig more about the relays for sure
    – Joe Lu
    Commented Dec 20, 2015 at 20:36
  • 2
    The "which pin" is more or less up to you! They're called General purpose input output pins for a reason ;) It's up to you to decide. If you do not connect much else, just pick any. And be sure to get a relay module that can be driven by the Pi's 3V3 output... and on a site note @SteveRobillard, got you ;)
    – Ghanima
    Commented Dec 20, 2015 at 20:43

1 Answer 1


If you connect your wires directly to the GPIO your raspberry pi will explode in sparks or maybe something less direcly harmful to it. No joke. Good that you have the transformer and resistor. You should wire it to a pin and then use this code:
GPIO.setup(pin number, GPIO.OUT)

to output from it and take input(same thing except with GPIO.IN instead of GPIO.OUT) or use a ground pin. These are the pin numbers 1-26 (pi 1 pins are all you need): http://raspi.tv/wp-content/uploads/2013/07/Rev2-GPIO-bold-173x300.jpg GND are ground pins and for output use the GPIO# ones
Question 1: Probably not, because of the resistor and transformer, but you might want it as a precaution
Q2: Yes, you should

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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