This example is a simple ADC sample. For more information please see ADC <../../firmwareapi/pycom/machine/adc.md>__.

from machine import ADC


Calibration¶

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

# Output Vref of P22

Now that the voltage reference is externally accessible 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