Full width home advertisement

Post Page Advertisement [Top]

NDJ 30003 - ELECTRONIC INSTRUMENTATION


Creating a Smart LED System using ESP32 & Blynk


Name: ONG JUN JIE

Matrics No.: 192020315

Program: Computer Engineering

Date: 28/11/2021


Introduction

When compared to manually controlled loads, a load controlled by computer systems has numerous advantages. In artificial intelligence projects, there are many programmes and applications that help to control things better using codes or python algorithms. This study proposes a Smart LED System project based on IoT technology to save energy and make load monitoring easier. This Smart LED System is an Internet of Things (IoT) project that uses a Wireless Fidelity WIFI connection to monitoring over the internet. A smart phone connected to the internet with the Blynk application acting as a control panel, and a ESP32 microcontroller kit acting as a controller receiving control commands via WIFI signal on the other side. The ESP32 Board, which can process and analyse Wi-Fi signals before sending them to the microcontroller. The WIFI receiver and microcontroller are integrated into a single kit for IoT projects. It's known as ESP32 Board.

    To connect the system to the Internet, needs a Wi-Fi receiver. In this case, I used ESP32 that is connected as built-in in the DOIT board that contains a firmware runs with the ESP32. The firmware is a low-level control computer software.

    To tell the ESP32 what to do, I want to use the Arduino Integrated Development Environment (IDE) with the Universal Serial Bus port (USB). I want to make the ESP32 control LED using the Sound Sensor and monitoring using Blynk hand phone application and display the light intensity measured by the LDR sensor.


Equipments/Components

1) ESP32 Board. Integrated Wi-Fi and Bluetooth connectivity for a wide-range of applications.

Figure 1 ESP32 Board


2) Functional Computer device. Run Arduino IDE and program the application.

Figure 2 Functional Laptop


3) Microphone Sound Sensor. Detects sound and gives a measurement how loud is the sound.

Figure 3 Microphone Sound Sensor (KY-037)


4) Light Dependent Resistors, LDR. Detect light and change the operation of a circuit dependent upon the light levels.

Figure 4 Light Dependent Resistors


5) LED. A semiconductor light source that emits light when current flows through it.

Figure 5 LED


6) Jumper Wires. Have connector pins at each end, allowing them to be used to connect two points to each other.

Figure 6 Jumper Wires


7) USB cable. Used to connect computers to peripheral devices.

Figure 7 USB Cable


ESP32 Code via Arduino IDE

To use the Arduino IDE to programme the ESP32, you must first add the ESP32 board to the Arduino IDE library by adding this address to the Arduino IDE preferences. After adding this reference to the Arduino IDE, go to boards manager and select DOIT ESP32 DEVKIT V1. Upload this code after adding ESP32 board to the Arduino IDE library and changing the hotspot name and password, as well as the token code. Figure 8 shows the situation.

Code: https://dl.espressif.com/dl/package_esp32_index.json
           https://arduino.esp8266.com/stable/package_esp8266com_index.json

Figure 8 Setting up ESP32 Board in Arduino IDE


The Hardware of the System
ESP32 can decide which pins are UART, I2C, or SPI. Just need to set that on the code. This is possible due to the ESP32 chip's multiplexing feature that allows to assign multiple functions to the same pin. If doesn't set them on the code, the pins will be used as default.
ESP32 DEVKIT V1 - DOIT
version with 30 GPIOs
Figure 9 ESP32 GPIOs

Blynk Application
Blynk is an IoT platform for iOS or Android smartphones that is used to control Arduino. This application is used to create a graphical interface by compiling and providing the appropriate address on the available widgets.
Figure 10 Blynk Sample Application


-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

How is it works?

This project is used to control the LED light when the sound sensor detect a loud clap sound made by the user. The Microphone Sound Sensor KY-037 plays a important role in this project. When sound sensor detect a loud clap sound, the digital read gives HIGH or '1' output to the program. Followed by the LED will on if the initial value is off. In the other hand, if a loud clap sound detected again by the sound sensor, the LED will turn off again.

The virtual LCD in Blynk Application will change the words to inform the user the current light intensity depends on the the light-dependent resistor (LDR) value. If the value is lower than 25, LCD will inform user that low brightness will harm his eyesight. If the LDR value is higher than 25, LCD will display some words that motivate user. In addition, a button in the Blynk app able to switch on or off the system. If the user switch on the button, then the system unable to use until the user switch off the button. 

The Blynk application consists of LUX Monitoring chart, button for switch on or off the system, virtual LED that synchronous the LED in breadboard. Therefore, user able to monitor the LED condition from time to time. Lastly, two virtual LCD is used to shows the condition of light intensity. 


Circuit Connection

In Figure 11 shows the design of how the circuit should be construct. Basically a Microphone Sound Sensor KY-037 is used to detect the clap sound make by the user. After that detect a loud clap sound, the LED light will automatically switch on. If another clap sound make by the user, the LED light will automatically switch off. The light-dependent resistor(LDR) are used to detect light levels. Whenever the light intensity surrounding is low, a virtual LCD board will display turn on the light on Blynk application while the light intensity is normal, the virtual LCD board will display good brightness on the LCD board. Therefore, it's useful to protect the user eyes health and maintaining good eyesight by notify the user current light intensity. From the design, two pins of KY-037 is connected to VCC and ground in the breadboard. Next, another two pins is connected to D2 and D4 pin in ESP32 board. Follow on, the LED is connected to ground and D5 pin with a 220ohm resistor. Lastly, a LDR is connected to ground and D34 pin with a 10Kohm resistor. The circuit is built as shown in Figure 12.


Design:

Figure 11 Circuit Connection Drawing

Build:
Figure 12(a) Circuit Connection


Figure 12(b) Circuit Connection


Coding via Arduino IDE
In the coding below show the code used to connect the Blynk application with ESP32. Firstly, it is important to declare the WiFi ID, password and gain internet to interact with Blynk Application. Next, authorized Token from the Blynk Application. Follow on, some formula is needed to get the LDR value. The formula is show below:
LDR_Vout = (analogRead(LDR_Pin) * Vin/(4095))
RLDR = (R*LDR_Vout) / (Vin - LDR_Vout)
lux = 170 / (RLDR/1000)
After that, 2 LCD Widget is used to display the light intensity condition and warning the user. If the light intensity is low, then the LCD will display "Light intensity is low", "Dark may harm your eyes!". If the light intensity is normal, then the LCD will display "Light intensity is good!", "Good luck with your work!".




Blynk Application Interface:


Figure 13 Project Blynk Application Interface


Results
1. Initial condition for the system. The LED is off and button to switch off the system is off too. It show the LUX value is below 25 therefore, in the virtual LCD in Blynk Apps show the light intensity is low and give warning to user that low brightness will harm his eyesight. 
Figure 14 show the circuit and Blynk app when LED is off

2. If a loud clap sound made by the user then the sound sensor detect it and LED will switch on shown in Figure 15. Meanwhile, the virtual LED in Blynk app switch on too and show red colour. Next, the LUX monitoring graph is above 25 therefore the light intensity is good and show some motivate words to the user. 
Figure 15 show the circuit and Blynk app when LED is on

3. If the switch off system button is on then the sound sensor will not detect any sound and doesn't give instructions to the LED. In the Blynk app show the LUX monitoring graph has stop moving and the system is off show in virtual LCD. The system will continue to work when the button is off.
Figure 16 show the circuit and Blynk app when the system is off



Demonstration Video


Discussion
    There are several problems when building this project. This first problem is the sensitivity threshold of microphone sound sensor KY-037. I didn't know that the threshold sensitivity need be adjust until it detects and doesn't perfect the sound at a perfect spot. The sensitivity threshold can be adjusted via the potentiometer on the sensor. To find the perfect spot for the sensor, adjust the potentiometer until the LED on the sensor blink when noise occur. Next, it's important that don't code delay command in the Arduino program as the delay command will effect the effectiveness of sound sensor and the LED will not light up. Lastly, to switch on and off the LED has trouble a lot when coding. The LED would not switch off after the LED is on. Therefore,  a certain command need to be made to make this works. A LED variable has be declare to add 1 when the LED is switch on. Next, when the LED variable become 0 when the LED is switch off. This simple coding has to be made to make it works because it couldn't just simply giving command on and off to make the LED switch on and off. However, finally the project had done after solving all the bugs and issues.

Conclusion
    In the nutshell, this project was able to finish on time. This project uses all the knowledge that I had learnt in the previous lab and make a simple IoT application project. The ESP32 plays a main role in this project. ESP32 can perform as a complete standalone system or as a slave device to a host MCU, reducing communication stack overhead on the main application processor. Furthermore, it can interface with other systems to provide Wi-Fi and Bluetooth functionality. Therefore, it is possible to implement with Blynk Application to make a IoT project. By using this project, the user can easily switch on and off the LED by making clap sound. For sure that this project still have massive of improvements can be made but currently it's limited with time and budget. Therefore, there are several improvements can be made in the future such as insert button and virtual button to switch on and off the LED manually. Next, change the LED to big light bulb to increase the brightness in the surrounding. Lastly, through this mini project, I had learn a lot about the ESP32, Blynk apps, sensor sensitivity control and more. These knowledge will help me in the future project.


MINI PROJECT END

LET'S MAKE A LITTLE BIT PROGRESS EVERY DAY AND YOU SEE 
THE POWER OF SMALL CHANGES

No comments:

Post a Comment

Bottom Ad [Post Page]

| Designed by Colorlib