Smart Home Automation Using Blynk & ESP32 IoT Projects | WiFi & Manual
By techstudycell
Introduction
This IoT project demonstrates how to create an IoT-based Smart Home Automation system using Blynk and ESP32. It allows control of an 8-channel relay module via manual switches and the Blynk smartphone app. If internet connectivity is unavailable, home appliances can still be controlled using manual switches. The project details all necessary steps for building this home automation system.
Key Features
- Control home appliances with WiFi via the Blynk App.
- Control home appliances using manual switches.
- Monitor real-time feedback of relay status in the Blynk App.
- Manually control home appliances even without an internet connection.
The project requires an 8-channel relay module and an ESP32 board.
Required Components
- 5V Relays (SPDT) (8 units)
- BC547 Transistors (8 units)
- PC817 Optocouplers (8 units)
- 510-ohm 0.25-watt Resistors (8 units, R1 - R8)
- 1k 0.25-watt Resistors (10 units, R9 - R18)
- 5-mm LEDs (10 units)
- 1N4007 Diodes (8 units, D1 - D8)
- Push Buttons (8 units)
- Terminal Connectors
- 5V DC Power Supply
Project Steps
Step 1: Circuit Diagram
The circuit diagram outlines the complete setup for this home automation project. The ESP32's GPIO pins D23, D22, D21, D19, D18, D5, D25, and D26 are used to control the 8 relays. Manual control is achieved via push buttons connected to GPIO pins D13, D12, D14, D27, D33, D32, D15, and D4. The INPUT_PULLUP
function in the Arduino IDE is utilized, negating the need for external pull-up resistors. A 5V mobile charger is used to power the smart relay module.
A tutorial video explaining the circuit is available at: YouTube Tutorial Video.
Step 2: Control Relays With Internet Using Blynk
When the ESP32 module is connected to WiFi, home appliances can be controlled remotely via the Blynk App and the pushbuttons. The Blynk App allows for control and real-time monitoring of the relay statuses from anywhere globally.
Step 3: Control Relays Without Internet Using Push-buttons
In the absence of WiFi, relays can be operated using the connected pushbuttons. The ESP32 periodically checks for WiFi availability (every 3 seconds) and automatically reconnects when the network becomes accessible.
Step 4: Configure the Blynk App for ESP32
Install the Blynk App from your device's app store. Create an account and start a new project. Name the project, select "ESP32 Dev Board" as the board, and "WiFi" as the connection type. Tap "Create". Blynk will send an authentication token to your registered email address.
Step 5: Add Button Widgets in Blynk App
Add eight button widgets to the Blynk app interface to control the eight relays. Assign virtual pins V1 through V8 to these buttons, setting their mode to "Switch". Detailed instructions are provided in the tutorial video.
Step 6: Code for Blynk ESP32 Home Automation
The tutorial video guides through programming the ESP32 DEV KIT V1 using the Arduino IDE. Before uploading, ensure the ESP32 board support package and the Blynk library are installed. Input your WiFi network name, password, and the Blynk Authentication Token into the code. Select the "DOIT ESP32 DEVKIT V1" board and the correct COM port, then upload the code to the ESP32 board.
The source code is available at: Source Code (.ino file).
Step 7: Program the ESP32 With Arduino IDE
If the Arduino IDE displays "Connecting....___" during code upload, press and hold the BOOT button on the ESP32 board until the connection is established.
Step 8: Designing the PCB
To achieve a compact and professional appearance, a Printed Circuit Board (PCB) was designed after testing all functionalities on a breadboard. The PCB Gerber files for this home automation project can be downloaded from the provided link.
Gerber file download link: Download PCB Gerber Files.
Step 9: Order the PCB
After downloading the Gerber files, PCBs can be ordered from manufacturers like JLCPCB. Visit the website, sign in or sign up, and click "QUOTE NOW".
Step 10: Uploading the Gerber File and Set the Parameters
Upload your downloaded Gerber file by clicking "Add your Gerber file". Configure the necessary parameters such as the quantity of PCBs and the PCB masking color. After selecting all options, click "SAVE TO CART".
Step 11: Select Shipping Address and Payment Mode
Enter your shipping address and choose a suitable shipping method. Submit the order and proceed to payment. Order tracking is available on the manufacturer's website. The PCBs were manufactured within two days and arrived within a week via DHL, noted for good quality and affordability.
Step 12: Solder All the Components on PCB
Solder all electronic components onto the PCB according to the circuit diagram. Subsequently, connect the ESP32 development board to the PCB.
Step 13: Testing the ESP32 Home Automation Circuit
Once the code is uploaded and the ESP32 connects to WiFi, the blue LED will illuminate. The relay module can then be controlled using both the Blynk app and the physical pushbuttons.
Step 14: Connect the Home Appliances
Connect the eight home appliances to the relay module as indicated in the circuit diagram. It is crucial to exercise proper safety precautions when working with high-voltage connections.
Step 15: Turn ON the Supply
Connect the 5V DC power supply (e.g., from an old mobile charger) to the PCB. Then, turn on the main 110V/230V AC supply and the 5V DC supply.
Step 16: Finally!!
Your home appliances can now be controlled in a smart, automated manner. This project provides a comprehensive solution for smart home integration. Feedback and queries are welcome in the comment section. Happy Learning!