Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Arduino Cardiac Monitoring and Alerting for Smart Campuses

Tech Aug 13 16

Cardiac Monitoring Systems for Smart Academic Environments

Integrating biometric sensors into educational facilities enables continuous health tracking and proactive wellness management. Arduino microcontrollers facilitate the acquisition of pulse data via dedicated hardware modules, processing analog or digital signals to derive beats per minute (BPM). The extracted metrics can be routed to serial terminals, visual displays, or acoustic alert systems to notify users of anomalous cardiac activity.

1. Pulse Sensor Library with Serial Output

This implementation utilizes the PulseSensorPlayground library to process raw analog signals from a photoplethysmography (PPG) sensor. The microcontroller continuously samples the input, identifies cardiac cycles, and outputs the calculated BPM to the serial monitor.

#include <PulseSensorPlayground.h>

const int PULSE_INPUT = A1;
const int THRESHOLD_VAL = 560;
PulseSensorPlayground monitor;

void setup() {
  Serial.begin(115200);
  monitor.analogInput(PULSE_INPUT);
  monitor.setThreshold(THRESHOLD_VAL);
}

void loop() {
  if (monitor.sawNewSample()) {
    int bpm = monitor.getBeatsPerMinute();
    Serial.print("Current BPM: ");
    Serial.println(bpm);
  }
}

2. Pulse Sensor Library with I2C LCD Display

For standalone deployments without a connected PC, an I2C liquid crystal display provides immediate visual feedback. The logic captures new samples from the library, calculates the BPM, and updates the secondary row of the display while simultaneously logging to the serial interface.

#include <PulseSensorPlayground.h>
#include <LiquidCrystal_I2C.h>

const int PULSE_INPUT = A1;
const int THRESHOLD_VAL = 560;
PulseSensorPlayground monitor;
LiquidCrystal_I2C screen(0x3F, 16, 2);

void setup() {
  Serial.begin(115200);
  monitor.analogInput(PULSE_INPUT);
  monitor.setThreshold(THRESHOLD_VAL);
  screen.init();
  screen.backlight();
  screen.setCursor(0, 0);
  screen.print("Heart Rate:");
}

void loop() {
  if (monitor.sawNewSample()) {
    int bpm = monitor.getBeatsPerMinute();

    screen.setCursor(0, 1);
    screen.print("    ");
    screen.setCursor(0, 1);
    screen.print(bpm);

    Serial.print("BPM: ");
    Serial.println(bpm);
  }
}

3. Analog Signal Processing with Status LED

A basic hardware status indicator confirms that the sampling process is active. The onboard LED illuminates during the analog read phase, and the mapped BPM is transmitted over the serial port. This method uses direct analog reads scaled to a plausible BPM range.

const int SENSOR_ANALOG_PIN = A2;
const int STATUS_LED_PIN = 13;

void setup() {
  pinMode(STATUS_LED_PIN, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  digitalWrite(STATUS_LED_PIN, HIGH);
  int rawVoltage = analogRead(SENSOR_ANALOG_PIN);
  int mappedBPM = map(rawVoltage, 0, 1023, 55, 180);

  Serial.print("Measured BPM: ");
  Serial.println(mappedBPM);

  digitalWrite(STATUS_LED_PIN, LOW);
  delay(500);
}

4. Acoustic Alerting for Abnormal Readings

To immediately flag potentially dangerous heart rates during physical education or stress tests, a piezo buzzer can be triggered when BPM exceeds a defined safe threshold. The following logic activates an auditory alarm if the calculated rate surpasses 120 BPM, utilizing standard analog mapping and direct tone generation.

const int SENSOR_INPUT = A3;
const int BUZZER_OUTPUT = 8;
const int ALERT_THRESHOLD = 120;

void setup() {
  pinMode(BUZZER_OUTPUT, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int rawSignal = analogRead(SENSOR_INPUT);
  int currentBPM = map(rawSignal, 0, 1023, 55, 180);

  Serial.print("Rate: ");
  Serial.println(currentBPM);

  if (currentBPM > ALERT_THRESHOLD) {
    tone(BUZZER_OUTPUT, 2000, 500);
  } else {
    noTone(BUZZER_OUTPUT);
  }

  delay(1000);
}
Tags: Arduino

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.