kingforger
Active member
I'm just trying to get a simple reading from an ADC pin. However, the value seems to both be wrong and moving around much more than it should be.
ON TOP:
const int batteryPin = 16;
IN SETUP:
pinMode(batteryPin, INPUT);
analogReference(DEFAULT);
analogReadResolution(10);
IN LOOP:
display.print(analogRead(batteryPin));
I have 2.92 volts on the ADC pin. So I should get a reading of 2.92V/3.3V*1024 = 906. Instead, I'm getting in readings that vary between 580 and 700 constantly. Why is this happening?
I double checked with an oscilloscope and the voltage is very stable. There are no fluctuations on it to speak of. Bypass capacitor is already there.
Schematically, I have two lithium ion batteries. They have a max voltage of about 4.2V. I have a divider coming off of them - series 500kohm and 1,500kohm. The connection is 4.2V to 500kohm to 1500kohm to ground. The ADC pin is hooked up between the two resistors.
I have no idea what the problem is. This should be so simple. I'm just trying to read battery voltage so that I can estimate how much charge it has left. Help?
ON TOP:
const int batteryPin = 16;
IN SETUP:
pinMode(batteryPin, INPUT);
analogReference(DEFAULT);
analogReadResolution(10);
IN LOOP:
display.print(analogRead(batteryPin));
I have 2.92 volts on the ADC pin. So I should get a reading of 2.92V/3.3V*1024 = 906. Instead, I'm getting in readings that vary between 580 and 700 constantly. Why is this happening?
I double checked with an oscilloscope and the voltage is very stable. There are no fluctuations on it to speak of. Bypass capacitor is already there.
Schematically, I have two lithium ion batteries. They have a max voltage of about 4.2V. I have a divider coming off of them - series 500kohm and 1,500kohm. The connection is 4.2V to 500kohm to 1500kohm to ground. The ADC pin is hooked up between the two resistors.
I have no idea what the problem is. This should be so simple. I'm just trying to read battery voltage so that I can estimate how much charge it has left. Help?