I am looking to detect 12+V from a car wire using an Arduino.

I have found the following schematic:

enter image description here

I know how crazy automotive voltage can get so I just want to make sure the schematic I found above will accommodate the crazy random currents that the car could produce.

Also, wouldn't I need some type of heat sink taken that I am stepping down a +12V to 5V or less? That, in my mind, would produce a pretty good amount of heat?

  • 1
    \$\begingroup\$ A simple resistive voltage divider would work best in this case. A transistor is only needed to step up the voltage for whatever reason. A heat sink is not necessary because the current through the components is not very high. The more power consumed by the components (P = I * V) the more heat will be dissipated. en.wikipedia.org/wiki/Voltage_divider \$\endgroup\$ Jun 24, 2013 at 5:10
  • 5
    \$\begingroup\$ Kurt - you're right in theory but in practice automotive systems are subject to lots of variation + spikes + EMF so if you had a divider that produced a reliable logical 1 @5v (so at least 3v, probably 4v to be safe when cranking) from 12v, it may go high enough to damage the arduino when the car is charging (modern "smart" alternators will run to nearly 20v at times). StealthRT's circuit is very reasonable and I've seen many similar use in automotive applications. \$\endgroup\$
    – John U
    Jun 24, 2013 at 8:23
  • 2
    \$\begingroup\$ For reference: www.industrologic.com/autotransients.pdf \$\endgroup\$
    – John U
    Jun 24, 2013 at 8:40
  • \$\begingroup\$ One could follow the 2-resistor voltage divider with a Zener diode, though. \$\endgroup\$ Aug 24, 2014 at 11:53

4 Answers 4


Knowing that all sorts of weird stuff can happen in automotive power circuits, and not being especially knowledgeable in those systems, I'd err on the side of caution and use an opto-isolator.


simulate this circuit – Schematic created using CircuitLab

Pin 1 = Car 12v R1
Pin 2 = Car Ground
Pin 3 = NC
Pin 4 = Arduino Ground
Pin 5 = Arduino 5v R2
Pin 6 = NC

With this scheme, your Arduino and the car aren't connected electrically at all. At worst, the optoisolator is destroyed, and you can replace it for less than a dollar. Put it in a socket and you won't even need a soldering iron to perform the repair.

R1 was selected such that input voltage transients up to 120V won't exceed the maximum forward current of U1. D1 avoids exceeding the maximum reverse voltage of U1 if the input voltage is inverted. The value of R2 isn't especially critical, so it might as well be the same value as R1.

You won't need any heat sink. Heat is the result of electrical energy being converted to heat, and power is the rate of energy conversion. Power \$P\$ in an electrical system is the product of current \$I\$ and voltage \$E\$:

$$ P = I E $$

So, the voltage itself doesn't make heat: it also depends on how much current is flowing. In both these circuits, the current is low enough that the power is small and no heatsink is required.

  • \$\begingroup\$ +1 for optocoupler, this is practically what they were designed for in the first place. \$\endgroup\$
    – shieldfoss
    Jun 24, 2013 at 13:38
  • \$\begingroup\$ I like this. That 4N25 is 25 cents at Jameco (as an example). \$\endgroup\$
    – mikeY
    Jun 24, 2013 at 15:09
  • \$\begingroup\$ @Phil Frost do you happen to know what the pin out would be? does the 12v come into pin 1? The 5v comes into pin 5? \$\endgroup\$
    – StealthRT
    Sep 12, 2013 at 22:05
  • \$\begingroup\$ @StealthRT if either of those pins see 12V or 5V with respect to their respective grounds (pins 2 and 4), a 4N25 will be destroyed. See the datasheet for the pinout, and acceptable operating conditions. \$\endgroup\$
    – Phil Frost
    Sep 13, 2013 at 11:42
  • 1
    \$\begingroup\$ As said by @PhilFrost one comment ago, you can use the internal pull-ups instead of R2. These are configure in Arduino using pinMode(pin, INPUT_PULLUP). \$\endgroup\$ Jun 9, 2018 at 21:51

You are on the right track, never hurts to have the reverse diode in there although you can belt-and-braces it by sticking an 18-22v Zener in its place.

This is a similar version, widely used and works fine: http://www.msextra.com/forums/viewtopic.php?f=101&t=40330

Some good background info on the nature of transients in automotive applications Harris appnote , for starters this graph says a fair bit:

enter image description here

Here's the circuit from the forum link above: Circuit for reference

  • \$\begingroup\$ Where's the reverse diode / zener you mention? I don't see any such thing in the schematic. \$\endgroup\$
    – Phil Frost
    Jun 24, 2013 at 13:44
  • \$\begingroup\$ It's not in that circuit, but if you replace the diode in the OP's circuit with a Zener it will protect against over-voltage as well as reverse-voltage. \$\endgroup\$
    – John U
    Jun 24, 2013 at 15:25

As noted in the comment to the question: "A simple resistive voltage divider would work best in this case." The voltage divider detects presence of 12V (HIGH @3V3 or 5V) and converts the voltage of the car circuit down to Arduino levels. http://en.wikipedia.org/wiki/Voltage_divider

  • Vout = R2 / (R1+R2) * Vin
  • 3300/(10000 + 3300) * 12.8V = 3.17V
  • 6800/(10000 + 6800) * 12.8V = 5.1V

Be aware that the voltage of the car may be higher than 12V, but at the lead-battery it should not exceed 13.8V for charging reasons. I have used this for detecting a 12V circuit. You can also try to use this to detect charging levels of the battery if you connect it to an Analog input.

  • \$\begingroup\$ This would normally be OK, although I'm not sure at some of the higher voltages occasionally present (as shown above) how well the internal clamp diodes in an AVR would cope with it. \$\endgroup\$
    – PeterJ
    Aug 24, 2014 at 9:46
  • \$\begingroup\$ If you use the 3V3 circuit with a 5V Arduino you should be safe. 3V is still detected as HIGH, and you can have over-voltages of 20V on the divider. \$\endgroup\$
    – cat
    Aug 25, 2014 at 8:30

It may be a bit late, but what I did is very simple. Understand this, optocoupler is the way to go to make your entire circuit simple and isolated from the car/motorcycle power system. But, instead of buying one, you can build one within 10 - 30 cents. Using a 3.2V white LED, ~620 Ohm resistor and a LDR. Now its just a simple LDR voltage reading on your Arduino side to detect whether there is any Battery (+) Positive is connected or not (engine on/ battery connected).

Connect 620 ohm resistor to the negative pin of the LED. Then connect the 12V negative with the other end of the resistor. Connect the Positive 12V terminal with the positive pin of the LED.

The good part is, it can handle voltage up to 19 Volts.enter image description here


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.