 # Voltage divider to measure 14.4v from Alternator

Hi all.
I am using a voltade divider with 30k and 10k resistors and connected to an analog pin on my Photon.
For some reason the maximum reading I get(through Blynk) is 13.2volts
Readings are correct from 0-13.2v but if I go above(max 17v) reading stops at 13.2v
Any ideas?
This is the code.
//connected to A3
vout1 = (value1 * 3.3) / 4095;
vin1 = vout1 * (R1 + R2) / R2;

Are all your variables floating point?

A first step to solve such a riddle would be to print out the raw `analogRead()` values float vout1 = 0.0;
float vin1 = 0.0;
float R1 = 30000.0;
float R2 = 10000.0;
int value1 = 0;

Will have to test the raw value tomorrow. Don’t want to start up the engine in the middle of the night!

If we assume the raw analogRead value is 4095, then if we do the math, vin1 = 13.2

With your 30k + 10k resistors the max readable voltage on an analog pin is 13.2V
If you blow up the voltage above that you will exceed the save voltage for `analogRead()` pins

The voltage drop across R1 will be 9.9V leaveing 3.3V on the pin to be dropped across R2.

Yes, I just realized this!
What should I do? Change the value of resistors? Is there a safer way?

As a first step change your 30k for a 40k will put the max readable voltag at 16.4V
There are multiple safer ways.
You could add a Zener diode or use a metering amplifier or …
There are some threads on this board that do deal with such questions and the net is full of stuff too.

Thank you!

Here is a sensor to easily and accurately way to measure voltage up to 26v DC.

1 Like