Arduino as voltimeter

Hello everyone!

I'm developing a project where I have to indicate a battery voltage level, and send that information to an LCD.

The scheme looks like this:

However i'm using a 4.3V voltage source for feeding the Arduino (USB 5V, but through a diode)

When the Arduino is measuring the voltage of a battery, with it being powered by USB , a level of approximately 4.2V is indicated on the battery

And when the Arduino is measuring the voltage of the battery, with it being powered by this same batery (boosted and stabilized at 4.3V), the LCD (always) indicates 5V.

I think it happens because the Arduino uses the feeding tension level comparing to the batery level (witch is connected to A0), so it will always indicate a 1023 (digital) signal (equals 5V) till the battery level drops below 4.3V (the feeding boosted level).

But i'm not sure...

There is something wrong with your setup. With the value shown (100k/10k) on voltage divider you should apply 47.3 V to have 4.3 V on the ADC pin. BTW, your conclusion are right, you can't measure a battery using the same value for reference, even when the battery discharge you'll always reading 1023. Try to use the internal 1.1 V reference, and use an appropriate voltage divider on input.

Ciao, Ale.

I think it happens because the Arduino uses the feeding tension level comparing to the batery level (witch is connected to A0), so it will always indicate a 1023 (digital) signal (equals 5V) till the battery level drops below 4.3V (the feeding boosted level).

Your logic is correct - You'll read 1023 when the voltage is at, or above, the ADC reference.

But you need to "re-calibrate" your calculations because if your reference is 4.3V, then 1023 = 4.3V (not 5V). Then of course, you need to figure-in your 1:11 voltage divider.

And, if the reference voltage is from the same battery you're trying to measure you can't measure it because you reference drops when the battery voltage drops.

The optional 1.1V reference will remain solid & regulated as long as Vcc is "reasonable", so if you switch to the 1.1V reference, analogReference (INTERNAL), and re-do your calculations (where 1023 = 1.1V before figuring-in your voltage divider) everything should work.

The usual ADC factor note:

voltage = analogRead(apin) * divider * aref / 1024.0;

where divider reflects the voltage divider, and aref the selected analog reference voltage.

The pin A0 measures by default "5V" / 1024 which might not be what you want, especially if your "5V" is not quite 5.
Read up on changing the range of A0 to 2.56 or 1.1 Volts (could depend on which hardware you are using)
and consider replacing the 100k with a 560k.