Analog sensors on an ESP32 look easy: read a pin, get a number. The number is only as good as the setup behind it. This reading review covers two pages of Espressif's ESP-IDF documentation, the ADC oneshot driver and the ADC calibration driver, and pulls out what matters when a raw ADC value is turned into a voltage.

1. A raw reading is not millivolts (ESP-IDF ADC calibration driver)

The calibration page explains that the ESP32 ADC compares the input voltage to a reference. By design that reference is 1100 mV, but the page says the true reference can range from 1000 mV to 1200 mV between chips. The calibration driver exists to reduce that chip-to-chip effect. On this chip the "line fitting" scheme uses parameters burned into eFuse when they are present. The page names the cases (a two-point value, a Vref value, or neither), and when neither is burned, you must supply a default Vref, which it describes as an estimate. You convert with adc_cali_raw_to_voltage(), or adc_cali_chan_raw_to_voltage() when a scheme applies channel-dependent corrections.

Lesson: two boards with the same code can report slightly different millivolts for the same input. Calibrate when absolute voltage matters, and check which calibration source your board actually has. Source: https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/peripherals/adc/adc_calibration.html

2. Configuration is part of the measurement (ESP-IDF ADC oneshot driver)

The oneshot page describes a fixed order: create the ADC unit with adc_oneshot_new_unit(), configure each channel with adc_oneshot_config_channel() (bit width and attenuation), then read with adc_oneshot_read(). The attenuation setting is part of the channel configuration, and the calibration page asks for the same attenuation and bit width when you create a calibration scheme. The two have to match the raw readings they convert.

The page also says adc_oneshot_read() uses mutexes because ADC hardware is shared with other drivers, so it must not be called from an interrupt service routine. It notes that ADC2 is also used by Wi-Fi, and that the driver provides protection between the Wi-Fi driver and oneshot mode.

Lesson: take readings from a task, not an ISR. If a design uses Wi-Fi, check the hardware limitations section before choosing which analog pin to wire. Source: https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/peripherals/adc/adc_oneshot.html

Checklist from the sources

  • Set attenuation and bit width once per channel, and reuse the same values when creating the calibration scheme.
  • Check which eFuse calibration value the chip reports before trusting millivolt output.
  • Read the ADC from a task. Never call adc_oneshot_read() from an ISR.
  • With Wi-Fi in the design, read the ADC2 notes before assigning pins.
  • If a sensor needs absolute accuracy, compare the converted value to a reference meter on your own hardware. The documentation describes the driver, not your board.

This is a documentation review, not a measurement report. It makes no claim about any specific board or sensor.