Skip to content

About

Arduino-based heart rate monitor with LCD display (CSE371 Real-Time Embedded Systems project)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Heart Rate Sensor

CSE371 (Introduction to Real-Time Embedded Systems) course project at Yanbu Industrial College. An Arduino-based heart rate monitor that reads a pulse sensor and shows the BPM on an LCD screen.

Team: Wejdan Aljohani, Rama Ayman

Final system showing the BPM on the LCD

Problem

Heart-related diseases account for a large share of global deaths (nearly 30%, according to the studies we cited). Many pulse monitoring solutions are expensive, complicated, or don't give real-time data, which makes them hard to use widely.

Solution

A low-cost, easy-to-use heart rate monitor built on an Arduino Uno. The pulse sensor detects the heartbeat, the Arduino calculates the BPM in real time, and the result is shown on an LCD.

Objectives

  • Accurately measure heart rate
  • Display the heart rate on an LCD
  • Use a potentiometer to adjust the LCD contrast for better readability

Components

Components

  1. Arduino Uno with USB cable
  2. 9V battery
  3. 16x2 LCD
  4. 9V battery snap connector with DC jack
  5. Pulse sensor with wires
  6. Breadboard
  7. Potentiometer (LCD contrast)
  8. Jumper wires

Circuit design

Circuit diagram

  • Pulse sensor: 5V, GND, and signal to analog pin A0
  • LCD: connected to digital pins 2-7, powered from 5V and GND
  • Potentiometer: outer pins to 5V and GND, middle pin to the LCD contrast pin

How it works

Flow chart

On startup the program initializes the LCD and pins and sets up a timer interrupt. The interrupt handler reads the pulse sensor every 2 ms and detects each heartbeat. The main loop checks a flag and, when a beat was found, shows the BPM on the LCD. If no beat is detected for more than 2.5 seconds, it times out.

BPM calculation: the time between two detected beats is the inter-beat interval (IBI) in milliseconds.

BPM = 60000 / IBI

The BPM is averaged over the last 10 beats to keep the reading stable.

Build steps

  1. Connect the pulse sensor to the Arduino and the breadboard

  2. Connect the potentiometer to the breadboard

  3. Connect the LCD to the breadboard and the Arduino

  4. Connect the Arduino to the laptop with the USB cable

    Arduino connected to the laptop

    • Green ON LED: the Arduino is receiving power through the USB connection
    • Yellow L LED: shows activity on digital pin 13, and may blink while the Arduino is running a program
  5. Test: place a finger on the sensor and the heart rate appears on the LCD

Code

void loop()
{
  serialOutput();
  if (QS == true) // A Heartbeat Was Found
  {
    // BPM and IBI have been Determined
    // Quantified Self "QS" true when arduino finds a heartbeat
    serialOutputWhenBeatHappens(); // A Beat Happened, Output that to serial.
    QS = false; // reset the Quantified Self flag for next time
  }

  delay(20); // take a break
}

void interruptSetup()
{
  // Initializes Timer2 to throw an interrupt every 2mS.
  TCCR2A = 0x02;   // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE
  TCCR2B = 0x06;   // DON'T FORCE COMPARE, 256 PRESCALER
  OCR2A = 0X7C;    // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE
  TIMSK2 = 0x02;   // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A
  sei();           // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED
}
void serialOutputWhenBeatHappens()
{
  if (serialVisual == true) // Code to Make the Serial Monitor Visualizer Work
  {
    Serial.print(" Heart-Beat Found "); //ASCII Art Madness
    Serial.print("BPM: ");
    Serial.println(BPM);
    lcd.print("Heart-Beat Found ");
    lcd.setCursor(1,1);
    lcd.print("BPM: ");
    lcd.setCursor(5,1);
    lcd.print(BPM);
    delay(300);
    lcd.clear();
  }
  else
  {
    sendDataToSerial('B',BPM); // send heart rate with a 'B' prefix
    // ...

Results

Final system

Final system

Earlier test readings

BPM 70 BPM 68

With a finger on the sensor, the LCD shows "Heart-Beat Found" and the current BPM.

Project files

Skills shown

  • Real-time embedded systems
  • Arduino programming (C/C++)
  • Timer interrupts
  • Sensor interfacing
  • LCD interfacing
  • Circuit design
  • Hardware testing
  • Teamwork
  • Technical documentation

About

Arduino-based heart rate monitor with LCD display (CSE371 Real-Time Embedded Systems project)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors