Can someone confirm maths for voltage divider please

Hi all

I am making a simple voltage divider and have done the math for it as follows and want it looked at as the values seem very high compared to a few tutorials I found.

The formula is VR2=(R2/(R1+R2)) * vin
The battery vin is 12v but I have calculated using the maximum possible charged rate of the battery so have made it 15v
The bit I am unsure of is the info I found on the net stated I needed to guess(i hate guessing) how much current this circuit would use and stated it was probably 100 uA
therefore
RT=15v/100uA
RT=150 K ohms
R1+R2=150 K ohms

R2=(V_out/battery voltage) * RT
R2= 40K ohms
R1=RT-R2
R1=150K ohms-40 K ohms
R1=110k

So in my circuit R1=110K ohms and R2=40 K ohms

This will reeduce the voltage to 4v for the Arduino

Another question is do I need some sort of reverse voltage protection in this circuit?
I am using 2 12v 7AH batteries in series.
Perhaps a zener diode or something like that.

Thanks
Steve

The bit I am unsure of is the info I found on the net stated I needed to guess(i hate guessing) how much current this circuit would use and stated it was probably 100 uA

Are you trying to power something from a voltage divider? If so don't it will not work use a voltage regulator.
What circuit is drawing 0.1mA?
The absolute value of the resistors are not given by the formula it is just the ratio. The absolute values can be anything. If this is for measureing a voltage then make the bottom leg 10K and work out what the top leg should be.

The 10k resistor Grumpy_Mike suggests is used often with the Arduino.
For a good analog to digital conversion the impedance of the circuit should be 10k or less.

To measure 12V, you could use 33k for the other resistor.
If you are not sure about the voltage, you could add diodes (1N4148) from the resistors to ground and 5V (The 5V of the Arduino). But you would need an extra resistor of about 1k from the voltage divider (with diodes) to the analog input of the Arduino.

Hi
Thanks for the answers guys. I am not powering anything from the 12v except it is connected to a seperate circuit with a relay and motor which will only draw current when it is activated after the battery level has been read.
The Arduino is powered from a separate 6v battery through a voltage regulator.
I think for the equation I used it is assumed that just the circuit with the resister divider is drawing the 0.1mA

I think for the equation I used it is assumed that just the circuit with the resister divider is drawing the 0.1mA

sort of. It is a simple way of calculating the total resistance from the voltage.
Normally the current you want down a potential divider is about 10 times what you take out at the bottom. In your case for a measurement you want to bottom leg to be 10K to get the impedance right for the minimum sampling time of the A/D.
So with 10K and 5V across it then that gives you
5/10 = 0.5 mA
So you need 0.5mA down the resistor chain. If your top voltage is 15V then the top resistor has 15 - 5 = 10V across it.
So with 10V across a resistor that is carrying 0.5mA the resistor is:-
10 / 0.5 = 20K.
So that is a 20K resistor in the top and a 10K in the bottom.

STOP! You said you're using 2 12volt batteries in series. That's 24 volts not 12volts or 15 volts. Your 24 volt (30 volt?) stack will put 8+ volts to your 'newly smoked Arduino'.

Apologies
I meant 2 12v batteries in parallel.

Thanks Mike

That makes sense

No1Daemon:
Apologies
I meant 2 12v batteries in parallel.

Connecting batteries in parallel is a bad idea. They cross charge each other. Use a diode on each to link them.

Will this code do the trick?

/*

Prints the voltage on analog pin to the serial port
Do not connect more than 5 volts directly to an Arduino pin.
*/

const int referenceVolts = 5; // the default reference on a 5-volt board
//const float referenceVolts = 3.3; // use this for a 3.3-volt board

const int R1 = 20000; // value for a maximum voltage of 20 volts
const int R2 = 10000;
const int resistorFactor = 255 / (R2/(R1 + R2)); 
const int batteryPin = 0; // +V from battery is connected to analog pin 0

void setup()
{
Serial.begin(9600);
}

void loop()
{
int val = analogRead(batteryPin); // read the value from the sensor
float volts = (val / resistorFactor) * referenceVolts ; // calculate the ratio
Serial.println(volts); // print the value in volts
}

Or is there an easier way?
Thanks for your input guys
Steve

Not sure what you are trying to do but assuming it is measure the input to the divider in volts I would say it looks wrong. Each step on the A/D is Vref / 1024
So convert to volts then multiply by the factor of your divider ratio

Mike

I was referring directly to the following link except they use different resistor values.

Just because some on misunderstood what was in a book doesn't make it right.

That example is rubbish. It turns out that the so called resistance factor is 1020 which is close to the 1024 you need to use. This is just a shear fluke.
Then that code only gives you the voltage on the analogue input pin not on the input of the voltage divider.