LAB 2 - EXPLORING THE ESP32 GPIOs

 


UNIVERSITI MALAYSIA PERLIS

 

 

 

 

 

NDJ 30003 – ELECTRONIC INSTRUMENTATION

 

 

 

LAB 2 

 

EXPLORING THE ESP32 GPIOs

 

 

Prepared by:

Ts. Ahmad Syahir Bin Ahmad Bakhit

 

 


               Name                :  IRFAN BIN RAMZAN

               Matrix No.        : 192020084

               Program           : COMPUTER ENGINEERING

             Date                 : 29/9/2021



Unit 1 - ESP32 Digital Inputs and Outputs
In this section, I had observed how the digital outputs can be controlled with the digital inputs. In this particular experiment, I use a button switch (digital input) to control the LED (digital output). Supposedly, when the button switch is pressed (HIGH) the LED will lights up (HIGH) and if button switch is not pressed (LOW) the LED will not lights up (LOW).


As the switch button is pressed (HIGH), the LED will lights up (HIGH).

 
As the switch button is not pressed (LOW), the LED will not lights up (LOW).

Conclusion
In conclusion, the digital input can freely control the digital output(s) as long as the pins are correctly connected and addressed. 

Unit 2 - ESP32 Touch Sensor
In this section I'm going to observe how the ESP32 touch sensor works.

Introducing the ESP32 Touch Sensor
The ESP32 has 10 capacitive touch GPIOs. These GPIOs can sense variations in anything that holds an electrical charge, like the human skin. So they can detect variations induced when touching the GPIOs with a finger.

These pins can be easily integrated into capacitive pads, and replace mechanical buttons. Take a look at your board pinout to locate the 10 different touch sensors – the touch sensitive pins are highlighted in pink color. 



Testing
Before I start, I have to run a quick short test to see if the touch sensor on ESP32 works properly. For that, a string of male to female jumper are being connected to the GPIO4 pin which is also the TOUCH0 pin. By grabbing the male end of the jumper with my fingers, the sensor will responses and these responses can be observed through the Serial Monitor feature on Arduino IDE.


By grabbing the male end of the jumper with my fingers, the sensor will responses.


From the Serial Monitor on Arduino IDE, I can observe the responses reading that has been picked up by the touch sensor. The higher numbers are produced when the sensor are touched, while the lower number are produced when the sensor is not touched.


To see the more accurate reading, Serial Plotter feature on Arduino IDE can be viewed. The reading are represented in graphical form which can make it easier for the data to be analyzed.


Touch Sensitive LED
Now that I have known the touch sensor is working properly, I can now begin to conduct a simple experiment to control the LED with the touch sensor. The normal reading that are shown when untouched are above 70 and when touched, the reading can drop drastically below 10. Supposedly, if the reading drop below the threshold (in which in this case is programmed to be 20), the LED will lights up and will continue to lights up as long as the reading are below the threshold.


When the sensor is touched, and the reading is below the threshold, the LED will light up (HIGH).


When the sensor is untouched, the reading will rise to its normal reading (above 70) and the LED will not lights up (LOW).

Conclusion
In conclusion, the ESP32 features 10 capacitive touch GPIOs, but only 9 are available with the ESP32 DEVKIT V1 DOIT board (with 30 pins). This sensor can be used as an input to control the digital output(s) in which particularly in this experiment the touch sensor controlled the state of the LED.


Unit 3 - ESP32 Pulse-Width Modulation (PWM)
In this section I had experimented on how to dim an LED using the LED PWM controller of the ESP32 with the Arduino IDE.

Testing
Firstly, I started by using a single LED to see how it works.



In the first picture, we can see the LED lights up with normal brightness. And later in the second picture, we can see how the LED light grows dimmer over time until the light is gone. Then, the LED will lights up again with the normal brightness and then grows dimmer again. The cycle will continue as long as there is current coursing through the circuit.

Getting the Same Signal on Different GPIOs 
You can get the same signal from the same channel in different GPIOs. For that, I will dim 3 LEDs of the the different colors using the same PWM signal from the same channel.



From the first and the second picture, we can see how the all the 3 LED simultaneously light up and grow dimmer until the light is gone. By sharing the PMW signal from the same channel, the effect are perfectly synchronized without any delayed.

Conclusion
In conclusion, a digital output component such as LED can also fetch analog output by the implementation of built-in PMW channel on the ESP32. 

Unit 4 - ESP32 Reading Analog Inputs
In this section I had experimented on reading an analog input with the ESP32. Particularly in this experiment, I had used a potentiometer to control the resistor values and observed it through the Serial Monitor.



By rotating the potentiometer, I had varied the resistor values. Resultantly, the reading shown on the Serial Monitor varied from the lowest number (0) to the highest number achievable (4095). The range of 0 to 4095 are decided by the 12 bits of resolution of the analog input pins of the ESP32.

Conclusion
In conclusion, the ESP32 DEVKIT V1 DOIT board (version with 30 pins) has 15 ADC pins you can use to read analog inputs. These pins have a resolution of 12 bits, which means you can get values from 0 to 4095. 

Unit 5 - ESP32 Hall Effect Sensor
In this section I had experimented on built-in the Hall effect sensor on the ESP32. These built-in Hall effect sensor which is located as shown in the figure below (behind that metal cap):


A Hall effect sensor can detect variations in the magnetic field in its surroundings. The greater the magnetic field, the greater the output voltage. 

Testing
To see how the hall sensor works, I had used a piece of circular magnet which will be placed on the metal cap so that the Hall effect sensor can detect the magnetic field produced by the magnet. 



When the piece of magnet is placed on the Hall effect sensor, the reading shown on the Serial Monitor started to decrease.



When the other side of the magnet is placed on the Hall effect sensor, the reading shown on the Serial Monitor started to increase. This shows that the different poles of the magnet would fetch different results.


Conclusion
In conclusion, the built-Hall effect sensor on the ESP32 measure the magnetic field and the readings will differ depending on the poles of the magnet.

Overall Conclusion
Throughout this laboratory session, the ESP32 board has digital I/O pins, touch sensor, PMW channel, analog output pins and Hall effect sensor. All these feature can be easily use once calibrated correctly. Similarly with Arduino board, the ESP32 board can also be programmed using C language on Arduino IDE software. All in all, the ESP32 is a very useful and well-rounded microcontroller that had most of the features that Arduino board have. So if Arduino isn't available to you, an ESP32 can do the job.



Comments

Popular posts from this blog

LAB 1 - D’ARSONVAL GALVANOMETER