# Switch seperate 12V circuit with Rasp Pi Zero

I'm trying to use a Raspberry Pi Zero to control our apartment unit's buzzer phone (the thing that lets people at the building door in).

There is a momentary push-button that completes a 12VDC circuit, causing the door to be unlocked. I've attached leads so that when I touch them together, it does the same thing as pressing the button.

So far I've tried two approaches to wire this up to a rasp pi.

The first was with a single NPN transistor controlled by one of the +3.3V GPIO pins. Verified the circuit concept by controlling a simple LED circuit with the GPIO high or low. Then I tried it with the buzzer, hooked the +12V from the buzzer to the collector and the 0V to the emitter. This didn't work, and caused some buzzing in the phone.

Next I tried this Opto-isolator breakout https://www.sparkfun.com/products/9118 in hopes that isolating the two systems would be more straightforward and eliminate the possibility of a ground loop. I also tried this with the LED proof-of-concept circuit. It was noticeably dimmer when going through the opto-isolator vs. not, and it didn't end up working out with the buzzer. I'm thinking it introduces too much resistance.

If you were doing this, what approach would you take? Is there any way I can modify my approaches to make something work?

• I'd use a relay. – Roger Rowland Sep 15 '16 at 4:43
• Is it 12VAC or 12VDC that operates the door using the switch? – jonk Sep 15 '16 at 5:15
• @jonk - It is 12VDC. – computmaxer Sep 15 '16 at 5:23
• That's important. The a.c. answers will be more complex than you need. – jonk Sep 15 '16 at 5:24
• Added an answer now. – jonk Sep 15 '16 at 9:17

You mention buzzer phone and that it completes a simple 12VDC circuit, but then also mention causing 'buzzing in the phone'.

Reading between the lines of this I assume that you mean you have an intercom system with a door unlock/release button on the handset and a unit at the door entry ?

The short answer if so is, use a relay it is by far the easiest option.

There are several possible scenarios with an intercom system.

1. The button on the intercom is a dry contact that switches the door lock power directly.

2. Same as above but rather than directly powering the lock the push button is an input to an access control system or similar that controls the lock.

3. The button is actually part of a circuit on the intercom handset, this will then perform some sort of function on the intercom system, depending on the type. Some may then activate a relay on the door station or a similar relay/actuator module somewhere. Some door stations or modules may have powered lock outputs rather than a relay. Typically the intercom may be a bus system with audio/video and potentially data/lock functions on the same wires, some may use several dedicated wires, it varies massively with proprietary yet similar systems used by different manufacturers.

Given you say you caused buzzing by connecting a transistor I suspect that it may be something like 3, where you are affecting your handset's circuit in unexpected ways and if so it may be difficult to determine how to connect a transistor without knowing the circuit design of the handset.

• Definitely #3, it's a system that supports audio and video, multiple intercoms per unit, etc. I've ordered a relay, thank you! – computmaxer Sep 19 '16 at 5:31
• No worries. Relay as Roger initially suggested is definitely the easiest solution. I've spread some upvote love, the other guys have more fleshed out answers with helpful info just slightly off the mark for your case. – D-on Sep 20 '16 at 0:02

Traditional doorbells typically work on AC, stepped down from line voltage (120 VAC in the US) to 10-20 VAC. If true in your case, this would explain why an NPN transistor didn't work (only conducts current one way). I like Roger's idea of using a relay as the simplest way that's likely to work. But if you wanted to use a semiconductor, a TRIAC can be made to work. Here's a circuit I found with a quick search on 'low voltage triac' that might serve your purposes.

You could consider a 3.3VDC relay. You'd need to drive its coil and this would mean a single BJT circuit. Those relays are a couple of dollars, plus shipping. But it would work, for sure. And it's a very good option, actually.

But I think another possibility is that your BJT wasn't sufficiently driven by your I/O pin to hold in the door lock solenoid. Instead, it's likely that you oscillated because you didn't have enough current (or voltage) available.

Since you don't provide ANY details about your door lock solenoid, other than there is an adequate 12VDC source for it, let's just do a little over-kill with BJTs and go with that.

simulate this circuit – Schematic created using CircuitLab

In looking up door lock solenoids that run off of 12V, I found that at least some of them require about 2.6A in order to operate. So I'm going with that as an educated guess about your needs. Frankly, I think the above circuit will almost certainly work for you. But $Q_1$ will probably drop about $400mV$. I don't think that will be a problem for you, though.

The above circuit is designed to use the absolute minimum of parts, if you aren't using a relay (which as I said above, and which Roger wisely mentioned in his comment.) I've added the power requirements of each part, so you can make sure you get sufficiently rated parts. (The 2N3055 is already rated way more than you need, so just use it without question.) For example, $R_1$ will burn about $500mW$, so you should buy one that is rated for $1W$, at least. $Q_2$ won't be a problem. Even a TO-92 part will work find there.

$Q_2$ is going to operate somewhat saturated, so it will require some base current. If you are lucky, only $2mA$ or so. But even if this is more like $5mA$ you should be fine with your IO pin. $R_1$ sets the base current into $Q_1$ and is set to deliver $200mA$ or more. If you have various values of $1W$ resistors laying about, you might try a $12\Omega$ or a $15\Omega$ in there, as well. Or even larger, if the door latch continues to work okay. I've set it low to start out, so you get LOTS of current to drive the base of the 2N3055 BJT. Just to make sure.

You might also measure the current when you switch your latch. That information would help a lot in dialing in this circuit to fit, better. But I think the above circuit is overbuilt enough that it will do the job.

Oh. And the circuit is ON when you drive the IO PIN to LOW. When the IO pin is HIGH, then the circuit is OFF.

And I'm curious. How is the Raspberry Pi going to be better than a human being pressing the button to let someone in? Which adds another question. Would you prefer a circuit that the Raspberry Pi triggers, but where the circuit itself times the duration and then automatically removes the power so that the door is no longer unlocked? (Would be very simple to add that capability.)