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 MQTT Based Heart Rate Monitor using ESP8266 & Arduino
ESP8266 Projects IoT Projects

IoT MQTT Based Heart Rate Monitor using ESP8266 & Arduino

Mamtaz AlamBy Mamtaz AlamUpdated:August 20, 20221 Comment6 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
IoT Based Heart Rate Monitor
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview: IoT Based Heart Rate Monitor using ESP8266 & Arduino

In this project, we will make IoT Based Heart Rate Monitor using NodeMCU ESP8266, Arduino & Easy Pulse Sensor. We will display the value of Pulse Rate or BPM on OLED Display as well as MQTT Dashboard simultaneously. In one of the previous project, we use Optical Pulse Sensor with NodeMCU ESP8266 that can connect to the Wifi Network and uploads the Heart Rate (BPM) Value to Thingspeak Server regularly.

The free version of Thingspeak Server has limited access. The data uploads to Thingspeak Server only after an interval of 15 seconds. This is why it is necessary to select the method that can easily suit our requirements. MQTT protocol fulfills our requirements. MQTT is a lightweight publish/subscribe messaging protocol designed for low-bandwidth, high latency, unreliable networks. MQTT’s features make it an excellent option for sending high volumes of sensor messages to analytics platforms and cloud solutions.

So, one of the best MQTT platforms for IoT Project is Ubidots. We can use the Ubidots platform to send data to the cloud from any Internet-enabled device. In this IoT MQTT Based Heart Rate Monitor Project, we will interface the Easy Pulse Sensor with Arduino & ESP8266. We will first display the Pulse Rate Data on OLED Display. Then using the WiFi connectivity, the data will be sent to the Ubidtos MQTT Cloud.



Bill of Materials

Following are the list of components and modules that you need for this project. You can purchase all the components online from Amazon from the given purchase link.

S.N.ComponentsQuantityPurchase Links
1Arduino Nano Board1Amazon | AliExpress
2NodeMCU ESP8266 Board1Amazon | AliExpress
3Easy Pulse Sensor HRM-2511-E1Graylogix
40.96" I2C OLED Display1Amazon | AliExpress
55V DC Power Supply1Amazon | AliExpress
6Connecting Wires10Amazon | AliExpress
7Breadboard1Amazon | AliExpress

Easy Pulse Sensor

Easy Pulse Sensor

The Easy Pulse Sensor is a DIY pulse sensor that is designed for hobbyists and educational applications. It is used to illustrate the principle of photoplethysmography (PPG). PPG is a non-invasive technique for detecting the cardio-vascular pulse wave from a fingertip. The Easy Pulse Sensor uses a transmission mode PPG probe (HRM-2511E) sensor.

The Sensor uses an infrared light source to illuminate the finger on one side. On the other side of the sensor, there is a photodetector that measures small variations in the transmitted light intensity due to changes in blood volume inside the tissue. The onboard components & instrumentation provide a clean and filtered analog PPG waveform. The on-board LED also indicates the digital pulse output. The analog and digital signals are both synchronous with the heartbeat.

PPG Signal

Earlier, we used the Easy Pulse Sensor with Arduino to display the BPM Value on OLED Display. You can check the post here: Arduino Easy Pulse Sensor Tutorial


Block Diagram: IoT Based Heart Rate Monitor using ESP8266 Arduino on MQTT

For easy and clear understanding let us go through the block diagram. This is a simple diagramatic demonstration of the project: IoT Based Heart Rate Monitor using ESP8266 Arduino & Pulse Sensor.

IoT Based Heart Rate Monitor using ESP8266 Arduino on MQTT

We first Connect the Pulse Sensor to Arduino. Using UART Communication, we send the data from Arduino to NodeMCU ESP8266. We could have directly connected the Pulse Sensor to NodeMCU ESP8266 Board. But the pulse sensor doesn’t seem working and giving any output on Serial Monitor. So it’s easy to use the UART method to retrieve the data from Arduino to ESP8266.

The NodeMCU ESP8266 connects to the WiFi Network. It then uploads or publishes the BPM topic to MQTT Cloud Called Ubidots. The published data can be viewed on Computer or Mobile phones using the Ubidots Dashboard as they are the subscriber. This is how the entire IoT Based Heart Rate Monitor Project works.




Circuit Diagram & Connections

You can convert the above block diagram to the circuit diagram. I use Fritzing to draw the schematics. The connetion between Pulse Sensor ESP8266 & Arduino is fairly simple.

Pulse Sensor ESP8266 Arduino

We use Software Serial Method to communicate between ESP8266 & Arduino. For that connect the TX & RX Pins of ESP8266 to Arduino digital 7 & 8 Pins. Connect the input of the pulse sensor to Arduino A0 Pin. Similarly, connect the Pulse Sensor VCC & GND Pin to 5V & GND of Arduino.

As OLED Display is an I2C Module, so connect its I2C Pin, i.e SDA & SCL to D2 & D1 of NodeMCU respectively. Also connect the VCC & GND Pin of OLED Display to 3.3V & GND of ESP8266.

Heart Rate Monitor Pulse Sensor ESP8266


Setting Up Ubidots

We need to setup the Ubidots dashboard in order to recieve the Pulse Sensor BPM data from ESP8266 MQTT. In order to set up Ubidots, visit https://ubidots.com/ & create a New Account using your email address.

After login into Ubidots Dashboard, we need an API Key. To get the API key, click on the top right of the dashboard on the profile option. You will see an option called “API Credentials”. Click on the option.

Now when you click on Default Token and copy the API Token. You need an API Token in the code part to receive the data.


Source Code/program

The code for IoT Based Heart Rate Monitor using ESP8266 & Arduino on MQTT is divided into two part. We have to write and upload the program for both Arduino & NodeMCU Board.


But before that, there are few libraries that are required for project compilation. Check all of these libraries below and add it to the Arduino Library Folder.

  1. Pulse Sensor Library: Download

  2. ESP8266 MQTT Ubidots Library: Download

  3. PubSubClient Library: Download

  4. Adafruit GFX Library: Download

  5. Adafruit SSD1306 Library: Download

Code for Arduino Board

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
#include <SoftwareSerial.h>
#define USE_ARDUINO_INTERRUPTS true   // Set-up low-level interrupts for most acurate BPM math
#include <PulseSensorPlayground.h>     // Includes the PulseSensorPlayground Library
SoftwareSerial nodemcu(7, 8); // nodemcu module connected here
 
const int PulseWire = 0;       // 'S' Signal pin connected to A0
const int LED13 = 13;          // The on-board Arduino LED
int Threshold = 550;           // Determine which Signal to "count as a beat" and which to ignore
String myString;
String cmessage; // complete message
char buff[10];
 
PulseSensorPlayground pulseSensor;  // Creates an object
 
void setup()
{
  Serial.begin(9600);
  nodemcu.begin(9600);
 
  // Configure the PulseSensor object, by assigning our variables to it
  pulseSensor.analogInput(PulseWire);
  pulseSensor.blinkOnPulse(LED13);       // Blink on-board LED with heartbeat
  pulseSensor.setThreshold(Threshold);
 
  // Double-check the "pulseSensor" object was created and began seeing a signal
  if (pulseSensor.begin())
  {
    Serial.println("PulseSensor object created!");
  }
}
 
void loop()
{
  int myBPM = pulseSensor.getBeatsPerMinute();      // Calculates BPM
 
  if (pulseSensor.sawStartOfBeat()) // Constantly test to see if a beat happened
  {
    Serial.println("♥  A HeartBeat Happened ! "); // If true, print a message
    Serial.print("BPM: ");
    Serial.println(myBPM);                        // Print the BPM value
    myString = dtostrf(myBPM, 3, 0, buff);
    cmessage = cmessage + myString ;
    nodemcu.println(cmessage);
    Serial.println(cmessage);
    cmessage = "";
    Serial.println();
  }
  delay(20);
}


Code for NodeMCU ESP8266 Board

From this code, change the WiFi SSID, Password & Ubidots Token.

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
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "UbidotsESPMQTT.h"
#include <SoftwareSerial.h>
String myString; // complete message from arduino, which consistors of snesors data
char rdata; // received charactors
String myBPM;
 
#define TOKEN "******************" // Your Ubidots TOKEN
#define WIFINAME "******************" //Your SSID
#define WIFIPASS "******************" // Your Wifi Pass
 
#define SCREEN_WIDTH 128    // OLED display width, in pixels
#define SCREEN_HEIGHT 64    // OLED display height, in pixels
#define OLED_RESET -1       // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
 
Ubidots client(TOKEN);
 
void callback(char* topic, byte* payload, unsigned int length)
{
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i = 0; i < length; i++)
  {
    Serial.print((char)payload[i]);
  }
  Serial.println();
}
 
void setup()
{
  client.setDebug(true); // Pass a true or false bool value to activate debug messages
  Serial.begin(9600);
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C))
  {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;); // Don't proceed, loop forever
  }
  display.display();
  delay(100);
  display.clearDisplay();
  client.wifiConnection(WIFINAME, WIFIPASS);
  client.begin(callback);
}
 
void loop()
{
  if (Serial.available() > 0 )
  {
    rdata = Serial.read();
    myString = myString + rdata;
    if ( rdata == '\n')
    {
      Serial.println(myString);
      myBPM = getValue(myString, ',', 0);
      myString = "";
    }
    if (!client.connected())
    {
      client.reconnect();
    }
    int BPMvalue = myBPM.toInt();
    client.add("BPM", BPMvalue);
    client.ubidotsPublish("ESP8266");
    client.loop();
 
    Serial.println();
    delay(100);
  }
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(10, 30);
  display.print("BPM");
  //display.setCursor(5, 40);
  display.print(myBPM);
  display.display();
}
 
String getValue(String data, char separator, int index)
{
  int found = 0;
  int strIndex[] = { 0, -1 };
  int maxIndex = data.length() - 1;
 
  for (int i = 0; i <= maxIndex && found <= index; i++)
  {
    if (data.charAt(i) == separator || i == maxIndex)
    {
      found++;
      strIndex[0] = strIndex[1] + 1;
      strIndex[1] = (i == maxIndex) ? i + 1 : i;
    }
  }
  return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
}


Monitoring the Pulse Rate (BPM) Value on OLED & Cloud

Upload the code to the Arduino & NodeMCU Board. After uploading the code, attach the Probe to Finger or if you are using Earlobe clip attach it to ear.

Open the Serial Monitor on Arduino Code Part. Then you will see the Pulse Rate or BPM Value on Serial Monitor.

Also open the tab Serial Monitor for NodeMCU ESP8266 Output. You will see data being received via UART of Arduino. The data publish log will also be displayed on Serial Monitor.

Apart from the Serial Monitor, you can see the BPM value on OLED Display as well. In case if you don’t want this project with MQTT Connection, then you can use OLED to monitor the Heart Rate data.

Heart Rate Monitor ESP8266 OLED

To check the data online from any part of the world, you can visit the Ubidots Dashboard.

The data get logged after regular intervals. You can check all the logged data in table format as well.

You can create your own widgets from the dashboard. The widgets make the dashboard more beautiful.

IoT Based Pulse Rate Monitoring

The online monitoring of Heart Rate Data is not only limited to the Computer dashboard. But you can also check it on the mobile dashboard.

Heart Rate Monitor NodeMCU ESP8266 Pulse Sensor


Video Tutorial & Guide

IoT MQTT Based Heart Rate Monitor using ESP8266 & Arduino
Watch this video on YouTube.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleUltrasonic Range Finder with ESP32 TFT Display & HC-SR04
Next Article IoT Based Battery Status Monitoring System using ESP8266

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 1 Comment

1 Comment

  1. osman jamal on September 3, 2023 5:04 PM

    How to Interface Pulse Sensor with ESP8266 using Arduino Programming

    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
  • IoT Based PM & Air Quality Monitoring System using ESP32
    IoT Based PM & Air Quality Monitoring System using ESP32
  • 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
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
    ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • RS-485 Simplex Communication with Arduino & MAX485
    RS-485 Simplex Communication with Arduino & MAX485
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.