This example is a simple ADC sample. For more information please see ADC.

from machine import ADC
adc = ADC(0)
adc_c ='P13')


Currently the ESP32's ADC is not calibrated from the factory. This means it must be calibrated each time you wish to use it. To do this you must firstly measure the internal voltage reference. The following code will connect the 1.1v reference to P22

from machine import ADC
adc = ADC()

# Output Vref of P22

Now that the voltage reference is externally accessable you should measure it with the most accurate voltmeter you have access to. Note down the reading in millivolts, e.g. 1120. To disconnect the 1.1v reference from P22 please reset your module. You can now calibrate the ADC by telling it the true value of the internal reference. You should then check your calibration by connecting the ADC to a known voltage source.

# Set calibration - see note above

# Check calibration by reading a known voltage
adc_c ='P16', attn=ADC.ATTN_11DB)

results matching ""

    No results matching ""