FireBeetle 2 ESP32 C6 Development Board _ADC Module Test
[Copy link]
This time, let’s test the ADC of ESP32
1. MCU uses 3.3V power supply
2. Use a potentiometer to provide a signal
3. Test the code
void setup() {
// initialize serial communication at 115200 bits per second:
Serial.begin(115200);
//set the resolution to 12 bits (0-4095)
analogReadResolution(12);
}
void loop() {
// read the analog / millivolts value for pin 2:
int analogValue = analogRead(2);
int analogVolts = analogReadMilliVolts(2);
// print out the values you read:
Serial.printf("ADC analog value = %d\n",analogValue);
Serial.printf("ADC millivolts value = %d\n",analogVolts);
delay(100); // delay in between reads for clear read from serial
}
4. Test situation
Voltage value
|
AD value
|
3.3
|
3344
|
2.38
|
2382
|
2.03
|
2033
|
1.70
|
1701
|
1.00
|
1002
|
This value is very strange. 3,3V should be 4095, why is it 3344? It seems to have been transformed. Does anyone know what's going on?
|