Skip to content

Analog Input (ADC) (esp32_adc)

What it does: Reads an analog value from the selected ESP32 ADC pin.

esp32_adc

Inputs

  • pin: ADC pin number.
  • Field Attenuation: input voltage range.
  • Field Width:: ADC conversion width (resolution).

Output

  • numerical value of ADC (Number).

When to use it

  • read potentiometer, analog sensor or voltage divider.
  • Conversion of analog value to physical units in the next block.

Tips and pitfalls

  • Actual ADC ranges vary by attenuation and specific board.
  • Average multiple samples for more stable measurements.

Generated Python example

from machine import ADC, Pin
adc32 = ADC(Pin(32))
adc32.atten(ADC.ATTN_11DB)
adc32.width(ADC.WIDTH_12BIT)
value = adc32.read()