PROJECT #3 - Trying Out Internal Sensor Of ESP32 Dev Board Using The Arduino IDE

Hello there! In this project, I'm going to try using the internal sensor of an ESP32 Dev Board. FYI, the ESP32 Dev Board has three internal sensors: 

  • Touch sensor
  • Hall Effect sensor
  • Temperature sensor*
*not all ESP32 Dev Board have this sensor.

This project is split into three parts for each respective sensor. So without further ado, let's get to the experiment!


PART 1: TOUCH SENSOR

STEP 1: Prepare The Required Software and Hardware

For hardware, you'll need these components:

  • ESP32 Development Board
  • Breadboard
  • Jumper Wire Male-to-Male
  • LED
  • 330 Ohm Resistor

For software, you'll need to set up the Arduino IDE. If you haven't set it up yet, you can click here to see the installation process from my first project in the first step from the first part.


STEP 2: Testing The Touch Sensor

For testing the touch sensor, I'm using the TouchRead sketch file. You can access this file from File -> Example -> ESP32 -> Touch -> TouchRead.

TouchRead Sketch File Location

TouchRead Sketch Code

To set up the hardware, connect a jumper wire to GPIO 4 pin. 

Hardware Setup

After you uploaded the sketch to the ESP32 Dev Board, observe the Serial Monitor while your finger touches the other side of the jumper wire (Note: check lower right if the value is not a number). The value in the Serial Monitor should be high when you don't touch the jumper wire and low when you touch it if the setup is correct. You can use the Serial Plotter instead of the Serial Monitor to see the value.


Touch Sensor Result (Monitor)

Touch Sensor Result (Plot)


STEP 3: Trying to Light a LED Using Touch Sensor

The program code I'm using is from randomnerdtutorials website. You can copy the code from this link or look at the image below.

Touch to Light 1 LED Sketch Code

To set up the circuit, connect:

  • a GPIO 16 (RX2 in the ESP32) to the longer side of the LED
  • the shorter side of the LED to a 330 ohm resistor
  • the other side of the resistor to the ground (GND) of the ESP32
  • a jumper wire to GPIO 4 pin to use the touch sensor.

The setup should be like this (refer to the image below) :

Hardware Setup

After you uploaded the code to the ESP32, observe the LED while your finger touches the tip of the jumper wire. If the setup is correct, the LED should be turned on when you touch the tip of the jumper wire and off when you release the touch. For an easier makeshift button (touch sensor), you can use aluminum foil so that you don't have to touch the tip of the jumper wire directly. But I didn't prepare the aluminum foil so I'm touching the tip directly.



STEP 4: More Complicated Circuit (Optional)

The sketch code is based on the second part of my second project. If you want to see it, you can click hereThe concept of the program is to turn on a specific LED with a combination of 2 push buttons. But, in this project, I'm going to change the push button to the touch sensor.

2 Touch Sensor to Light 3 LED Sketch Code (p1)

2 Touch Sensors to Light 3 LEDs Sketch Code (p2)

Based on the third step, connect 3 LEDs and 2 jumper wires (for the touch sensor) to a GPIO pin. Beware that the touch sensor only exists in GPIO 2, 4, 12 - 15, 27, and 32 - 33. In my case, I've set up left and right jumper wires, and the 3 LEDs are (in order from left to right) red, yellow, and green. For the program, I'm going to make this logic :

  • If both wires are touched, the yellow LED will turn on.
  • If only the left wire is touched, the red LED will turn on.
  • If only the right wire is touched, the green LED will turn on.
Hardware Setup

When the preparation is complete, upload the code and observe the circuit you just made. If the setup is correct, the corresponding LEDs should be lighting on when you touch the corresponding jumper wire's tip (or aluminum foil for an easier makeshift button).



PART 2: HALL EFFECT SENSOR

STEP 1: Prepare The Required Software and Hardware

For hardware, you'll need an ESP32 Development Board and a magnet.

For software, we'll use the Arduino IDE. See the first step of the first part for the installation process.


STEP 2: Testing The Hall Effect Sensor

For testing the touch sensor, I'm using the HallSensor sketch file. You can access this file from File -> Example -> ESP32 -> HallSensor. 

Hall Sensor Sketch File Location

Hall Sensor Sketch Code

After you uploaded the sketch to the ESP32 Dev Board, observe the Serial Monitor while approximating a magnet to the hall effect sensor (Note: check lower right if the value is not a number). FYI, the hall effect sensor is located behind the metal lid of the ESP32 chip (Refer to the image below). When you approximate the magnet to the sensor, the value on the Serial Monitor should be increasing/decreasing depending on the magnet's polarity.

Hall Effect Sensor Location

How to Test The Hall Effect Sensor

Test Result

In my case, the value in the Serial Monitor is kind of random so I think either my hall effect sensor is broken or the setup (or the magnet) is not correct.



PART 3: TEMPERATURE SENSOR

STEP 1: Prepare The Required Software and Hardware

For hardware, you'll only need an ESP32 Dev Board.

For software, we'll use the Arduino IDE. See the first step of the first part for the installation process.


STEP 2: Testing The Temperature Sensor

This temperature sensor is not usable to check the external surrounding temperature but only for checking the core's internal temperature. In addition to that, not all ESP32 Dev Board have this sensor. So, I'm going to check whether my ESP32 has the temperature sensor or not.

The program code I'm using is from circuits4you website. You can copy the code from this link or look at the image below.

Temperature Sketch Code

After you uploaded the sketch to the Dev Board, observe the Serial Monitor. You can see the temperature of the internal core there. If the temperature shown on the Serial Monitor is always 53.33 C (128 F), it means that the ESP32 Dev Board doesn't have the temperature sensor (But I don't know whether this is true or not).

Hardware Setup

Test Result

As for my ESP32, it doesn't have the internal temperature sensor as we can see from the result above.


That's all for this project! Thank you for reading this and happy experimenting!



- Ryu / 18220025

Comments

Popular posts from this blog

PROJECT #5 - Trying Out OLED Display and Pulse-Width Modulation On ESP32 Dev Board Using The Arduino IDE

Getting Started with ESP32 Development Board - Programming "LED Blink" using Arduino IDE