You are on page 1of 12

OBJECTIVE:

To measures and display individual’s heart rate in real time.

BACKGROUND:
From medical workers manually checking patients' pulses to the introduction of
computerized heart rate monitors, the history of heart rate monitors has been revolutionary.
These monitors were once only used in clinical settings, but they are now widely used in both
consumer and medical applications. Heart rate monitoring is significant since it is one of the
most important markers of cardiovascular health. Frequent monitoring helps preventative
healthcare initiatives by enabling early abnormality discovery.
Additionally, by guaranteeing safe workout intensities, heart rate monitors are essential for
enhancing fitness regimens. With cutting-edge tools like electrocardiography (ECG), they aid
in the diagnosis and treatment of heart disorders. Continuous heart rate monitoring has
benefits beyond medicine in that it helps people reduce stress and enhance their general
health. Sensors are the foundation of how heart rate monitor’s work.

COMPONENTS:
1. Arduino UNO
2. OLED
3. PULSE SENSOR
4. BUZZER
5. VERO BOARD
6. JUMPER WIRES

THEORY:
ARDUINO:
Arduino is an open-source platform (Often
referred as Micro-controller) used for building
electronics projects. Arduino consists of both a
Programmable hardware and a software which
is used to over write the Arduino Programmable
Hardware by using language Which in terms
called embedded C and C.

ARDUINO POWER OPTIONS:


Arduino can be operated by 3 methods which are
very well-known.
USB: We can operate Arduino by its USB plug In
Port which connects with your Laptop/Personal
Computer by a USB cable. It can provide up to
(5V and 200mA-300mA).

ADAPTOR JACK: There is an option of Adaptor Jack present on hardware of Arduino; it


works at 7V TO 12V.

Department Of Biomedical Engineering


Sir Syed University of Engineering and Technology, Karachi.
CELL/BATTERY: We can directly Operate Arduino Micro Controller by giving directly a
DC supply of 5v to its Vin Pin.

ORGANIC LIGHT EMITTING


DIODE (OLED):
The organic light-emitting diode (OLED) display
that we’ll use in this tutorial is the SSD1306
model: a mono color, 0.96-inch display with
128×64 pixels. The OLED display doesn’t require
backlight, which results in a very nice contrast in
dark environments. Additionally, its pixels
consume energy only when they are on, so the
OLED display consumes less power when
compared with other displays.
It has only four pins and communicates with the
Arduino using I2C communication protocol.
There are models that come with an extra RESET pin. There are also other OLED displays that
communicate using SPI communication.
Here is a general guide for connecting an OLED display to an Arduino using I2C:
CONNECTIONS
VCC to 5V: Connect the OLED's VCC (power) pin to the Arduino's 5V pin.
GND to GND: Connect the OLED's GND (ground) pin to any of the Arduino's GND pins.
SCL to A5: Connect the OLED's SCL (serial clock) pin to the Arduino's A5 pin.
SDA to A4: Connect the OLED's SDA (serial data) pin to the Arduino's A4 pin.

PULSE SENSOR:
A pulse sensor is a device used to measure the
heart rate (pulse) of an individual. It typically
works by detecting the pulsatile component of
blood flow in peripheral blood vessels, usually
the fingertip.
The working of the Pulse/Heart beat sensor is
very simple.The sensor has two sides, on one side
the LED is placed along with an ambient light
sensor and on the other side we have some
circuitry. This circuitry is responsible for the
amplification and noise cancellation work. The
LED on the front side of the sensor is placed over
a vein in our human body. This can either be your
Finger tip or you ear tips, but it should be placed
directly on top of a vein.Now the LED emits light
which will fall on the vein directly. The veins will
have blood flow inside them only when the heart
is pumping, so if we monitor the flow of blood we can monitor the heart beats as well. If the

Department Of Biomedical Engineering


Sir Syed University of Engineering and Technology, Karachi.
flow of blood is detected then the ambient light sensor will pick up more light since they will
be reflect ted by the blood, this minor change in received light is analysed over time to
determine our heart beats.
Pin Configuration:
Pin Number Pin Name Description
1 Ground Connected to the ground of the system
2 Vcc Connect to +5v or +3.3v supply voltage
3 Signal Pulsating output signal

BUZZER:
A buzzer is an electroacoustic device
that produces sound when an electrical
signal is applied to it. It is a simple form
of a transducer that converts electrical
energy into mechanical vibrations,
resulting in audible sound waves.
Connections:
1. Connect the positive (+) terminal of
the buzzer to one of the digital output
pins on the Arduino.
2. Connect the negative (-) terminal of
the buzzer to the Arduino's GND
(ground) pin.

VERO BOARD:
A vero board, also referred to as a
stripboard or perfboard, is a versatile
circuit prototyping platform commonly
used in electronics. The board is
characterized by a grid of perforations
or holes arranged in rows and columns.
One side of the board features copper
strips, usually organized horizontally,
connecting the holes. These copper strips
allow for the creation of electrical
connections between components. The
opposite side of the board typically
consists of an insulating material,
ensuring electrical isolation between the
copper strips.

When assembling a circuit on a vero board, electronic components like resistors, capacitors,
and integrated circuits are mounted by inserting their leads into the holes. The leads are

Department Of Biomedical Engineering


Sir Syed University of Engineering and Technology, Karachi.
then bent and arranged to establish connections between adjacent holes, forming the desired
circuit. Additional connections or breaks in the copper strips are often made using solder or
jumper wires, offering flexibility in circuit design and modification.

MALE TO FEMALE JUMPER


WIRES:
Male-to-female jumper wires are
essential components in electronics
and prototyping. These wires consist
of a male connector at one end and a
female connector at the other,
allowing them to establish
connections between components
with varying pin types. On one side,
the male connector typically has pins
or prongs that can be inserted into
headers or
sockets on a circuit board, sensor, or
microcontroller. This design
facilitates a secure and
reliable electrical connection. The female connector, on the other end, is equipped with
receptacles that can accept male pins, ensuring compatibility with different components.
Male-to-female jumper wires are commonly used in breadboarding, allowing for quick and
temporary connections between various electronic elements. These wires eliminate the need
for soldering, making them highly convenient for rapid prototyping and experimentation.
The male ends enable direct insertion into headers on microcontrollers or sensors, while the
female ends accommodate components with male pins.

CIRCUIT DIAGRAM & CONNECTONS:


To design ECG Display using Pulse Sensor with OLED & Arduino, assemble the
components as shown in the figure below

Department Of Biomedical Engineering


Sir Syed University of Engineering and Technology, Karachi.
• Connect pulse sensor VCC pin to Arduino 5V Pin and GND to GND. Connects its
signal pin to Arduino Analog pin A0.

• Similarly connect the VCC Pin of OLED Display to Arduino 3.3V pin and GND
to GND. Connect its SDA & SCK pins to Arduino A4 & A5 pins respectively.

• Connect a buzzer to Arduino digital pin 8 and another pin to GND.

WORKING OF CIRCUITRY:
Pulse Sensor:
The pulse sensor works by emitting an Infra-Red signal from an IR-Diode onto the skin. Just
underneath the skin, there are capillaries carrying blood. Every time heart pumps there is a
small increase in blood flow/pressure. This swells the capillaries slightly, this slightly more
filled capillary reflects more infra-red than at times when the heart is not giving your blood a
“push”. An Infra-detector on the device senses the different reflected IR levels. Some simple
comparator circuitry converts this into a voltage signal which we can read with the Arduino
Analog inputs.

OLED 128×64 (SSD1306 Driver) display:


In this project, we’re adding an ECG waveform plotter along with BPM on the OLED
display. For this we need 2 different library, i.e SSD1306 Driver & GFX Library. Firstly
ensure you’ve bought an OLED 128×68 I²C display (SSD1306 driver) display. It should
have four connections, i.e 5V, GND, SDA, and SCK.

OLED Address:
Since the OLED used here is an I2C OLED, so it has a particular device address. To find
the I2C address first scan the OLED with the I2C Scanner program. Normally the OLED
Display has a device address of 0x3C or 0X3D.

Final Displayed Output:


After code is uploaded to Arduino Board, at first no graph or waveform is seen. But when the
finger is placed the BPM value is displayed as well as the graph is drawn along with the beep
sound from Buzzer. The value may be irregular or unstable at starting for few seconds but
later the value becomes stables. The sensor is not too accurate as it is cheap. So, it cannot
give us properly accurate values of BPM.
For some OLED there is a problem with the trace being at the bottom and the BPM being
missing then this is caused by the following lines in the Adafruit_SSD1306.h file in libraries
folder :
#define SSD1306_128_64
// #define SSD1306_128_32
// #define SSD1306_96_16
For the project ECG Display using Pulse Sensor with OLED & Arduino, it must be need to
add 2 libraries.
1. Adafruit SSD1306 Library
2. Adafruit GFX Library
Now, compile and upload the program that's below to the Arduino.

Department Of Biomedical Engineering


Sir Syed University of Engineering and Technology, Karachi.
SOURCE CODE FOR PULSE RATE MONITOR WITH ECG DISPLAY:
#include <Adafruit_SSD1306.h>
#define OLED_Address 0x3C // 0x3C device address of I2C OLED. Few other OLED has
0x3D
Adafruit_SSD1306 oled(128, 64); // create our screen object setting resolution to 128x64 int
a=0;
int lasta=0;
int lastb=0;
int LastTime=0;
int ThisTime;
bool BPMTiming=false;
bool BeatComplete=false;
int BPM=0;
#define UpperThreshold 560
#define LowerThreshold 530
void setup()
{
oled.begin(SSD1306_SWITCHCAPVCC, OLED_Address);
oled.clearDisplay();
oled.setTextSize(2);
}
void loop()
{
if(a>127)
{
oled.clearDisplay(); a=0;
lasta=a;
}
ThisTime=millis();
int value=analogRead(0);
oled.setTextColor(WHITE);
int b=60-(value/16);
oled.writeLine(lasta,lastb,a,b,WHITE);
lastb=b;
lasta=a;
if(value>UpperThreshold)
{
if(BeatComplete)
{
BPM=ThisTime-LastTime;
BPM=int(60/(float(BPM)/1000));
BPMTiming=false;
BeatComplete=false;
tone(8,1000,250);
}
if(BPMTiming==false)
{
LastTime=millis(); BPMTiming=true;

if((value<LowerThreshold)&(BPMTiming)) BeatComplete=true;
oled.writeFillRect(0,50,128,16,BLACK); oled.setCursor(0,50);
Department Of Biomedical Engineering
Sir Syed University of Engineering and Technology, Karachi.
oled.print("BPM:");
oled.print(BPM);
oled.display();
a++;
}
Adafruit_SSD1306 oled(128, 64); // create our screen object setting resolution to 128x64 int
a=0;
int lasta=0;
int lastb=0;
int LastTime=0;
int ThisTime;
bool BPMTiming=false;
bool BeatComplete=false;
int BPM=0;
#define UpperThreshold 560
#define LowerThreshold 530 void setup() {
oled.begin(SSD1306_SWITCHCAPVCC, OLED_Address);
oled.clearDisplay();
oled.setTextSize(2);
}
void loop()
{
if(a>127)
{
oled.clearDisplay(); a=0;
lasta=a;
}
ThisTime=millis();
int value=analogRead(0);
oled.setTextColor(WHITE);
int b=60-(value/16);
oled.writeLine(lasta,lastb,a,b,WHITE);
lastb=b;
lasta=a;
if(value>UpperThreshold)
{
if(BeatComplete)
{
BPM=ThisTime-LastTime; BPM=int(60/(float(BPM)/1000)); BPMTiming=false;
BeatComplete=false; tone(8,1000,250);
}
if(BPMTiming==false)
{
LastTime=millis();
BPMTiming=true;
if((value<LowerThreshold)&(BPMTiming)) BeatComplete=true;
oled.writeFillRect(0,50,128,16,BLACK);
oled.setCursor(0,50);
oled.print("BPM:");
oled.print(BPM);
oled.display();
Department Of Biomedical Engineering
Sir Syed University of Engineering and Technology, Karachi.
a++;
}

DESCRIPTION OF SOURCE CODE:


The above Arduino code aims to create a heart rate monitor with an ECG wave displayed on an
OLED screen. In the preamble, the necessary library, Adafruit_SSD1306, is included, and an
Adafruit_SSD1306 object named 'oled' is instantiated with a resolution of 128x64 pixels. The
I2C address of the OLED module is set to 0x3C.

Here, several global variables are declared:


• a: Counter variable for drawing on the OLED display.
• lasta and lastb: Store the previous coordinates for drawing lines on the OLED display.
• LastTime and ThisTime: Store the timestamp of the last and current loop iterations.
• BPMTiming and BeatComplete: Flags to control the timing of BPM calculation and
to indicate a complete heartbeat.
• BPM: Variable to store the calculated heart rate in beats per minute.
• UpperThreshold and LowerThreshold: Threshold values for detecting a
heartbeat based on analog sensor readings.

In the setup function, the OLED display is initialized. The oled.begin function configures the
display, and oled.clearDisplay clears any existing content on the screen. oled.setTextSize
sets the text size to 2.
Now, let's go through the loop function step by step:

Drawing on OLED: If the counter 'a' exceeds 127 (the width of the OLED display), it
clears the display and resets the counter. The 'oled.writeLine' function is employed to draw a
line on the OLED display, representing the ECG wave. The coordinates are determined based
on the counter 'a' and the analog sensor value ('value').

Heartbeat Detection: The analog sensor value is read and stored in the variable 'value'. If
'value' is above the 'UpperThreshold', it indicates a heartbeat. If a complete heartbeat
('BeatComplete') is detected, the heart rate (BPM) is calculated based on the time between the
current and last heartbeat. The 'tone' function is utilized to produce an audible indication.

BPM Timing: If 'BPMTiming' is not active, it records the current time as the starting point
for BPM calculation.

BPM Calculation and Display: The heart rate (BPM) is calculated based on the time
between heartbeats. The BPM value is then displayed on the OLED screen.

Updating OLED Display: The lower part of the OLED display is cleared ('oled.writeFillRect') to
update the BPM value. The BPM value is printed on the display. Incrementing Counter: The
counter 'a' is incremented for the next iteration.

Department Of Biomedical Engineering


Sir Syed University of Engineering and Technology, Karachi.
COMPREHENSIVE PROCESS STAGES FOR CREATING AND
OPERATING THE HARDWARE CIRCUIT:

1) We recently undertook a project to create a heart rate monitor featuring an ECG wave
using components such as a Pulse Sensor, Arduino Uno, OLED display, and a buzzer. The
journey began by gathering all the necessary materials, including jumper wires and a
breadboard. We meticulously connected the Pulse Sensor to the Arduino Uno, linking VCC
to 5V, GND to GND, and the signal output to Analog Pin A0.

2) Moving on, established connections for the OLED display, attaching SDA to Analog Pin
A4, SCL to Analog Pin A5, VCC to 5V, and GND to GND. The Buzzer followed, with its
positive end connected to Digital Pin 8 and the negative end to the Arduino's GND.

3) For a more permanent connection, we decided to solder the wires. Setting up a well-
ventilated and well-lit workspace, tinned the wire tips and carefully connected them to their
respective pins on each component using a soldering iron. Heat shrink tubing provided
insulation, ensuring secure connections and minimizing the risk of short circuits.

4) The next step involved assembling the components on the breadboard, ensuring a tidy
layout and confirming the stability of connections. With the hardware in place, installed the
Arduino IDE on my computer and integrated the necessary libraries for the OLED display.

5) Taking the Arduino code from reference (https://www.arduino.cc/) and adjusted it as per
the requirement, verified it, and uploaded it to the Arduino Uno. Opening the Serial Monitor
allowed me to observe any debug information.

6) Upon powering on the Arduino Uno and placing the Pulse Sensor on my fingertip, the
OLED display vividly showcased heart rate and ECG wave representations. The added
auditory dimension from the buzzer further enriched the experience.

7) To fine-tune the project, we adjusted the code and thresholds for calibration, aligning
them with the unique characteristics of my Pulse Sensor. After ensuring the correct pin
usage, we reached a satisfying outcome.

8) In the final phase of the project, we took the initiative to secure the components within a
project enclosure, providing a polished appearance to the hardware circuit. To ensure a more
permanent and robust setup, we decided to transition from the breadboard to a vero board.
The soldering process onto the vero board demanded careful attention to detail.
After selecting an appropriately sized vero board, we meticulously replicated the circuit layout
from the breadboard. The soldering iron was employed to heat the copper pads, and with
precision, we affixed each component securely in place.

9) Throughout the process, paid close attention to wire routing, insulating adjacent traces, and
double-checking connections for potential issues like solder bridges or cold joints. The
soldered components were then firmly secured to the vero board, providing stability and
durability to the assembly. Thorough testing of the circuit was conducted before proceeding
to the final step of integrating the vero board into the project enclosure. This integration was

Department Of Biomedical Engineering


Sir Syed University of Engineering and Technology, Karachi.
executed with care, ensuring that external components such as the Pulse Sensor and OLED
display were positioned optimally for easy access.

OBSERVATION TABLE:

SUBJECTS AGE CONDITION HEART RATE RANGE


(BPM)
Person 1 8 Yrs. Relaxed state 76 70-115
Active state 98
Person 2 26 Yrs. Relaxed state 65 60-100
Active state 90
Person 3 43 Yrs. Relaxed state 88 60-100
Active state 128

FINAL OUTPUT RESULTS:

Department Of Biomedical Engineering


Sir Syed University of Engineering and Technology, Karachi.
ANALYSIS OF THE RESULTS OBTAINED:
The successful completion of the heart rate monitor project with an ECG wave display
yielded promising outcomes across various key aspects. First and foremost, the heart rate
monitoring functionality using the Pulse Sensor proved effective, delivering real-time and
accurate heart rate information. The integration of this data with the Arduino code facilitated
a clear representation of the ECG wave on the OLED display, providing a visual insight into
the heart's electrical activity.

The addition of an audible component through the buzzer further enriched the user
experience, synchronizing with each detected heartbeat and adding an extra layer of
engagement to the monitoring process. The transition from a temporary breadboard setup to a
more permanent solution on a vero board, coupled with meticulous soldering, significantly
enhanced the stability and reliability of the hardware circuit. This shift contributes to a more
enduring solution suitable for long-term use.

The integration of the vero board into a project enclosure serves both practical and aesthetic
purposes. The carefully executed placement ensures easy access to external components
while presenting a tidy and organized appearance. Throughout the development, the
calibration of the Arduino code played a pivotal role in achieving precise and meaningful
monitoring results. Adjustments to thresholds and timing parameters were made to fine-tune
the system, contributing to its overall accuracy.

In essence, the results attained underscore the success of the heart rate monitor project,
emphasizing the importance of meticulous attention to details during construction, soldering
processes, and coding phases. The cohesive integration of hardware and software
components has culminated in a functional, reliable, and user-friendly heart rate monitoring
system with an ECG wave display.

RANGE OF RESOURCES:
For the engineering activity involving the creation of a heart rate monitor with an ECG wave
display, a diverse range of resources was harnessed to ensure the project's success. The
collective expertise of the project team, which included two people, played a crucial role in
conceptualizing, designing, and implementing the heart rate monitoring system.

Financial resources were allocated for the project, covering the procurement of essential
components such as
700Rs Pulse Sensors
550Rs OLED displays
50Rs for buzzer with a total budget of 1300 units of currency

The infrastructure, both physical and technological, provided the necessary support for the
project, including dedicated workspaces, soldering equipment, power supplies, and
computers for coding tasks. A wealth of tangible materials, from jumper wires and a
breadboard to the actual electronic components, formed the building blocks of the heart rate
monitor. Access to relevant information, spanning knowledge about the Pulse Sensor's

Department Of Biomedical Engineering


Sir Syed University of Engineering and Technology, Karachi.
functionality, Arduino programming, OLED display integration, and soldering guidelines,
proved crucial. Additionally, cutting-edge technology, notably Arduino Uno boards for
microcontroller functionality and OLED display technology, played a key role in bringing the
project to fruition. The effective integration of people, financial backing, infrastructure,
materials, information, and technology underscores the comprehensive approach taken in this
engineering endeavour.

OUR EXPERIENCE:
Our exploration of the relevant principles and laws necessary for implementing the heart rate
monitor project was a recent endeavour, providing us with a foundation of knowledge. While
we had a conceptual roadmap outlining the steps to achieve our desired outcome, there were
instances where we found ourselves second-guessing certain decisions along the way. This
experience prompted us to engage in a continuous process of evaluation and refined
prediction, enhancing our ability to foresee potential outcomes. The need to
navigate uncertainties and make informed decisions at various points in the project
contributed to a more nuanced understanding of the subject matter. Overall, this experience
fostered a dynamic learning environment, where our theoretical understanding intersected with
the practical challenges of constructing a heart rate monitor with an ECG wave display.

RESULTS AND CONCLUSION:


To sum up, the project of real-time heart rate monitor was implemented successfully which
contributed a lot in the field of health monitoring by technology. The primary task to provide
users with an instantaneous and accurate information about their heart rates has been
accomplished by integration of advanced sensors and real-time data processing algorithms.
The project is not only a technical demonstration but also meets the growing requirements
for individualized healthcare solutions.
Challenges were faced during the development phase which were conquered thereby
demonstrating the resilience and problem-solving abilities of the project team. Testing and
user feedback have played a key role in honing the performance of the monitor as well as
enhancing its reliability across different scenarios. The project’s joint effort between
hardware and software resulted in a smooth experience for users hence increasing efficiency
of heart rate monitor generally.
The final results from this project demonstrate how much health and wellness can be
improved by empowering people to monitor their own heart rates in real time. This helps
identify problems early as well as promoting proactive approach to self-care monitor is easy
to use interface that can work on different devices.

Department Of Biomedical Engineering


Sir Syed University of Engineering and Technology, Karachi.

You might also like