Project Overview
This project creates a fall detection system that monitors an elderly person’s activity and alerts caregivers when a fall is suspected. Using multiple PIR sensors placed strategically, the system detects unusual patterns—sudden motion followed by prolonged inactivity—and sends an alert via SMS, email, or local alarm.
Difficulty: Intermediate
Estimated time: 3-4 hours
Estimated cost: $40-60
How It Works
The system uses one or more PIR sensors to monitor movement patterns in key areas (bedroom, bathroom, living room). It detects anomalies: sudden rapid movement (characteristic of a fall), prolonged inactivity after movement, and motion detected in unexpected areas. When a potential fall is detected, the system activates an alarm and sends notifications to caregivers.
Materials Needed
- ESP32 (1)
- HC-SR501 PIR sensors (2-4)
- Buzzer for local alarm
- LED for status indication
- 220Ω resistors
- Jumper wires
- Power supply (5V 2A)
- Enclosures for sensors and main unit
- GSM module (optional, for SMS if no Wi-Fi)
Sensor Placement
- Bedroom: Near the bed to detect getting in/out
- Bathroom: At the entrance and near the toilet/shower
- Living room: Covering seating area and pathways
- Hallways: Between rooms
Circuit Diagram
Connection Table
| Component |
Pin |
ESP32 Pin |
PIR Sensor 1 (Bedroom) |
OUT
GPIO 4
PIR Sensor 2 (Bathroom) |
OUT
GPIO 5
PIR Sensor 3 (Living) |
OUT
GPIO 6
PIR Sensor 4 (Hallway) |
OUT
GPIO 7
Buzzer |
Positive
GPIO 8
Status LED |
Anode
GPIO 2 (via 220Ω)
表
Arduino Code
// Elderly Fall Detection System
#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "YourWiFiSSID";
const char* password = "YourWiFiPassword";
const char* botToken = "YourTelegramBotToken";
const char* chatID = "YourChatID";
const int pirPins[] = {4, 5, 6, 7};
const int buzzerPin = 8;
const int ledPin = 2;
const int numSensors = 4;
const char* sensorNames[] = {"Bedroom", "Bathroom", "Living Room", "Hallway"};
unsigned long lastMotionTime = 0;
const unsigned long inactivityThreshold = 300000;
const unsigned long fallCooldown = 60000;
bool fallAlertActive = false;
bool normalActivity = true;
unsigned long lastActivityTime[4];
int motionCounts[4];
int rapidMovementCount = 0;
unsigned long rapidMovementStartTime = 0;
const int rapidMovementThreshold = 3;
const unsigned long rapidMovementWindow = 5000;
void setup() {
Serial.begin(115200);
for (int i = 0; i < numSensors; i++) {
pinMode(pirPins[i], INPUT);
lastActivityTime[i] = 0;
motionCounts[i] = 0;
}
pinMode(buzzerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(buzzerPin, LOW);
digitalWrite(ledPin, LOW);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) delay(500);
delay(60000);
}
void sendTelegramAlert(String message) {
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
String url = "https://api.telegram.org/bot" + String(botToken) + "/sendMessage";
http.begin(url);
http.addHeader("Content-Type", "application/json");
String payload = "{\"chat_id\":\"" + String(chatID) + "\", \"text\":\"" + message + "\"}";
http.POST(payload);
http.end();
}
}
void activateAlarm() {
if (!fallAlertActive) {
fallAlertActive = true;
sendTelegramAlert("FALL DETECTED! Please check on the individual immediately.");
digitalWrite(ledPin, HIGH);
for (int i = 0; i < 10; i++) {
tone(buzzerPin, 2000, 500);
delay(500);
tone(buzzerPin, 2500, 500);
delay(500);
}
}
}
void resetAlarm() {
if (fallAlertActive) {
fallAlertActive = false;
digitalWrite(ledPin, LOW);
digitalWrite(buzzerPin, LOW);
sendTelegramAlert("Fall alarm has been reset.");
}
}
void checkForFall() {
unsigned long currentTime = millis();
bool anyMotion = false;
unsigned long latestMotionTime = 0;
for (int i = 0; i < numSensors; i++) {
bool motion = digitalRead(pirPins[i]) == HIGH;
if (motion) {
anyMotion = true;
latestMotionTime = currentTime;
if (currentTime - lastActivityTime[i] > 1000) {
lastActivityTime[i] = currentTime;
motionCounts[i]++;
if (currentTime - rapidMovementStartTime < rapidMovementWindow) {
rapidMovementCount++;
} else {
rapidMovementStartTime = currentTime;
rapidMovementCount = 1;
}
}
}
}
if (rapidMovementCount > rapidMovementThreshold) {
activateAlarm();
}
if (!anyMotion && normalActivity && (currentTime - lastMotionTime > inactivityThreshold)) {
activateAlarm();
normalActivity = false;
}
if (anyMotion) {
lastMotionTime = currentTime;
normalActivity = true;
}
}
void loop() {
checkForFall();
if (digitalRead(0) == LOW) {
delay(50);
if (digitalRead(0) == LOW) {
resetAlarm();
while (digitalRead(0) == LOW) delay(10);
}
}
delay(100);
}
Caregiver Web Dashboard
#include <WebServer.h>
WebServer server(80);
void handleRoot() {
String html = "<html><body><h1>Activity Monitor</h1><table border=1>";
for (int i = 0; i < numSensors; i++) {
html += "<tr><td>" + String(sensorNames[i]) + "</td><td>" + String(motionCounts[i]) + "</td></tr>";
}
html += "</table></body></html>";
server.send(200, "text/html", html);
}
void setup() {
server.on("/", handleRoot);
server.begin();
}
void loop() {
server.handleClient();
}
Installation Steps
- Position sensors at key locations
- Adjust sensitivity for normal movement detection
- Assemble main unit and connect sensors
- Configure Telegram bot for notifications
- Test normal activity to establish baseline
- Simulate a fall to verify alarm triggers
- Fine-tune inactivity threshold and rapid movement sensitivity
Conclusion
This fall detection system provides peace of mind for caregivers and independence for elderly individuals living alone, ensuring help arrives quickly when needed.