0
\$\begingroup\$

I'm trying to input 12v into Ardunio Digital inputs. But since Arduino digital input max voltage is 5v, I would like to use an optocoupler as a switch for 12v input into 5v from Arduino itself.

So I have got P621 Opto, But I' little concerned about the opto handle 12V??

Also for optos both in and out can withstand same voltage??

I'm only a beginner since not much able to grasp the tech jargons from the datasheets..

\$\endgroup\$
5
  • \$\begingroup\$ I am assuming that you meant for your 5th word to be 12V, not 1V, based on your further description. \$\endgroup\$
    – Mattman944
    Feb 10, 2020 at 10:40
  • \$\begingroup\$ Do you need the isolation the optocoupler provides? If not, you can just use a voltage divider. \$\endgroup\$
    – awjlogan
    Feb 10, 2020 at 10:58
  • \$\begingroup\$ @Mattman944 You are right mate.. Sorry for that.. \$\endgroup\$ Feb 10, 2020 at 12:52
  • \$\begingroup\$ @awjlogan Honestly not. I tried with a voltage divider which is working fine. But thought about a different approach with Opto.. \$\endgroup\$ Feb 10, 2020 at 12:53
  • \$\begingroup\$ @SandeepThomas Optos are slow, expensive, and large - if you don't need the full galvanic isolation (ie, no shared ground), but want to protect the Arduino inputs, use a buffer IC and/or put in some protection diodes. \$\endgroup\$
    – awjlogan
    Feb 10, 2020 at 13:45

2 Answers 2

4
\$\begingroup\$

Think in terms of current. You want your input voltage to cause about 10 mA to flow in the LED. The LED will drop 1-2 volts, so (12-2)/0.01 = 1k.

The output transistor will produce a current that you need to convert to a voltage with a resistor. For low speed signals, 10k is a good choice.

Note that this circuit will invert the signal, 12V in will cause a logic zero. This is easily handled in software. Or, you can reverse R2 and Q1 to get a non-inverted signal.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
4
  • \$\begingroup\$ Thanks a lot friend.. But I have a little question... Is that 10k is pulldown resistor?? \$\endgroup\$ Feb 10, 2020 at 12:55
  • 2
    \$\begingroup\$ Look at the schematic: It's clearly a pull-up resistor. \$\endgroup\$ Feb 10, 2020 at 13:24
  • \$\begingroup\$ @SandeepThomas No it is niether of them, it is a current limiting resistor. Letrs put it this way. You can have it connected to mains AC which is 220V and it will still work, it is all about the current that needs to be limited. So your optocoupler can handle roughly 10-20mA input to the LED. It can be 5000V or 1M V as long as current stays around 10-20mA, and for that you would use a resistor. V = IR. I = V/R \$\endgroup\$ Feb 16, 2020 at 11:29
  • \$\begingroup\$ can't we use arduino's built-in INPUT_PULLUP to eliminate the 10K Resistor? \$\endgroup\$
    – Ohbhatt
    Jul 7, 2020 at 19:34
0
\$\begingroup\$

But I' little concerned about the opto handle 12V??

enter image description here.

The electrical specifications states that it can accept upto 24V. So, 12 V is with in the valid operating range.

Also for optos both in and out can withstand same voltage??

The LED can be surely driven by the 12 V too. Important thing is to size the series resistor properly so that the recommended Foreward current of the opto LED is not violated.

Also, you can think of placing a diode in reverse direction across opto LED for reverse voltage protection

\$\endgroup\$
2
  • \$\begingroup\$ Thanks friend.. A question... You have mentioned to size the series resistor properly.... But why the resistor required since it handle 24v? \$\endgroup\$ Feb 10, 2020 at 13:08
  • \$\begingroup\$ the LED current should be limited to some value, else the LED will get hot and burns out. Please refer to the datasheet to know the maximum LED current alowed \$\endgroup\$
    – User323693
    Feb 10, 2020 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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