ESP32 ADC Tutorial | How to Use ADC of ESP 32 | How to Interface Potentiometer With ESP32
by Utsource in Circuits > Arduino
663 Views, 0 Favorites, 0 Comments
ESP32 ADC Tutorial | How to Use ADC of ESP 32 | How to Interface Potentiometer With ESP32
In this tutorial we will learn how to use ADCs of ESP32.
ADC stands for analog to digital converter which means it will take analog values of voltages and give Digital output.
For example in ARDUINO UNO for 0v it gives 0 and for 5V it gives 1023 so similar with ESP32 0v is 0 & 3.3V is 4095.
ADC stands for analog to digital converter which means it will take analog values of voltages and give Digital output.
For example in ARDUINO UNO for 0v it gives 0 and for 5V it gives 1023 so similar with ESP32 0v is 0 & 3.3V is 4095.
Things You Need
For this tutorial you need few basic things :
ESP32 :
POTENTIOMETER :
1x breadboard :. :
Few jumpers :
My ESP32 is LOLIN32 lite but you can take any ESP32 and for that you need to get proper schmatics from google to know it all pins and on which pins ADC (analog pins ) is available but you can buy any ESP32 Board and it will work for this tutorial.
ADC on ESP32
Reading any analog value with ESP32 board means you can measure the varying voltage levels between 0 V and 3.3 V and it will give output in digital for those voltage levels.
The voltage measured is then assigned to a value between 0 and 4095, in which 0 V corresponds to 0, and 3.3 V corresponds to 4095. Any voltage levels between 0 V and 3.3 V will be given a corresponding value in between 0 to 4095.
The voltage measured is then assigned to a value between 0 and 4095, in which 0 V corresponds to 0, and 3.3 V corresponds to 4095. Any voltage levels between 0 V and 3.3 V will be given a corresponding value in between 0 to 4095.
Schmatics
Connect everything According to the shown schmatics.
As we connected the Potentiometer to pin 32 (gpio34) on esp32.
As we connected the Potentiometer to pin 32 (gpio34) on esp32.
Code
The coding part is really simple you can copy the following code, it is almost the same code we used to Potentiometer values from ARDUINO UNO :
// Potentiometer is connected to GPIO 34 (Analog ADC1_CH6)
const int potPin = 34;
// variable for storing the potentiometer value
int potValue = 0;
void setup() {
Serial.begin(115200);
delay(1000);
}
void loop() {
// Reading potentiometer value
potValue = analogRead(potPin);
Serial.println(potValue);
delay(500);
}
// Potentiometer is connected to GPIO 34 (Analog ADC1_CH6)
const int potPin = 34;
// variable for storing the potentiometer value
int potValue = 0;
void setup() {
Serial.begin(115200);
delay(1000);
}
void loop() {
// Reading potentiometer value
potValue = analogRead(potPin);
Serial.println(potValue);
delay(500);
}
Testing the ADC of ESP32
So after uploading the code, i opened the serial monitor at baud rate 115200 and when i rotate the Potentiometer the values we are getting in serial monitor from 0 to 4095 as we expected so we got the ADC of ESP32 working.
So this is how you can use ADC Of ESP32 in your projects and you can use potentiometer with your projects so have fun with your projects and let me know if you have anything on this in comments.
So this is how you can use ADC Of ESP32 in your projects and you can use potentiometer with your projects so have fun with your projects and let me know if you have anything on this in comments.