IoT-Smart Fan Control Using ESP8266, DHT11 and KiwisIoT
by Keerthana Dass in Circuits > Electronics
33 Views, 0 Favorites, 0 Comments
IoT-Smart Fan Control Using ESP8266, DHT11 and KiwisIoT
In this project, we are going to build an IoT-based Smart Fan Control System using an ESP8266 NodeMCU, DHT11 temperature sensor, relay module, 5V DC fan, and KiwisIoT.
The ESP8266 reads the temperature from the DHT11 sensor and sends the temperature value to the KiwisIoT dashboard. The fan is connected through a relay and can be turned ON or OFF remotely using the KiwisIoT dashboard.
This project demonstrates how an ESP8266 can be used to monitor temperature and remotely control a fan through an IoT platform.
Supplies
ESP8266 NodeMCU — 1
DHT11 Temperature Sensor — 1
2-Channel Relay Module — 1
5V DC Fan — 1
5V DC Power Supply — 1
Breadboard — 1
Jumper Wires — As required
USB Cable — 1
How the Project Works
The DHT11 temperature sensor measures the surrounding temperature and sends the temperature value to the ESP8266 NodeMCU.
The ESP8266 processes the temperature reading and sends it to the KiwisIoT dashboard through Wi-Fi.
The fan is connected to the ESP8266 through a relay module. The relay allows the fan to be turned ON or OFF remotely using the KiwisIoT dashboard.
KiwisIoT Channels
- Channel 0 → Displays the temperature
- Channel 1 → Controls the fan
When Channel 1 is set to ON, the ESP8266 activates the relay and the fan turns ON.
When Channel 1 is set to OFF, the relay switches OFF and the fan stops.
Project Flow
Temperature Monitoring:
DHT11 → ESP8266 → Wi-Fi → KiwisIoT
Fan Control:
KiwisIoT → ESP8266 → Relay → 5V Fan
Circuit Connections
The following connections are used to connect the DHT11 sensor, relay module, and 5V fan to the ESP8266 NodeMCU.
DHT11 Temperature Sensor
Connect the DHT11 sensor to the ESP8266 as follows:
DHT11 VCC → ESP8266 3.3V
DHT11 DATA → ESP8266 D5
DHT11 GND → ESP8266 GND
Relay Module
Connect the relay module to the ESP8266 as follows:
Relay VCC → Relay power supply
Relay GND → ESP8266 GND
Relay IN1 → ESP8266 D1
Only IN1 (Relay Channel 1) is used in this project. The second relay channel is not used.
5V Fan
The fan is powered using a separate 5V DC power supply.
Connect the fan through the relay:
5V Power Supply (+) → Relay COM
Relay NO → Fan (+)
Fan (−) → 5V Power Supply (−)
Important
Do not connect the 5V fan directly to the ESP8266. The fan is powered from the separate 5V supply and is switched ON/OFF using the relay.
Installing Arduino IDE and Libraries
Before programming the ESP8266 NodeMCU, we need to install the Arduino IDE and the required libraries.
1. Install Arduino IDE
Download and install the Arduino IDE on your computer.
2. Install ESP8266 Board Support
Open Arduino IDE and add the ESP8266 board package through the Boards Manager.
After installation, select:
Tools → Board → ESP8266 → NodeMCU 1.0 (ESP-12E Module)
3. Install Required Libraries
Open:
Sketch → Include Library → Manage Libraries
Search for and install:
- DHT sensor library
- Adafruit Unified Sensor
- KiwisIoT Library
These libraries are required to read the DHT11 sensor and communicate with the KiwisIoT platform.
Arduino Code
The following Arduino code reads the temperature from the DHT11 sensor and sends the temperature value to KiwisIoT Channel 0.
It also receives the fan control command from KiwisIoT Channel 1 and switches the relay ON or OFF accordingly.
Channel 1 = 1 → Fan ON
Channel 1 = 0 → Fan OFF
KiwisIoT Dashboard
KiwisIoT is used in this project to monitor the temperature and control the fan remotely.
The ESP8266 communicates with the KiwisIoT platform through Wi-Fi.
Two channels are used in this project:
Channel 0 — Temperature
The temperature measured by the DHT11 sensor is sent to Channel 0 and displayed on the KiwisIoT dashboard.
Channel 1 — Fan Control
Channel 1 is used to control the fan remotely.
ON (1) → Relay turns ON → Fan turns ON
OFF (0) → Relay turns OFF → Fan turns OFF
This allows the user to monitor the temperature and control the fan from the KiwisIoT dashboard.
Testing the Project
After uploading the program to the ESP8266 NodeMCU, open the Serial Monitor in the Arduino IDE and set the baud rate to 115200.
The ESP8266 connects to the Wi-Fi network and then connects to KiwisIoT.
The DHT11 continuously measures the temperature and sends the temperature value to KiwisIoT Channel 0.
To test the fan control, change Channel 1 on the KiwisIoT dashboard.
Channel 1 = ON (1)
The relay switches ON and the 5V fan starts running.
Channel 1 = OFF (0)
The relay switches OFF and the fan stops.
The Serial Monitor displays the temperature readings and the received fan control commands.
Final Result
The Smart Fan Control System is now successfully completed.
The DHT11 sensor measures the surrounding temperature and sends the temperature data to the KiwisIoT dashboard through the ESP8266.
The fan can be controlled remotely using the KiwisIoT dashboard. When the fan control is set to ON, the relay activates and the 5V fan starts running. When it is set to OFF, the relay switches off and the fan stops.
This project demonstrates how an ESP8266, sensor, relay, and IoT platform can be combined to create a simple and practical IoT-based automation system.