mirror of
https://github.com/sascha-hemi/pycom-documentation.git
synced 2026-03-21 03:04:13 +01:00
* Products
-> updated with new products
-> added accessories
* Getting started
-> re-structured getting started guide
-> removed some of the advanced stuff
* Tutorials / Examples
-> added categories
-> added new basic tutorials Sleep, GPIO and Pring
-> added WiFi ap / sta tutorial
-> added wifi Scan MAC tutorial
* Firmware API
-> added pysense pytrack pygate categories here
* Datasheets
-> added CE FCC and RoHS documents
-> added pysense2 and pytrack 2 templates
* Update firmware
-> new section, added all methods of updating the firmware
* License
-> put license in its own section
general remarks:
-> updated the layout / theme
no more red code text
codeblocks actually work now
-> general layout updates, removed the old html structures (mostly)
1.3 KiB
1.3 KiB
title, aliases
| title | aliases | |||
|---|---|---|---|---|
| ADC |
|
This example is a simple ADC sample. For more information please see ADC.
from machine import ADC
adc = ADC(0)
adc_c = adc.channel(pin='P13')
adc_c()
adc_c.value()
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
adc = ADC()
# Output Vref of P22
adc.vref_to_pin('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
adc.vref(1100)
# Check calibration by reading a known voltage
adc_c = adc.channel(pin='P16', attn=ADC.ATTN_11DB)
print(adc_c.voltage())