Skip to content

7 min read

Can Arduino Read 12 V?

Not directly. A GPIO pin is designed for the board’s logic voltage, typically 5 V or 3.3 V. Twelve volts will damage the input. A voltage divider scales the signal down to a safe range first.

Two resistors forming a voltage divider between a 12 V source and an Arduino analog input

At a glance

The short answer

An Arduino input pin tolerates the supply voltage plus a small margin. On a 5 V board that margin is only a fraction of a volt above 5 V. Applying 12 V drives far too much current through the input protection structure and can destroy the pin or the whole microcontroller. Never connect a 12 V source to a digital or analog pin.

Reading a voltage and powering a board are separate questions. Many boards accept a higher voltage on their VIN or barrel jack because an onboard regulator handles it. That regulator does not protect the GPIO pins.

How a voltage divider works

Two resistors in series across the source produce a scaled voltage at their junction. The upper resistor connects to 12 V and the lower resistor connects to ground. The junction goes to the analog input. The output is the input voltage multiplied by the lower resistance divided by the sum of both resistances.

For a 5 V board, a 30 kilo-ohm upper resistor and a 10 kilo-ohm lower resistor give one quarter of the input: 12 V becomes 3 V, comfortably inside the range. For a 3.3 V board the same ratio is also safe. Choose values in the tens of kilo-ohms so the divider does not waste much current.

Connect the grounds together

The divider’s lower resistor must connect to the Arduino ground, and the 12 V source’s negative terminal must be joined to that same ground. Without a common reference the analog pin floats and the reading is meaningless. This shared ground does not mean the source is at 5 V; it only aligns the zero point of both circuits.

If the 12 V source is isolated or generated elsewhere, make this connection deliberately and check it before applying power.

Protecting the analog input

A divider assumes the source is clean. Automotive and industrial 12 V lines carry spikes far above their nominal voltage. A small capacitor across the lower resistor slows fast transients, and a series resistor between the junction and the pin limits fault current. Clamping diodes keep the pin voltage inside the supply rails when a spike gets through.

Keep the resistance seen by the analog pin modest. The ADC needs time to charge its internal sample capacitor, and a very high source impedance makes readings drift. If measurements look unstable, lower both resistors while keeping their ratio.

Convert the raw reading back to volts

analogRead returns a number from 0 to 1023 on a 10-bit converter. The voltage at the pin is that number multiplied by the reference voltage and divided by 1024. With a 5 V reference, a reading of 512 corresponds to about 2.5 V at the pin.

Multiply by the divider ratio to recover the source voltage. With the 30 k and 10 k divider, the factor is four, so 2.5 V at the pin means 10 V at the source. Put this conversion in one small function, print the result for a known battery or supply, and verify it once with a meter before trusting it.

When to use a sensor module instead

If you need isolation from the measured circuit, or you are measuring tens of volts, a purpose-built voltage sensing module is easier to justify than a hand-built divider. It still outputs a low voltage suitable for the analog pin, but it adds protection and keeps the high-voltage side physically separate.

Whatever method you choose, state the measured range and the assumed reference voltage in your code comments. A correct formula with the wrong reference produces a confidently wrong number.

Frequently asked questions

Can I connect 12 V directly to an Arduino analog pin?

No. Analog pins have the same voltage limit as digital pins. Use a voltage divider or a suitable sensor module.

What resistor ratio brings 12 V below 5 V?

A 30 k upper and 10 k lower resistor give one quarter of the input, so 12 V becomes 3 V.

Do I need a common ground with the 12 V source?

Yes. The source negative terminal and the Arduino GND must be joined, or the analog reading has no reference.

Why does my measured voltage drift?

A high source impedance or a noisy supply can make the ADC reading unstable. Lower the divider resistors, add a small capacitor and average several samples.

Related pages