Step down voltage from 12V to 5V

hello and good day.

i have been working on a new project that involves me to read a specific voltage and the voltage ranges from 12v to 0v

my question is how do i scale it down from 12v to 5v so the Arduino can read it from an analog input pin. If i were to use a voltage divider, what value resistor should i use? or do i just use an available voltage sensor module that i can find on market?

thank you kind sirs.

Let's see.

5:7 is the ratio(5V output, 7 V 'waste'). Or, V1 = V2*R1/(R1+R2); V1 =5, V2 = 12; pick an R1, solve for R2.
Either way, if you use 10k for the lower resistor, you need 14k for the upper. (Put the lower resistance to ground, higher resistance to 12V).

Now, 14k is not a standard value, but the trick is, any ratio resulting in 1:1.4 will work.
If you use 15 k, your divider has a little 'headroom'.

By the way, if your 12V source is automotive, be aware that you should assume 13.8V steady state minimum, higher is better (I'd use 15V, and put in some transient protection as well); recalculate with that in mind.

1 Like

can i know why you say the 7v waste. also i did some google search, i do want to stick with a simple solution but other solution that i found are to use an op-amp.

I already confused with the many option of the op-amp. I am sure there are for more a lot of specific use case scenario.

Sorry, 'waste' seems to have triggered an unusual question. It's simply 'not of interest', it's the voltage across the lower resistor you measure.

Not all Arduino's will accept 5V on the analog input. Is this an automotive application?

yup, im trying to read from a something like a wheel that i pull out from an old car. That thing rotates and works with 12V supply. is it possible that i just use 5v and read it directly?

Back in the pre-Arduino days, the Dark Ages, we had potentiometers.
Few know what they are anymore.

2 Likes

I decide to use INA219 current sensor as it also can read voltage. I figure out that i need to put a 10K resistor on the VIN- terminal

Could that "wheel" be a DC motor? How many wires are sticking out of the wheel?

You mean a 3 wire rheostat? :grin:

Note that when switching inductive loads, the instantaneous voltage levels may levels may
greatly exceed steady-state levels due to inductive kickback. Chip damage can
occur if you do not take precautions to protect against inductive spikes.

Be careful inserting noisy loads that can cause a sharp current draw, such as DC
motors, since they can cause problems on the power lines and may cause the
INA219 to reset, etc. When using a DC motor or a similar device, be sure to
include a large capacitor to decouple the motor from the power supply.

The above is from the Adafruit data sheet. If "something like a wheel" is a motor or other inductive load. Be sure to read the data sheet entirety and understand what it is telling you. Failure on this can cause your Arduino sales person to sell you another one and another one ...etc.

@gilshultz and @JCA34F, this is what i manage to pull out from the pcb, im still figure out the resistor value and looks like it, it looks like a giant voltage divider with different R1 and R2 making different output voltage

Just be careful to NOT connect voltage higher than your MCUs Vdd. (3.3V ?)

imma try to use the ina219 module. it seems can read voltage up to 25V. when i try using it, i found out that i need to put a 10k resistor to the VIN- pin in order for it to read the voltage

Screenshot 2024-02-01 180700

is there any particular explanation of why do i need to put the 10k resistor on the VIN- or it just was supposed to be like that?

@cookie95

is there any particular explanation of why do i need to put the 10k resistor on the VIN- or it just was supposed to be like that?

You should have netport53 connected to VIN- NOT VIN+

i notice it on my serial monitor, the voltage was read inversed.

Did you connect to VIN- with no resistor

it reads voltage as soon as i put the 10k resistor. Also, what purpose does the resistor serve when i put it?

Looks like it may be a 4 speed blower control switch. How big are those resistors? How about some pictures?

Can you provide a link the the particular module you are using.
The bus voltage is measured at VIN- without a resistor.
Maybe your board has shunt resistors on it.