# calculating transistor base resistance in parallel circuit

I am trying to use Raspberry Pi GPIOs to turn on and off optocouple switches controlled by transistors.

I really have no idea what I am doing (programming the thing okay. Wiring it? Not so much). I think that the base resistors are my problem, but I really don't know.

There are 20 switches.

Each one is connected to a separate GPIO pin at 3.3 Volt Output. (I have only drawn 3 for clarity)

The Optocouples require 1.2 V at 20 mA.

I really think my problem is the 10k ohm resistors but I don't have a clue how to calculate the needed resistance here.

• What are you doing with these lines? What frequency, duty cycle, etc. Any and all information you can provide will help a lot. Other than that, you are using a single R1 for all of them. Are you using them at the same time? Also, is there a reason you cannot sink $5\:\text{mA}$ with your GPIOs? – jonk Mar 1 '18 at 4:31
• In the text you say "10 KOhm resistors" but I don't see them in the diagram... Also, a common resistance (R1) for all the LEDs of the optocouplers will mean trouble. Give each LED its own resistance. – Claudio Avi Chami Mar 1 '18 at 4:32
• you're right... i'm sorry that is my mistake... they are 10K ohm, i accidentally marked them as 10 ohm – me_ Mar 1 '18 at 4:34
• Edited to fix the resistors in the schematic – me_ Mar 1 '18 at 4:41
• @me_ (1) The optoisolator you specified appears on first blush to only require about 5 milliamps of current to drive it. Most GPIO pins can handle that without the addition of external transistor circuits. So I believe all that extra stuff may not be required. Just one resistor per GPIO. (2) How often will you set these GPIO HI or LO. Once a year? Or once every microsecond. It matters. (3) What % of the time will they be HI and what % LO? – jonk Mar 1 '18 at 6:12