Used the esp32 esp_adc_cal_raw_to_voltage() function to get a more accurate battery voltage reading. Note, we call Arduino analogRead() to let that code setup the ADC for us. We need to do the adc1_get_raw() call because it looks like the Arduino code is messing with the raw value before returning it in analogRead().
Once we have the actual voltage on the pin, we use the resistor divider ratio to get the voltage at the battery, which then gets converted from mv to volts.
Used the esp32 esp_adc_cal_raw_to_voltage() function to get a more accurate battery voltage reading. Note, we call Arduino analogRead() to let that code setup the ADC for us. We need to do the adc1_get_raw() call because it looks like the Arduino code is messing with the raw value before returning it in analogRead().
Once we have the actual voltage on the pin, we use the resistor divider ratio to get the voltage at the battery, which then gets converted from mv to volts.
I also did some tab/space cleanup.