ADC

This article delves into the use of a 12-bit SAR ADC on the Edge101 motherboard with ESP32, featuring practical examples and code for effectively sampling analog input channels to measure voltage.

Example: Single-Channel ADC Sampling

The Edge101 motherboard features a 12-bit SAR ADC, supporting 6 analog input channels with a sampling speed of 2 Msps. At any given time, each ADC can only sample one channel. Note: ADC2 cannot be used when WiFi is enabled.

Hardware Required:

Example Code:

void setup()
{
  Serial.begin(115200);
  Serial.println();
}

void loop()
{
  int vtmp = analogRead(37); // GPIO37 ADC1_CH1 to read voltage

  Serial.printf("sample value: %d\n", vtmp);
  Serial.printf("voltage: %.3fV\n", vtmp * 3.26 / 4095);
  delay(500);
}

Result:

After uploading the program to the board, connect a potentiometer to pin P37 and adjust the input voltage. The serial monitor will display the measured raw digital value and the corresponding voltage.

Was this article helpful?

TOP