This project implements a home automation system using an ESP8266 microcontroller, a DHT11 temperature and humidity sensor, and the Blynk IoT platform. It allows users to remotely control four LED Bulbs and monitor temperature via the Blynk app.
- ESP8266 Development Board: (e.g., NodeMCU)
- DHT11 Temperature and Humidity Sensor
- LED Bulbs (4)
- 220 Ohm Resistors (4): For current limiting with the LEDs.
- MicroPython Firmware: Flashed onto the ESP8266.
- Blynk Account and App: Set up on your smartphone.
- Wi-Fi Network: With internet access.
- USB Cable: For connecting the ESP8266 to your computer.
-
LED Connections:
- Connect the anode (longer leg) of each LED to the following ESP8266 pins:
- LED BULB 1: D0 (GPIO16)
- LED BULB 2: D1 (GPIO5)
- LED BULB 3: D2 (GPIO4)
- LED BULB 4: D3 (GPIO0)
- Connect the cathode (shorter leg) of each LED to ground (GND) through a 220 Ohm resistor(For LEDs).
- Connect the anode (longer leg) of each LED to the following ESP8266 pins:
-
DHT11 Connection:
- Connect the VCC pin of the DHT11 to 3.3V on the ESP8266.
- Connect the GND pin of the DHT11 to GND on the ESP8266.
- Connect the data pin of the DHT11 to D5 (GPIO14) on the ESP8266.
-
ESP8266 Connection:
- Connect the ESP8266 to your computer using a USB cable for power and uploading code.
-
Flash MicroPython Firmware:
- Download the latest MicroPython firmware for ESP8266.
- Use a tool like
esptool.pyto flash the firmware onto your ESP8266.
-
Install Required Libraries:
- Use
miporupipto install thenetwork,machine,BlynkLib, anddhtlibraries on your ESP8266.
- Use
-
Blynk App Setup:
- Create a Blynk account and project.
- Add four buttons to control the LEDs, linked to virtual pins V1, V2, V3, and V4.
- Add a gauge widget to display the temperature, linked to virtual pin V5.
- Obtain the Blynk authorization token for your project.
-
Configure Wi-Fi and Blynk Token:
- Replace
wifissid,wifipass, andauthin the Python code with your Wi-Fi credentials and Blynk authorization token.
- Replace
-
Upload the Code:
- Use a tool like
ampyor Thonny to upload the Python code to your ESP8266.
- Use a tool like
network: For Wi-Fi connectivity.machine: For controlling GPIO pins.BlynkLib: For communication with the Blynk app.time: For delays.dht: For reading data from the DHT11 sensor.- Wi-Fi Connection: Connects the ESP8266 to your Wi-Fi network.
- Blynk Initialization: Establishes a connection with the Blynk server.
- LED Control: Controls the LEDs based on button presses in the Blynk app.
- DHT11 Reading: Reads temperature data from the DHT11 sensor.
- Blynk Virtual Writes: Sends LED status and temperature data to the Blynk app.
- Error Handling: Includes
try...exceptblocks to handle potential errors during value conversion. - Main Loop: Continuously runs the Blynk processes and reads sensor data.
-
Power On: Power on the ESP8266.
-
Connect to Blynk: The ESP8266 will connect to your Wi-Fi and Blynk.
-
Control LEDs: Use the buttons in the Blynk app to turn the LED BULBs on or off.
-
Monitor Temperature: The temperature will be displayed on the gauge widget in the Blynk app.
- Wi-Fi Credentials: Ensure your Wi-Fi credentials are correct.
- Blynk Token: Ensure your Blynk authorization token is correct.
- Pin Assignments: Double-check the pin assignments in the code and hardware setup.
- MicroPython Libraries: Make sure the required MicroPython libraries are installed.
- Error Handling: The code includes basic error handling, but you can add more robust error checking.
https://github.com/user-attachments/assets/bef6c9de-e6a4-403e-8396-ddf06b5a8266
- Add more sensors and actuators.
- Implement more complex automation logic.
- Use different Blynk widgets for a richer user interface.
- Add a web interface for local control.
- Utilize other cloud IoT platforms.
- Implement humidity monitoring and display.
- Add logging and data storage.
- Integrate with other smart home devices.
- Improve error handling and robustness.
Kritish Mohapatra
B.Tech Electrical Engineering (3rd Year)
IoT | Embedded Systems | MicroPython | ESP32
If you like this project, give it a ⭐ on GitHub and feel free to fork it!
Happy hacking 🚀
.png)