* Note: this is the internal system voltage measurement, not the external measurement which uses the TOUT pin.
Specifically, I am using the adc example project from the peripherals section of the SDK installation. The file is adc_example_main.c . It builds fine, then flashes, and monitors successfully.
I have setup a test circuit that uses a voltage divider using a trimpot 10k and 20k resistor. The input voltage is 3.3V. The trimpot gives me the range 3.3V to 0. I can see the device stop as the voltage is decreased (as measured by an multimeter).
Problem is, the adc function reading is always 0x01010702 (4466). Since the ADC is 10-bit, I am assuming the value is actually 0x010702 or 370 decimal. This corresponds to 0.370V. My input voltage as measured with a multimeter shows otherwise (plus the module is alive). The voltage never changes, never fluctuates. I have powered different ESP-01s from USB-UARTs, a 3.7 LiPo battery (running through an LDO to get the 3.23 V), and from raspberry pi pins (3.3V and 5V).
The example code is very simple, and uses the adc_read function defined in the adc.h header:
ESP_OK == adc_read(&adc_data)
My goal is to measure the system voltage and correlate that with a draining battery, so that I could warn the user when it is time to charge the battery.
The example provided does not seem to work.
Is there a way to access the memory register for the SAR ADC directly from code?
The datasheet for the ESP8266EX does not list the reference voltage used by the SAR ADC.