I am currently building a battery operated esp32 project using 2- AAA batteries. I also have a step converter, pushing the voltage to 5volts. I have connected the 5v to the VBUS input. My AAA battery voltage reading using my DVM at the pin is 2.8v. Basically when I am trying to read the battery voltage of the AAA batteries, I see values greater then 8000 counts(The S2 has a 13 bit ADC), when I expect values closer to 7000. If I ground the pin I see the value change to under 10. So it seems to be kind of working.
I also tried the example "ESP32AnalogReadTest.ino" from the Arduino library ESP32AnalogRead. Using this example I read 2.58 v for my AAA batteries and the 3.3v output from the on board regulator.(Second example), if I ground the pin the output is "0v"
Thanks for any help.
Development board link: Lolin S2 Mini
Here is my first code example:
const int VbusInPin = 3;
int VbusInVal = 0;
void setup() {
Serial.begin(115200);
delay(2000);
pinMode(VbusInPin, INPUT);
}
// the loop function runs over and over again forever
void loop() {
VbusInVal = analogRead(VbusInPin);
Serial.println(VbusInVal);//
}
/************ Second code example *********************************/
#include "Arduino.h"
#include <ESP32AnalogRead.h>
ESP32AnalogRead adc;
void setup()
{
adc.attach(3);
Serial.begin(115200);
}
void loop()
{
delay(500);
Serial.println("Voltage = "+String(adc.readVoltage()));
}