showBatteryVoltage(): receives that voltage and print that on the screen.

Set the channel up to the proper values as we designed.

Before setting it up, its important to know the GPIO battery voltage is divided by 2 due to the input limitation of the integrated ADC.
So, if the original value coming from the battery is 3.7V, then the input value to the GPIO pin will be about 1.85V.
Thus, we have to multiply the value by 2 to know the actual voltage.
We use 12 bit SAR ADC for the channel with 11 dB attenuation. We should use these rates to calculate the result as well.

Now, let's get it started again.
First of all, define that extra value as a Preprocessor macro and include necessary libraries to use ADC on ESP32.

To get an accurate ADC voltage, calibration is needed. The ADC reference voltage is originally 1.1V by default but actually differs slightly on every ESP32 module. The manufacturer writes the calibration data in efuse.

esp_adc_cal_characterize(): returns a characteristic of its AP as a structure.

The readBatteryVoltage() function reads an ADC value with the adc1_get_raw() function. It returns a calculated voltage as a double type value using the esp_adc_cal_raw_to_voltage() function.