2

I am using the pi as a switch to short the pins on my motherboard to turn on my computer. I see many people use an optoisolator to do this to protect the board. What purpose does the isolator serve as opposed to a transistor?

Can I hook the 5V power switch to the collector, and the emittor to the ground, then connect the 3.3V gpio out to the base? Wouldn't this protect the board and accomplish the task on the optoisolator?

2

Optocouplers have two separate circuits.
See it sort-of like the simplified schematic asciiart below.

Optocoupler           Transistor
   _____                   _____
  |     |                 /     |
--|-LED-|--              /   /--|-- Collector
  |     |        Base --(---%   |
--|-LDR-|--              \   \--|-- Emitor
  |_____|                 \_____|

The optocoupler: The LED (Light Emitting Diode) emits light when powered.
The LDR (Light Depending Resistor) breaks the circuit when there's no light, and shorts the circuit when there is light. And since its all within a small black box, its all depending on the light from the LED.

So the only connection between the two circuits is optical, hence the word optocoupler.

While in a transistor circuit, the ground has to be the same for the two parts, so essentially 1 circuit.

  • can someone correct me here? Its not necessary the ground, but it could be the positive as well, but (as a non-native English writer) I'm struggling how to phrase that correctly... – ExploWare Mar 21 '14 at 10:40
  • Well it depends on how you drive the circuit. Usually it is ground on the emitor, as its much safer than the external voltage. So yes, most of the time it will be GND (Ground) – Piotr Kula Mar 21 '14 at 12:37
  • @ppumkin depending on a type of Transistor right? PNP stands for Positive-Negative-Positive and NPN vice versa. – ExploWare Mar 21 '14 at 15:32
0

You'll also need to connect the ground on the switch, to the ground on the Pi. Otherwise the 3.3V can't go anywhere.

You also need to add a resistor between the GPIO pin and the Base of the transistor.

Optocouplers are better if you are working with higher voltages, or if you don't want to connect the grounds of both items.

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.