This circuit is designed to monitor heart rate and detect falls using an MPU-6050 accelerometer and a heart pulse sensor. It includes an Arduino UNO microcontroller to process sensor data and control outputs such as a buzzer and an LED. The circuit is powered by the Arduino's 5V output and includes a resistor to limit current to the LED.
5V
connected to Heart Pulse Sensor VCC
GND
connected to MPU-6050 GND
, Heart Pulse Sensor GND
, buzzer GND
, and LED cathode
(through Resistor)A0
connected to Heart Pulse Sensor SIGNAL
A4
(SDA) connected to MPU-6050 SDA
A5
(SCL) connected to MPU-6050 SCL
D10
connected to buzzer PIN
D11
connected to LED anode
VCC
not connectedGND
connected to Arduino UNO GND
SDA
connected to Arduino UNO A4
SCL
connected to Arduino UNO A5
VCC
connected to Arduino UNO 5V
GND
connected to Arduino UNO GND
SIGNAL
connected to Arduino UNO A0
GND
connected to Arduino UNO GND
PIN
connected to Arduino UNO D10
anode
connected to Arduino UNO D11
cathode
connected to Arduino UNO GND
(through Resistor)pin1
not connectedpin2
connected to LED cathode
#include <Wire.h>
#include <MPU6050.h>
MPU6050 mpu;
const float FALL_THRESHOLD = 2.5; // Fall detection acceleration threshold
const int buzzerPin = 10; // Buzzer pin
const int ledPin = 11; // LED pin
const int heartSensorPin = A0; // Heart rate sensor pin
const int volume = 1; // Buzzer volume (PWM value)
const int heartRateThreshold = 60; // Heart rate threshold (example: 60 BPM)
unsigned long lastFallTime = 0; // Last fall detection time
const unsigned long debounceTime = 2000; // Debounce time of 2 seconds after fall detection
void setup() {
Serial.begin(9600);
Wire.begin();
mpu.initialize();
pinMode(buzzerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(heartSensorPin, INPUT);
if (!mpu.testConnection()) {
Serial.println("MPU6050 connection failed");
while (1);
}
}
void loop() {
// Read sensor data
int16_t ax, ay, az;
mpu.getAcceleration(&ax, &ay, &az);
// Convert acceleration to m/s² (1g ≈ 9.81m/s²)
float accelX = ax / 16384.0 * 9.81;
float accelY = ay / 16384.0 * 9.81;
float accelZ = az / 16384.0 * 9.81;
// Current time
unsigned long currentTime = millis();
// Fall detection
if (accelZ < FALL_THRESHOLD && (accelX > 1 || accelY > 1)) {
if (currentTime - lastFallTime > debounceTime) { // Check debounce time
Serial.println("Fall detected!");
// Turn on LED
digitalWrite(ledPin, HIGH);
delay(500); // Keep LED on for 0.5 seconds
digitalWrite(ledPin, LOW); // Turn off LED
// Turn on buzzer with low sound
analogWrite(buzzerPin, volume);
delay(1000); // Buzzer on for 1 second
analogWrite(buzzerPin, 0); // Turn off buzzer
lastFallTime = currentTime; // Update last fall detection time
}
}
// Measure heart rate
int heartSignal = analogRead(heartSensorPin);
float heartRate = map(heartSignal, 0, 1023, 0, 200); // Example mapping (may vary with sensor)
// Print heart rate
Serial.print("Heart Rate: ");
Serial.print(heartRate);
Serial.println(" BPM");
// Warn if heart rate is below threshold
if (heartRate < heartRateThreshold) {
Serial.println("Low heart rate warning!");
digitalWrite(ledPin, HIGH); // Turn on LED
analogWrite(buzzerPin, volume); // Buzzer on with low sound
delay(1000); // Buzzer on for 1 second
digitalWrite(ledPin, LOW); // Turn off LED
analogWrite(buzzerPin, 0); // Turn off buzzer
}
// Print acceleration values (for debugging)
Serial.print("Accel X: ");
Serial.print(accelX);
Serial.print(" | Accel Y: ");
Serial.print(accelY);
Serial.print(" | Accel Z: ");
Serial.println(accelZ);
delay(500); // Check interval (0.5 seconds)
}
void setup() {
// Setup code here, to run once:
}
void loop() {
// Main code here, to run repeatedly:
}
(Note: The MPU-6050 code provided is empty and does not contain any functional code. It is assumed that the MPU-6050 is being controlled by the Arduino UNO via the I2C interface, and its functionality is included in the Arduino UNO's code.)