10
\$\begingroup\$

Circuit Diagram

I'm trying to control my garage door remote with a GPIO pin from my Raspberry Pi. Instead of driving a relay, it would be much easier to just short the pushbutton on the remote. Is this how I should do it? Do I need a protection diode and if so, where should it go?

Does it matter that the 3.3V GPIO pin is referenced to a different ground (Raspberry Pi ground) than the remote ground?

Would also appreciate guidance on transistor to use and resistor value.

UPDATE; More info from comments by OP: After checking, you're right, the pushbutton simply shorts the circuitry to the return path of the 9V battery. My main concern is the 3.3V being referenced to GND while everything on the remote is floating.

\$\endgroup\$
9
\$\begingroup\$

To eliminate any possibility of surprise, and to generally make things more robust, I'd suggest using an optocoupler like 4N25.

schematic

simulate this circuit – Schematic created using CircuitLab

With this arrangement, you don't need to worry about how to combine the separate grounds of the two systems, because their grounds simply aren't connected. Also, if there's a problem on either end, the optocoupler may isolate the fault to one side, and is cheap to replace, where a Raspberry Pi or garage remote is not.

Depending on exactly what the garage remote is, you may need to add another transistor to handle additional current, because the 4N25 has an absolute maximum of 50mA. Q1 is one way to do that, and general PNP transistor you can find will work in this application. This arrangement formed by Q1 and the output transistor of the 4N25 is called a Sziklai pair.

One potential disadvantage of this solution is that when the transistor is on, the remote (represented by U1 here) will see only about \$8.2V\$, where it would have seen the full \$9V\$ had these transistors been replaced with a mechanical switch. This is because you lose \$0.6V\$ from the emitter-base drop of Q1, and another \$0.2V\$ from the collector-emitter drop of the 4N25. However, I doubt this will be a problem in practice.

\$\endgroup\$
  • \$\begingroup\$ Probably the safest solution of them all (so far). \$\endgroup\$ – jippie Jul 22 '13 at 19:11
  • \$\begingroup\$ Thanks Phil, I like the optocoupler solution. The max RPi GPIO current is about 50mA so I think I may not need Q1. I have available a 130 ohm resistor and with 3.3V that's about 25mA and I have an MCT6 opto available with max current of 60mA on the emitter (diode) side. The current transfer ratio is 20% which means about 5mA on the detector (transistor) side ... which I'm not sure is enough for the remote but I'll give it a shot and see. \$\endgroup\$ – nummy Jul 23 '13 at 14:44
4
\$\begingroup\$

Right idea, wrong execution. Assuming your diagram of the remote is correct (I have no way of verifying and there could be a lot of different configurations), you want to use a PNP transistor. The NPN as emitter follower that you show won't work because the blue block will only see the 3.3V digital level minus the B-E drop.

That leaves a problem as to how to turn on the PNP. Here is a simple way:

Q2 will sink about 2.7 mA when the digital signal is high. Figuring Q1 should have a gain of at least 50, that will allow the block to draw up to 130 mA, which is probably a lot more than a garage remote draws. Adjust R1 accordingly if more current is needed.

However, are you really sure the button simply applies power to some block? That could make sense if there was only a single button, but is probably incorrect if there are two buttons, like open and close. My first guess would be that power is always applied and the button shorts some line to ground, although there could be a lot of different configurations.

Added:

You now say that the pushbutton doesn't turn on power to the unit, but shorts some line to ground. That makes more sense. In that case, this circuit should work:

The grounds of the remote and the computer need to be tied together, but there is no problem with that. The remote is a single isolated device, so there is nothing wrong with tying one of its nodes to some external reference. I see that others are making a big deal of this, but that is silly. There are cases where you want to isolate a switch like this, but when the device itself is arbitrarily floating as it is in this case, adding isolation is just a knee-jerk reaction or to satisfy religious beliefs.

\$\endgroup\$
  • \$\begingroup\$ After checking, you're right, the pushbutton simply shorts the circuitry to the return path of the 9V battery. My main concern is the 3.3V being referenced to GND while everything on the remote is floating. \$\endgroup\$ – nummy Jul 23 '13 at 14:35
  • 1
    \$\begingroup\$ @nummy: See addition to my answer. Don't let the superstitions of others scare you about connecting the grounds. There is no electrical reason they can't be connected. \$\endgroup\$ – Olin Lathrop Jul 23 '13 at 15:16
3
\$\begingroup\$

The idea behind your circuit is fine, the implementation requires some improvements:

schematic

simulate this circuit – Schematic created using CircuitLab

You have two choices, I like the left circuit best:

  • LEFT: Short the switch and move the NPN transistor to the low side of the battery. This is most common way of controlling a load from a microcontroller. RPi's ground and the remote's ground are shared.
  • RIGHT: If you really want use the contact for the push button, which may mechanically easier to implement, then you need an PNP transistor and you want RPi's Vcc and the remote's Vcc interconnected. This may be tricky if an RPi has an on board voltage regulator. You need the 3V3 power supply rail of the RPi here. Also for this reason I would go for the left; it is more robust, simpler to implement. Actually I like Olin's solution better than the right circuit too.

Any cheap general purpose small signal transistor will work.

  • For left NPN eg.: BC547, BC548, 2N3904, ...
  • For right PNP eg.: BC557, BC558, 2N3906...

There are really lots and lots to choose from. Depending on your geographic location other part numbers may be more common. Just walk in a shop and ask for an equivalent of the ones mentioned above.

  • \$\text{h}_\text{FE}\$ or \$\beta\$ > 100

  • \$\text{V}_\text{CE,max} > 15\text{V}\$

  • \$\text{I}_\text{C,max} > 100\text{mA}\$
  • I'm guessing that you want a TO-92 package, which is reasonably easy to experiment with.
  • Price indication in a regular shop when sold per piece? I'd say € 0.20 again depending on geographic location.

The resistor can be pretty much anything around 1kΩ-10kΩ\$ and 250mW carbon film or better. Similar price as the transistor in regular retail.

\$\endgroup\$
  • \$\begingroup\$ Whoops, you are right! \$\endgroup\$ – jippie Jul 22 '13 at 18:40
  • \$\begingroup\$ I think I corrected the mistake, please review @PhilFrost \$\endgroup\$ – jippie Jul 22 '13 at 19:08
  • \$\begingroup\$ Looks reasonable \$\endgroup\$ – Phil Frost Jul 22 '13 at 19:34
1
\$\begingroup\$

First, yes, the grounds need to be connected together if you're using direct galvanic connections like a transistor. An optocoupler is probably safer.

Second, why worry about the remote? The garage door opener should have a manual trigger, which is just a regular pushbutton on a wire. You can drive this with a transistor, or with a small relay that you in turn drive with a transistor or optocoupler.

\$\endgroup\$
  • 1
    \$\begingroup\$ There are tons of reasons that someone might want to hack a control instead of the main device. Accessibility, ease of replacement if you fubar it, portability, size, etc. And, in my experience, the garage door opener in my house did not have a manual button on it. \$\endgroup\$ – Passerby Jul 23 '13 at 5:42
  • \$\begingroup\$ I wanted to use the remote because the RPi is very far away from the garage door pushbutton. \$\endgroup\$ – nummy Jul 23 '13 at 14:36
  • \$\begingroup\$ I agree there may be valid reasons to use the remote instead of a manual button input -- but the original post doesn't talk about that, so I made sure to suggest it. Making-connection (Normally Open) pushbuttons can be wired in parallel; you can have more than one wired to the same opener. Thus, if the RPi is far away from the current button, you could just run a second wire to the RPi and use that for opening. This is likely to be more robust than driving the remote, although the remote idea can probably work just fine as well. \$\endgroup\$ – Jon Watte Jul 25 '13 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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