ESP8266/IoT B.Tech/Diploma Beginner

IoT MQTT Based Heart Rate Monitor using ESP8266 & Arduino

IoT Based Heart Rate (BPM) Monitor using NodeMCU ESP8266, Arduino & Easy Pulse Sensor on Ubidots MQTT Cloud Server. Source Code, Circuit Link

  • Suitable forB.Tech/Diploma ESP8266/IoT students
  • Build time1-2 weeks
  • LevelBeginner
  • Available atAjvika Labs, Kakinada

About this project

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.
Components
Quantity
Purchase Links

Arduino Nano Board

Amazon
AliExpress

NodeMCU ESP8266 Board

Amazon
AliExpress

Easy Pulse Sensor HRM-2511-E

Graylogix

0.96" I2C OLED Display

Amazon
AliExpress

5V DC Power Supply

Amazon
AliExpress

Connecting Wires

Amazon
AliExpress

Breadboard

Amazon
AliExpress
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.
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
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.
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
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
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.
Pulse Sensor Library:
Download
ESP8266 MQTT Ubidots Library:
Download
PubSubClient Library:
Download
Adafruit GFX Library:
Download
Adafruit SSD1306 Library:
Download
Code for Arduino Board

#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
(

)
;
// nodemcu module connected here
const
int
PulseWire
=

;
// 'S' Signal pin connected to A0
const
int
LED13
=

;
// The on-board Arduino LED
int
Threshold
=

;
// Determine which Signal to "count as a beat" and which to ignore
String
myString
;
String
cmessage
;
// complete message
char
buff
[

]
;
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
(
"BPM: "
)
;
Serial
println
(
myBPM
)
;
// Print the BPM value
myString
=
dtostrf
(
myBPM

buff
)
;
cmessage
=
cmessage
+
myString
;
nodemcu
println
(
cmessage
)
;
Serial
println
(
cmessage
)
;
cmessage
=
""
;
Serial
println
(
)
;
}
delay
(

)
;
}
Code for NodeMCU ESP8266 Board
From this code, change the
WiFi SSID
Password
&
Ubidots Token

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "UbidotsESPMQTT.h"
#include <SoftwareSerial.h>

Technologies used

ESP8266ArduinoMQTTThingSpeakWiFiBLESSD1306OLEDI2CSPIUARTAWS

Hardware components

  • ESP8266
  • Arduino
  • SSD1306
  • OLED

Software & tools

  • ThingSpeak
  • MQTT
  • Fritzing

What you get

  • Working project / hardware kit, tested before delivery
  • Complete source code with explanation
  • Project demo and guidance for your viva
  • Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed. Payment is in two parts: • 50% advance to start the project • Remaining 50% before delivery Note: • Documentation and PPT are not included by default • If you need documentation/PPT, it can be arranged for extra time and cost We'll confirm the exact timeline and cost with you after reviewing your requirements.