As title topic,
I did read several tutorials, but I don't have the ideas clear.
I have an ATMEGA328P 8mhz no BOD barebone. I feed it with 2XAA battery (~ 2.74 volt when full charged).
I have also a step up to 3.3v to feed a DHT22.
Now, I want to read the battery voltage.
I know that I need to read BEFORE the Step up (direct the 2.74V).
I know that I need to use a voltage divider.
I want to use INTERNAL REF (1,1v)
But, How I can get the formula to use in sketch?
E.g. I know that to obtain 1.1v in voltage divider from an input of 2.74 I Need to use R1 = 2K and R2 =~ 1300 (I did try here: Voltage Dividers - learn.sparkfun.com ).
I did not understand If I need to pick the start voltage at full charged (in my example the 2.74v) and divide to the 1.1V, to perform the reference.
For example, I did found a sketch that say (for the 3.3v):
int sensorValue = analogRead(A0); float battery_Voltage = sensorValue * 0.003363075;
Where the magic number coming from a voltage divider made from
R1 = 1M and R2 = 470K
and formula =
((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
3.44/1023 = Volts per bit = 0.003363075
So, I mean, I need to reduce every voltage input to the 1.1 when full charged?