LCD with ESP32 on Arduino IDE

For this Embedded System assignment, my team and I purchased an LCD with I2C communication and installed a library. We wanted to display a static test on the LCD.

We followed this tutorial. Sadly, connecting the LCD to ESP32 needed four female to female jumper wires while we only had three. So, instead of directly connecting the two device, we connected the I2C to the arduino breadboard and wired it to the ESP32 using male to female jumper wire. We connected the ESP32 to our laptop using USB cable.

We could see the LED on ESP32 and the LCD lit up. We thought the circuit had connected to the laptop just fine. We compiled and uploaded the code in the IDE to search for I2C address. We failed for the first time because apparently we had used the schematic diagram of the wiring for ESP8266. Our circuit was not detected by the IDE.

Wrong circuit arrangement
Correct circuit arrangement

After following the right diagram for ESP32, we found the address which was 0x27, same as the address listed on the tutorial.

Next, we compiled and uploaded the code for displaying a static test. We observed there was nothing on the LCD even though there was no problem with the code. Using a screwdriver, we adjusted the potentiometer on the I2C. The backlight was fixed so that our static test could be displayed clearly.

For this assignment, we got many experiences because the challenges we faced. Thankfully, we were able to overcome all of them.

BUILDING A TOUCH AND MAGNET SENSOR USING ESP32

ESP32 is a multipurpose system on a chip. My team built a touch sensor and a magnet sensor for our Embedded System class weekly assignment.

To program our ESP32, we used Arduino IDE. So first thing first, we have to install ESP32 add-ons successfully.

How to Make A Touch Sensor

The board pinout of ESP32 has ten different touch sensors. They are the pink buttons in the following diagrams. Each of them corresponds to one GPIO. Those GPIOs can detect variations in anything that has an electrical charge, including human skin.

esp32-doit-devkit-v1-board-pinout-30-gpios-copy690525199186635703.png

We used the code provided by this source.

We connected a jumper wire to GPIO 4. Then, we connected the ESP32 to our laptop using a USB cable. Next, we uploaded the code after making sure we have selected the right board and COM port.

In the Arduino window, we opened Serial Plotter. When we touched the metal part of the jumper wire, the values displayed in Serial Plotter changed. We noticed that when the wire wasn’t touched, the values displayed would be around 70, and around 10 when it was touched.

We integrated an LED light to our circuit. This is the code we used.

We determined the threshold to be 20 since we already knew the range of values from the previous tries.

With this new circuit, our LED would light up every time the wire was touched.

 
How to Make A Magnet Sensor

Turns out ESP32 already has a built-in hall effect sensor. It can detect a change in the magnetic field surrounding it.

Here is the code for our magnet sensor.

We connected the ESP32 to our laptop using a USB cable. Then, we uploaded the code after making sure we have selected the right board and COM port.

Through the Serial Monitor we opened in the Arduino window, we figured out that when the magnet was far away from the sensor, the values displayed was around 20. When the magnet was attached to the sensor, the values changed to around 50. We have known from the reference that attaching different magnetic poles to the sensor would result in a negative value. Sadly, our magnet was one-sided. Next time, we are going to try using another magnet with both poles exposed.

We decided to code for the integration of LED light to our circuit. We determined a certain value for the threshold. Here is our code.

15807184517102283517546026224323.jpg

After creating a proper circuit and uploading the code, we could observe the LED lit up when our magnet was close to the sensor.

That was how we made a very simple touch and magnet sensor using ESP32. There are tons of tutorials on the internet that has helped us tremendously. We are looking forward to creating more projects using ESP32 and explore the world of Embedded System.