Embedded SystemsBeginnerPRJ-060

Heart-Rate Based Fan Speed Control Using ESP8266

A fan that speeds up when your pulse rises and slows when you calm down.

Built and tested by Shahan Fathima K · Industrial Robotics Institute

Circuit diagram of the Heart-Rate Based Fan Speed Control using ESP8266 NodeMCU
Circuit diagram · ESP8266 NodeMCU
LevelBeginner
Build time1–2 hours
BoardESP8266 NodeMCU
Parts6 components

What is the Heart-Rate Based Fan Speed Control?

A fan that responds to how you feel. A pulse sensor on your finger gives a signal that rises with heart activity; the ESP8266 turns it into a PWM speed for the fan through an L298N motor driver. When you are stressed or warm the fan speeds up, and when you are calm it slows down.

How it works

  1. The pulse sensor reads your heartbeat signal (0–1023).
  2. The ESP8266 maps it to a fan speed (0–255).
  3. It sends that speed as a PWM signal to the L298N’s ENA pin.
  4. Higher heart activity gives a faster fan; the speed updates every 200 ms.

Parts list

ComponentQty
ESP8266 NodeMCU1
Pulse Sensor1
L298N Motor Driver Module1
DC Fan / Motor1
Jumper WiresAs needed
External 5V/12V Power Supply1

Software

  • Arduino IDE

Wiring and connections

FromConnect to
Pulse sensor VCC3.3V
Pulse sensor GNDGND
Pulse sensor SIGNALA0
L298N IN1D1
L298N IN2D2
L298N ENA (PWM)D3
L298N VCCExternal 5V/12V
L298N GNDGND (common with ESP8266)
DC fanL298N OUT1 & OUT2

How to build the Heart-Rate Based Fan Speed Control

  1. Connect the pulse sensor to 3.3V, GND and A0.
  2. Remove the ENA jumper and connect ENA to D3, IN1 to D1 and IN2 to D2.
  3. Connect the fan to the L298N output and its power supply to the L298N.
  4. Join the ESP8266 and L298N grounds.
  5. Upload the code from the Arduino IDE.
  6. Place your finger on the pulse sensor and watch the fan speed change.

Heart-Rate Based Fan Speed Control code

Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the ESP8266 NodeMCU.

#define pulsePin A0
#define in1 D1
#define in2 D2
#define enA D3

int pulseValue = 0;

void setup()
{
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(enA, OUTPUT);

  digitalWrite(in1, HIGH);   // fixed direction
  digitalWrite(in2, LOW);
  analogWriteRange(255);     // PWM range 0-255
}

void loop()
{
  pulseValue = analogRead(pulsePin);

  int speed = map(pulseValue, 0, 1023, 0, 255);
  analogWrite(enA, speed);

  delay(200);
}

Real-world uses

  • Personal comfort fans
  • Stress-aware smart homes
  • Biofeedback learning
  • Health tech demos

Frequently asked questions

What is a Heart-Rate Based Fan Speed Control?

A fan that responds to how you feel. A pulse sensor on your finger gives a signal that rises with heart activity; the ESP8266 turns it into a PWM speed for the fan through an L298N motor driver.

What components are needed for the Heart-Rate Based Fan Speed Control?

You need: ESP8266 NodeMCU (1), Pulse Sensor (1), L298N Motor Driver Module (1), DC Fan / Motor (1), Jumper Wires, External 5V/12V Power Supply (1). Software: Arduino IDE.

Is the Heart-Rate Based Fan Speed Control project good for beginners?

Yes. It is rated beginner and takes about 1–2 hours to build, using the ESP8266 NodeMCU. The guide on this page explains every connection and step.

Where can I get the code for the Heart-Rate Based Fan Speed Control?

The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.

Can I buy a kit for the Heart-Rate Based Fan Speed Control?

Yes. IRI sells a kit with the parts for this project (PRJ-060). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.

Industrial Robotics Institute
Logo