Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » IoT Temperature Based Fan Speed Control & Monitoring System
ESP8266 Projects IoT Projects

IoT Temperature Based Fan Speed Control & Monitoring System

Mamtaz AlamBy Mamtaz AlamUpdated:May 28, 20233 Comments6 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
IoT Temperature Based Fan Speed Control & Monitoring System
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview

In this project, we will make Temperature Based Fan Speed Control & Monitoring System using ESP8266 WiFi Module & observe the data on IoT App Blynk. The fan speed increases based on the increase in temperature. The Blynk App will show the current temperature & Fan speed in percentage. Using the Blynk, we can also set the threshold value at what temperature the fan should turn ON.

To sense the room temperature, we will use a DS18B20 Waterproof Temperature Sensor. For the fan part, a 12V fan is perfect for this application as it is easy to control the speed with the PWM signal. The 16×2 LCD Display will display the instantaneous temperature and fan speed as well.

To get started, you can refer to Arduino Temperature Fan Speed Controller project, which gives overall idea about the working.



Bill of Materials

To make IoT Temperature Based Fan Speed Control System project, we need the following components.

S.N.ComponentsQuantityPurchase Link
1NodeMCU ESP8266 Module1Amazon | AliExpress
2DS18B20 Temperature Sensor1Amazon | AliExpress
316x2 LCD Display1Amazon | AliExpress
410K Potentiometer1Amazon | AliExpress
5IRF540N Mosfet1Amazon | AliExpress
612V DC Fan1Amazon | AliExpress
712V DC Power Adapter1Amazon | AliExpress
8Resistor 10K1Amazon | AliExpress
9Resistor 4.7K1Amazon | AliExpress
107805 Voltage Regulator IC1Amazon | AliExpress
11100uF Capacitor1Amazon | AliExpress
1210uF Capacitor1Amazon | AliExpress
13Breadboard1Amazon | AliExpress
14Connecting Wires1Amazon | AliExpress

Circuit Diagram & Connection

The following is the schematic of the IoT Temperature Based Fan Speed Control & Monitoring System using ESP8266. The connections are fairly simple.

IoT Temperature Based Fan Speed Control & Monitoring System

The entire circuit can be powered by a 12V DC power supply. Actually, the DC Fan only requires 12V for operations. The rest of the components takes 5V as input from the 7805 Voltage regulator IC. The DS18B20 Waterproof temperature sensor is connected to the D6 pin of Nodemcu ESP8266. The DS18B20 VCC & GND is connected to 3.3V & GND of NodeMCU. The output pin of DS18B20 is pulled high with a 4.7K resistor.

For displaying temperature and Fan Speed, we are using a 16×2 I2C LCD Display. Connect the VCC, GND, SDA & SCL pins of the LCD Display to 5V, GND, D2 & D1 of NodeMCU ESP8266.

The digital pin of NodeMCU is not capable of controlling the 12V fan alone. Therefore we are using an IRF540 Mosfet to control a fan. This output of the NodeMCU pin D0 goes to the Gate terminal of the IRF540 Mosfet. This Mosfet work as an Amplifier, which can control a large amount of voltage by applying a small amount of voltage at the Gate Terminal.

IoT Temperature Fan Speed Control ESP8266 Circuit

I used a zero PCB to assemble all the components together. As a power supply, you can use a 12V DC power adapter or a 12V battery. I am powering the circuit using a 11.2V Lithium-Ion Battery Pack.




Project PCB Gerber File & PCB Ordering Online

If you don’t want to assemble the circuit on a zero PCB and you want PCB for the project, then here is the PCB for you. I used EasyEDA to draw the schematic first. Then I converted the schematic to PCB. The PCB Board for this project looks something like below.

The Gerber File for the PCB is given below. You can simply download the Gerber File and order the PCB from ALLPCB at 1$ only.

Download Gerber File: Temperature Based Fan Speed Control PCB

You can use this Gerber file to order high quality PCB for this project. To do that visit the ALLPCB official website by clicking here: https://www.allpcb.com/.

You can now upload the Gerber File by choosing the Quote Now option. From these options, you can choose the Material Type, Dimensions, Quantity, Thickness, Solder Mask Color and other required parameters.

After filling all details, select your country and shipping method. Finally you can place the order.

You can assemble the components on the PCB Board.


Blynk 2.0 Web & Mobile Dashboard Setup

Now let’s set up the Blynk Web Dashboard first. To do that visit blynk.io and sign up using the email ID.

First Create a New Template.

Assign the name, Hardware & Connection Type.

From the Web Dashboard, Create 4 widgets Gauge, Label, LED & Slider.

For the Gauge setting, choose the Virtual pin V4. This will be used for displaying the fan speed in percentage.

For temperature display in label, select virtual pin V3 and data type as integer.

For the slider assign the virtual pin as V7. The slider is used to set up the threshold value at which the fan would turn on.

For LED setting rename the variable as Fan as this will indicate the fan ON/OFF status. The virtual pin assigned for the fan is V0.

Apart from the Web Dashboard, you can also set up your Mobile App Dashboard. For that download the Blynk from Playstore or AppStore. Using the Mobile dashboard, you can have the same observation as the web dashboard.



Source Code/Program

The code for IoT Temperature Based Fan Speed Control & Monitoring System using ESP8266 is written in Arduino IDE. We need to install the following library first.

  1. Blynk Library: Download
  2. OneWire Library: Download
  3. Dallas Temperature Library: Download
  4. I2C LCD Library: Download

From the following lines you can change the WiFi SSID, Password & Blynk Authentication Token.

1
2
3
char auth[] = "*********************";      //Blynk Authntication Token
char ssid[] = "*********************";      //WiFi SSID
char pass[] = "*********************";      //WiFi Password

From the Board List select NodeMCU 1.0 Board and from the COM Port list, select the right port for ESP8266. Then hit the upload button to upload the code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
 
#define BLYNK_PRINT Serial
#define ONE_WIRE_BUS 12
 
int fanPin = 16;
int dutyCycle = 0;
 
float temp = 0;
int threshold = 30;
 
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
 
WidgetLED FAN(V0);
 
char auth[] = "*********************";
char ssid[] = "*********************";
char pass[] = "*********************";
 
 
void setup()
{
  Serial.begin(115200);
  sensors.begin();
  pinMode(fanPin, OUTPUT);
 
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("  Temperature ");
  lcd.setCursor(0, 1);
  lcd.print("Monitoring System");
  delay(4000);
  lcd.clear();
 
  analogWriteRange(100);
  analogWriteFreq(10000);
 
  Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
}
 
 
BLYNK_WRITE(V7)
{
  threshold = param.asInt();
  Serial.print(" The Threshhold thresholdue is: ");
  Serial.println(threshold);
  Serial.println();
}
 
 
void controlFanSpeed(int fanSpeedPercent)
{
  analogWrite(fanPin, fanSpeedPercent);
 
  Serial.print("Fan Speed: ");
  Serial.print(fanSpeedPercent);
  Serial.println("%");
 
  lcd.setCursor(0, 1);
  lcd.print("Fan Speed: ");
  lcd.print(fanSpeedPercent);
  lcd.print("%");
}
 
 
void loop()
{
  Blynk.run();
  sensors.requestTemperatures();
  temp = sensors.getTempCByIndex(0);
 
  Serial.print("Temperature: ");
  Serial.print(temp);
  Serial.println("*C");
 
  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(temp);
  lcd.print("*C");
 
  Blynk.virtualWrite(V3, temp);
 
  if (temp >= threshold)
  {
    FAN.on();
    int fanSpeedPercent = map(temp, threshold, 55, 10, 100);
    controlFanSpeed(fanSpeedPercent);
    Blynk.virtualWrite(V4, fanSpeedPercent);
  }
  else if (temp < threshold)
  {
    FAN.off();  
    int fanSpeedPercent = 0;
    controlFanSpeed(fanSpeedPercent);
    Blynk.virtualWrite(V4, fanSpeedPercent);
  }
}

For generating PWM we have used the “analogWrite(pin, PWM value)” function in 8 bits. Mean if the PWM value is equivalent to an analog value. So if we need to generate 20% of the duty cycle then we pass 255/5 value as PWM in the “analogWrite” Function.




Testing: IoT Temperature Based Fan Speed Control System

After uploading the code, the ESP8266 will try connecting to the WiFi Network. After it gets connected to the WiFi Network, it connects to the Blynk platform using the Blynk Authentication Token.

At the same time the 16×2 LCD Display will show the temperature in degrees Celsius and Fan Speed in Percentage.

IoT Based Temperature Based Fan Speed Control & Monitoring System

At the same time the Blynk App will also display the Temperature in °C and Fan Speed in the Gauge widget. It will also indicate the Fan ON/OFF status and threshold value in the slider.

By default the threshold is set to 30°C. It means if the temperature exceeds the threshold value the fan will start automatically. The speed of the fan will gradually increase from 0-100% between the range of threshold value and upper limit. In this case, the upper limit is set to 55°C. In case the current temperature is less than the threshold the fan will not start.

The threshold value can be set using the Blynk Slider.

When the sensor detects a high temperature, the Fan turns on and its speed depends upon the temperature.

IoT Temperature Based Fan Speed Control & Monitoring System using ESP8266

The greater the temperature the greater the Fan speed. At a temperature of 55°C, the fan speed becomes 100%. You can change the value of the upper limit of temperature in the code part.

Temperature Based Fan Speed Control ESP8266 Blynk

The same thing can be monitored online on Blynk Web Dashboard as well. You can observe the fan speed and temperature from any part of the world.

This is how you can build and setup the IoT Temperature Based Fan Speed Control & Monitoring using ESP8266 and the Blynk Application.


Video Tutorial & Guide

IoT Temperature Based Automatic Fan Speed Control & Monitoring System using ESP8266 & Blynk 2.0
Watch this video on YouTube.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleIoT Controlled Relay using Raspberry Pi Pico W WiFi
Next Article How to use ADS1115 16-Bit ADC Module with Arduino

Related Posts

ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

Updated:June 16, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

Updated:June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

Updated:May 10, 20262K
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

Updated:May 2, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

Updated:April 27, 20261K
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

Updated:April 27, 20262K
View 3 Comments

3 Comments

  1. Prateek Singh on December 25, 2022 11:13 AM

    Nice sir

    Reply
  2. Mr. BianchiRider on August 14, 2023 10:57 PM

    Excellent project. I am planning a similar project using a relay to control the fan operation to cool my stereo cabinet. Using a mosfet is a more elegant solution and I plan to do this once I prove a fan will solve the problem with my Roku box overheating.
    However, in your source code for Blynk you should keep the void loop clean. I would suggest using a timer to read the temperature, print to the LCD, adjust the fan, etc every, say, second. Writing data to Blynk in a void loop (which would be thousands of times per second) is going to overload the Blynk server, resulting in communication troubles with the Blynk server.
    You probably won’t have any trouble since you are only writing two data points to the server, but you never know. The Blynk community website harps about this all of the time.

    Reply
  3. DKM on October 25, 2024 6:50 AM

    I want to design my own PCB. But i cant find the LCD Display and the NodeMCU that you have used. Can you tell me the Part-Numbers?

    Reply

CommentsCancel reply

Latest Posts
ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 16, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • ESP32 Fingerprint Attendance System with Live Web Dashboard
    ESP32 Fingerprint Attendance System with Live Web Dashboard
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • Interfacing PN532 NFC RFID Module with Arduino
    Interfacing PN532 NFC RFID Module with Arduino
  • How to use ADS1115 16-Bit ADC Module with Arduino
    How to use ADS1115 16-Bit ADC Module with Arduino
  • IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
    IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
  • IoT Based PM & Air Quality Monitoring System using ESP32
    IoT Based PM & Air Quality Monitoring System using ESP32
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.