1
\$\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\$
3
  • \$\begingroup\$ Do you need the isolation the optocoupler provides? If not, you can just use a voltage divider. \$\endgroup\$ Commented Feb 10, 2020 at 10:58
  • \$\begingroup\$ @awjlogan Honestly not. I tried with a voltage divider which is working fine. But thought about a different approach with Opto.. \$\endgroup\$ Commented 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\$ Commented 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\$
3
  • \$\begingroup\$ Thanks a lot friend.. But I have a little question... Is that 10k is pulldown resistor?? \$\endgroup\$ Commented Feb 10, 2020 at 12:55
  • 2
    \$\begingroup\$ Look at the schematic: It's clearly a pull-up resistor. \$\endgroup\$ Commented Feb 10, 2020 at 13:24
  • \$\begingroup\$ can't we use arduino's built-in INPUT_PULLUP to eliminate the 10K Resistor? \$\endgroup\$ Commented 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\$
3
  • \$\begingroup\$ Thanks friend.. A question... You have mentioned to size the series resistor properly.... But why the resistor required since it handle 24v? \$\endgroup\$ Commented 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\$ Commented Feb 10, 2020 at 13:24
  • \$\begingroup\$ Which is 16mA as per the line below. \$\endgroup\$ Commented Apr 6, 2024 at 17:44

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.