Thank you for you answer.
Yes, it is very simply - circuit and formula but.. it doesn't work in my case - there are some differences between voltage which I measure via MCU and voltage that I can measure by voltmeter.
I have Anarduino+RF96 - pretty the same as Moteino.
it has also Vcc == 3.3v
I power it from 4AA battery. Voltmeter shows me 6.11v on Vin pin. On Vcc pin - 3.3v
So I suppose voltmeter works ok.
then I build divider.
now with 1M+470K(1uF)
all online calculators and my calculations says me that after divider I should have 1.95v
then I need to know dividerRatio.
6.11 - 100%
1.95 - x%
x == 1.95*100 / 6.11 == 3.14
so dividerRatio == 3.14
my code:
for (byte i=0; i<10; i++){
reading += analogRead(BATT_MONITOR);
}
DEBUG("reading:"); DEBUGln(reading/10);
divVolts = (reading / 10.0)* 0.00322;
DEBUG("divVolts:"); DEBUGln(divVolts);
batteryVolts = (reading / 10.0)* 0.00322 * 3.14;
DEBUG("batteryVolts:"); DEBUGln(batteryVolts);
it shows:
reading: 599
divVolts: 1.93
batteryVolts: 6.06
Now I have difference in voltage about 0.5v
Seems I need tune some parameters in formula ? or it is allowable error for MCU ?
Also would you please explain second part of my previous question - why dividerRatio == 1.47 and why "to calculate the actual voltage of the battery I need to know what the battery rated voltage is (ie starting point)" ??