Lsse-Semester Vii - Biomedical Engineering - 2020-2021 - Oddsemester

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Online ExperimentReport(OnlinePractical)

LSSE-Semester VII – Biomedical Engineering – 2020-2021 –OddSemester

Name of the Student: vikram kolekar


Roll no.18105A2016
Date of submission: 6/11/2020
Title of Experiment: To make a Pulse Oximeter for measuring Heart Rate/Pulse Rate
Experiment
No. 10

Title To Build a Pulse oximeter to calculate pulse rate

Objective Calculate Pulse Rate

Backgroun
d Knowledge of Pulse Oximeter & Tools like Arduino IDE

1.Connect OLED, buzzer and MAX30102


2.Write the code
Procedure 3.Run thecode
4.Please Finger on thesensor
5.See the results displayed on theOLED
● Arduino UNO R3:

● OLED 0.91 inch128x32:


Componen
ts

● MAX30102 sensor:
Online ExperimentReport(OnlinePractical)
LSSE-Semester VII – Biomedical Engineering – 2020-2021 –OddSemester

#include<Adafruit_GFX.h> //OLED libraries


#include<Adafruit_SSD1306.h>
#include <Wire.h>
#include"MAX30105.h" //MAX3010xlibrary
#include"heartRate.h" //Heart rate calculatingalgorithm

MAX30105 particleSensor;
const byte RATE_SIZE = 4; //Increase this for more averaging. 4 is good. byte
rates[RATE_SIZE]; //Array of heart rates
byte rateSpot = 0;
long lastBeat = 0; //Time at which the last beat occurred float
beatsPerMinute;
int beatAvg;

#define SCREEN_WIDTH 128 // OLED display width, in pixels


#define SCREEN_HEIGHT 32 // 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); //Declaring the display name (display)

static const unsigned char PROGMEM logo2_bmp[] =


{ 0x03, 0xC0, 0xF0, 0x06, 0x71, 0x8C, 0x0C, 0x1B, 0x06, 0x18, 0x0E, 0x02, 0x10,
0x0C, 0x03, 0x10, //Logo2 and Logo3 are two bmp pictures that
display on the OLED ifcalled
Code 0x04, 0x01, 0x10, 0x04, 0x01, 0x10, 0x40, 0x01, 0x10, 0x40, 0x01, 0x10, 0xC0,
0x03, 0x08, 0x88,
0x02, 0x08, 0xB8, 0x04, 0xFF, 0x37, 0x08, 0x01, 0x30, 0x18, 0x01, 0x90, 0x30,
0x00, 0xC0, 0x60,
0x00, 0x60, 0xC0, 0x00, 0x31, 0x80, 0x00, 0x1B, 0x00, 0x00, 0x0E, 0x00, 0x00,
0x04, 0x00,};

static const unsigned char PROGMEM logo3_bmp[] =


{ 0x01, 0xF0, 0x0F, 0x80, 0x06, 0x1C, 0x38, 0x60, 0x18, 0x06, 0x60, 0x18, 0x10,
0x01, 0x80, 0x08,
0x20, 0x01, 0x80, 0x04, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0xC0,
0x00, 0x08, 0x03,
0x80, 0x00, 0x08, 0x01, 0x80, 0x00, 0x18, 0x01, 0x80, 0x00, 0x1C, 0x01, 0x80,
0x00, 0x14, 0x00,
0x80, 0x00, 0x14, 0x00, 0x80, 0x00, 0x14, 0x00, 0x40, 0x10, 0x12, 0x00, 0x40,
0x10, 0x12, 0x00,
0x7E, 0x1F, 0x23, 0xFE, 0x03, 0x31, 0xA0, 0x04, 0x01, 0xA0, 0xA0, 0x0C, 0x00,
0xA0, 0xA0, 0x08,
0x00, 0x60, 0xE0, 0x10, 0x00, 0x20, 0x60, 0x20, 0x06, 0x00, 0x40, 0x60, 0x03,
0x00, 0x40, 0xC0,
0x01, 0x80, 0x01, 0x80, 0x00, 0xC0, 0x03, 0x00, 0x00, 0x60, 0x06, 0x00, 0x00,
0x30, 0x0C, 0x00,
Online ExperimentReport(OnlinePractical)
LSSE-Semester VII – Biomedical Engineering – 2020-2021 –OddSemester

0x00, 0x08, 0x10, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x00,
0x01, 0x80, 0x00 };

void setup()
{
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //Start the OLED display
display.display();
delay(3000);
// Initialize sensor
particleSensor.begin(Wire, I2C_SPEED_FAST); //Use default I2C port, 400kHz
speed
particleSensor.setup(); //Configure sensor with default settings
particleSensor.setPulseAmplitudeRed(0x0A); //Turn Red LED to low to
indicate sensor is running
}
void loop() {
long irValue=particleSensor.getIR(); //Reading the IR value it will permit
us to know if there's a finger on the sensor ornot

//Also detecting a heartbeat


if(irValue>7000) //If a finger isdetected
{
display.clearDisplay(); //Clear thedisplay
display.drawBitmap(5, 5, logo2_bmp, 24,21,WHITE); //Draw the first
bmp picture (littleheart)
display.setTextSize(2); //Near it display the average BPM you can
display the BPM if youwant
display.setTextColor(WHITE);
display.setCursor(50,0);
display.println("BPM");
display.setCursor(50,18);
display.println(beatAvg);
display.display();
if (checkForBeat(irValue)==true) //If a heartbeat is detected
{
display.clearDisplay(); //Clear the display
display.drawBitmap(0, 0, logo3_bmp, 32,32,WHITE); //Draw thesecond
picture (bigger heart)
display.setTextSize(2); //And still displays the average BPM
display.setTextColor(WHITE);
display.setCursor(50,0);
display.println("BPM");
display.setCursor(50,18);
display.println(beatAvg);
display.display();
tone(3,1000); //And tone the buzzer for a100ms
you can reduce it it will bebetter
delay(100);
Online ExperimentReport(OnlinePractical)
LSSE-Semester VII – Biomedical Engineering – 2020-2021 –OddSemester

noTone(3); //Deactivate the buzzer to have the


effect of a"bip"
//We sensed a beat!
long delta = millis()-lastBeat; //Measure duration between two
beats
lastBeat = millis();
beatsPerMinute = 60 / (delta/ 1000.0); //Calculating theBPM
if (beatsPerMinute < 255 && beatsPerMinute> 20) //To calculate
the average we strore some values (4) then do some math to calculate theaverage
{
rates[rateSpot++] = (byte)beatsPerMinute; //Store this reading in the array
rateSpot %= RATE_SIZE; //Wrap variable

beatAvg = 0;
for (byte x = 0 ; x < RATE_SIZE; x++) //Take average ofreadings
beatAvg +=rates[x];
beatAvg /= RATE_SIZE;
}
}
}
if (irValue < 7000) //If no finger is detected it inform the user and put the average
BPM to 0 or it
{
will be stored for the next measure
beatAvg=0;
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(30,5);
display.println("Please Place ");
display.setCursor(30,15);
display.println("your finger ");
display.display();
noTone(3);
}
}

Circuit
Diagram
Online ExperimentReport(OnlinePractical)
LSSE-Semester VII – Biomedical Engineering – 2020-2021 –OddSemester

Both the modules (MAX30102 and OLED) use I2C interface for communication. If2
pin buzzers are used, then negative terminal should be grounded and positive
terminal should relate to the resistor to the digital pin 3(D3).

About the circuit:


1.Arduino is interfaced to the OLED and MAX30102sensor
2.When the code is run, subject needs to place finger on the sensor and wait fora
while till the buzzer sound is in sync withheartbeat.
3.Here the average bpm (Average of 4 bpm) is calculated, thus the readings turn out
to be moreaccurate.
4.The readings are displayed on the screen of theOLED.
Description Bit Map:
1.This helps in creating the small animated heart to pop up every time heartbeat and
finger isdetected.
2.Further knowledge on the creation of Bit Map’s is given in the linkbelow.
Precaution:
1.Reading may come wrong if finger is not stable while the heart rate is being
measured.
https://create.arduino.cc/projecthub/SurtrTech/measure-heart-rate-and- spo2-
Reference with-max30102-c2b4d8

From the above examination, we have assembled a working heartbeat


Conclusion oximeter which will quantify pulse/beat rate.

You might also like