0

I'm trying to close the contacts of a remote controller (wires are soldered to either side). I have an RPi and I'm yet to buy an optocoupler.

What would I need to get this to work? A Pi outputs 3.3v from a GPIO, but can power a circuit independently at 5v.

schematic

simulate this circuit – Schematic created using CircuitLab

shorting a remote control pushbutton with GPIO and a transistor

I was referencing this thread, but they've included a 9v battery, and I don't know what purpose that serves.

Alternatively, I could use a relay powered by the 5v Pi output which is triggered by the GPIO, but I worry that the contacts on a relay are too resistive to conduct a small switch short. Please advise!

Thank-you!!

EDIT: Thanks to user Passerby, I now have formula for finding an optocoupler and resistor.

Assuming the Pi outputs 3.3v at 16mA, what's a suitable resistor/optocoupler combination (x & y on schematic)?

yeeeeee
  • 33
  • 1
  • 1
  • 8
  • Just a note: If you use a photo-transistor optocoupler, you will need to make sure you have the polarity correct when wiring to the switch. If you us a FET optocoupler, like the H11F1, then you don't need to worry about polarity. – Mark May 30 '16 at 01:10

2 Answers2

1

Aside from an appropriate ballast resistor in series with the led side of the optocoupler r = (3.3 - Vf) / If), yes, that should work.

That post had a remote powered by a nine volt battery. Nothing really changes as far as your concerned with a 3 or 5 volt remote instead.

A relay will work too. The contacts of the relay should only have a negligible resistance (near perfect conductor). But then you have an issue of driving the relay, as the gpio cannot do it directly.

An optocoupler is ideal. But you could just use a simple npn transistor (2n3904). You would have to connect the grounds of the remote and the RPI together.

Passerby
  • 72,580
  • 7
  • 90
  • 202
  • I'm guessing that the GPIO outputs about 250mA (I don't have a volt meter) and a 4N25 is 60mA, so: r= (3.3 - vf)/0.19. What's the on voltage of a 4N25? (I'm guessing that's the vf?) – yeeeeee May 30 '16 at 01:05
  • The RPI gpio max is 16 mA! – Passerby May 30 '16 at 01:10
  • @yeeeeee the 4n25 normal Vf is 1.3~1.5V at 50mA. The 60 mA is an absolute max. But it should work at lower voltages/currents. For a simple pushbutton setup, it may (should in my opinion) work fine at 16 mA forward current, at which point the Vf is about 1 volt. But you may want to find a better optó coupler. – Passerby May 30 '16 at 01:17
  • So r=(3.3-1)/0.16? 143.75 ohms for the resistor? (Sorry, this is really first time electronics for me) – yeeeeee May 30 '16 at 01:22
  • @yeeeeee no, 16 mA is 0.016 Amps. – Passerby May 30 '16 at 02:10
  • Typing mistake. (I calculated 0.016) Is it otherwise correct? I should look for 143.75 ohms for the resistor? Do I just divide by the amperage of the Pi (16mA), and not the optocoupler? r=(3.3-1)/0.016? – yeeeeee May 30 '16 at 02:15
  • Yes. Since 16 mA is the max you want to pull. And since current is the same on series, 16 mA is what will go through the optó led. – Passerby May 30 '16 at 02:40
-1

I believe I've solved the problem. I'll be testing out a ~140 ohm resistor and 4n25 optocoupler.

Other optocoupler/resistor suggestions are greatly appreciated.

yeeeeee
  • 33
  • 1
  • 1
  • 8