ESP32 Reading Analog Inputs



MOHAMMAD SAIFIQUL AIMAN B MOHAMMAD ALI

192011145

R2427-MICROELECTRONIC ENGINEERING

When using the ESP32 to read an analogue value, you can measure voltage levels ranging from 0 to 3.3V. The voltage measured is then allocated to a value between 0 and 4095, with 0V equaling 0 and 3.3V equaling 4095. Any voltage between 0 and 3.3V will be assigned the value in the middle.

Here’s a list of parts you need to assemble the circuit

 ESP32 DOIT DEVKIT V1 Board

Potentiometer 

Breadboard 

Jumper wires


touchRead() 

Reading the touch sensor is straightforward. In the Arduino IDE, you use the touchRead() function, that accepts as argument, the GPIO you want to read. 



Assemble the circuit shown below







Copy the source code below

Source code :

// 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);

}



Uploading the Sketch :

Before clicking the upload button, go to Tools  Board, and select the board you’re using. In my case. It’s the DOIT ESP32 DEVKIT V1 board. Also don’t forget to select your ESP32’s COM port.



Now, press the upload button.

Then, wait for the “Done uploading.” message: 


Testing your project :








The value shown in serial monitor change according to analogue rotation , 

Comments

Popular posts from this blog

ESP32 Hall Effect Sensor

MINI PROJECT - AUTOMATIC WATERING PLANT USING BLYNK

ESP32 TOUCH SENSOR