I have 4n35 optocouplers, I am using these to isolate a motor driver circuit and the Arduino controlling it. I put one on the slave select pin and one on the tx line to the motor controller (there is no rx), however it is not working. I am using a 220ohm resistor between pin 1 of the 4n35 and the tx line from the Arduino and using no other resistors or capacitors. I am following this circuit I have been doing a lot of research on optocouplers and the 4n35. I have seen blogs and forums where people have achieved 9600 baud with it, but I don't understand how they did it.

What can I add to this circuit to make it work? Do I need to use a higher speed optocoupler such as the 6N137A?


You need a pull-up resistor on the output side of the opto, like this:


simulate this circuit – Schematic created using CircuitLab

If the output transistor's emitter is grounded, it can only pull the collector towards ground, or let it float. To ensure the motor driver receives a "High" when the transistor is off, you need to add the pull-up resistor.

  • 2
    \$\begingroup\$ Don't forget that using an NPN opto-coupler will invert the serial signal, so it needs to be inverted again, (or the input needs to be inverted ahead of the opto-coupler). \$\endgroup\$ – Nedd Jan 19 '15 at 21:09
  • \$\begingroup\$ Thank you, I tested this with the slave select pin and it switches between 0 and 5v but it is inverted as Nedd said so could I daisy chain a second optocoupler to avoid this? \$\endgroup\$ – Joel Jan 19 '15 at 21:28
  • 1
    \$\begingroup\$ You can reverse the positions of the resistor and the transistor.. \$\endgroup\$ – Spehro Pefhany Jan 19 '15 at 21:34
  • \$\begingroup\$ You could add an NPN transistor - no need for a second opto-coupler. Or you could change the software. \$\endgroup\$ – Peter Bennett Jan 19 '15 at 21:42
  • \$\begingroup\$ I just flipped the positions of the resistor and the transistor and that solved the issue. Thank you all so much for your help. \$\endgroup\$ – Joel Jan 19 '15 at 21:46

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.