Arduino Cardiac Monitoring and Alerting for Smart Campuses
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);
}