Skip to content

Eldoraaa/DoraShield

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ DoraShield β€” ELDORA Fall Detection Wearable

Protect. Respond. Recover.

Platform Language Sensor Protocol License Hackathon


ESP32 firmware for the ELDORA DoraShield β€” a wearable fall-detection device that continuously monitors acceleration, detects strong impact events, and triggers an immediate local buzzer alert to protect elderly users.

🌐 ELDORA Ecosystem Β· πŸ€– DoraBot Β· πŸ“± ELDORA App


πŸ“Œ Overview

DoraShield is the first line of defense in the ELDORA eldercare ecosystem. Worn on the body, it continuously reads inertial data from the MPU6050 accelerometer/gyroscope and triggers an immediate local buzzer alert the moment a fall or strong impact is detected β€” no internet connection required for the core safety response.

DoraShield's role in the ELDORA ecosystem: "The wearable guardian β€” always on, always measuring, always ready to raise the alarm before anyone even realizes something happened."

MCU ESP32
IMU Sensor MPU6050 (I2C) β€” 3-axis accelerometer + 3-axis gyroscope
Alert Output Active buzzer (GPIO-driven)
Detection Method Total acceleration vector magnitude threshold
Power Li-ion battery + power module
Response Latency Real-time (continuous polling loop)

🌐 ELDORA Ecosystem

DoraShield is the Protect layer of ELDORA's three-phase safety framework:

ELDORA Ecosystem
β”œβ”€β”€ πŸ›‘οΈ  DoraShield   β€” Fall detection wearable (this repo β€” ESP32)
β”œβ”€β”€ πŸ€–  DoraBot       β€” AI voice companion (ESP32-S3)
└── πŸ“±  ELDORA App    β€” Caregiver dashboard (XGBoost + SHAP, Isolation Forest)


✨ Firmware Features

  • πŸ“‘ MPU6050 Initialization β€” configures the IMU over I2C on boot with error checking
  • πŸ”„ Continuous Acceleration Reading β€” polls 3-axis accelerometer data in the main loop
  • πŸ“ Total Acceleration Vector Calculation β€” computes resultant magnitude from X, Y, Z axes
  • πŸ’₯ Fall / Impact Detection β€” triggers alert when magnitude exceeds the configured threshold
  • πŸ”” Local Buzzer Alert β€” activates buzzer immediately on detection, deactivates when motion normalizes
  • πŸ–₯️ Serial Monitor Output β€” streams live sensor values and alarm state for debugging and threshold tuning

πŸ› οΈ Tech Stack

Layer Technology Purpose
MCU ESP32 Main processor, I2C master, GPIO control
Framework Arduino (ESP-IDF) Firmware development environment
IMU Driver Adafruit MPU6050 I2C communication and sensor abstraction
Sensor Abstraction Adafruit Unified Sensor Standardized sensor event interface
I2C Bus Wire Arduino I2C protocol library
Debug Output Serial Monitor (115200 baud) Live sensor data + alarm state logging

πŸ”§ Hardware

Component Model / Spec Role
Microcontroller ESP32 Main firmware host, I2C master
IMU MPU6050 3-axis accelerometer + 3-axis gyroscope
Alert Active buzzer Immediate local fall alarm output
Power Li-ion battery + power module Portable wearable power supply

Pin Configuration

Defined in FallDetection.ino:

Pin GPIO Connected To
I2C SDA GPIO 4 MPU6050 SDA
I2C SCL GPIO 5 MPU6050 SCL
Buzzer GPIO 3 Active buzzer signal

⚠️ If you rewire the hardware, update the #define constants at the top of FallDetection.ino to match your new pin assignments before flashing.


πŸ“ Project Structure

DoraShield/
β”‚
└── πŸ“„ FallDetection.ino     # Complete firmware β€” MPU6050 init, read loop,
                             # vector calculation, threshold check, buzzer control
Why it's a single file

DoraShield's firmware is intentionally minimal and self-contained. The entire detection pipeline β€” sensor init, data read, math, alert output, serial logging β€” fits cleanly in one Arduino sketch, making it straightforward to flash, audit, and tune. There are no hidden dependencies between files or initialization order surprises.


βš™οΈ How DoraShield Works

In plain English:

DoraShield boots β†’ initializes MPU6050 over I2C
    β†’ enters continuous loop:
        reads ax, ay, az from MPU6050
        computes total acceleration magnitude
        if magnitude > threshold β†’ buzzer ON  (fall detected)
        else                     β†’ buzzer OFF (normal motion)
        streams readings to Serial Monitor

πŸ”¬ Fall Detection Logic

The core detection is a total acceleration vector magnitude check:

// Read accelerometer, gyroscope, and temperature events
sensors_event_t a, g, temp;
mpu.getEvent(&a, &g, &temp);

// Compute resultant acceleration magnitude across all three axes
float totalAccel = sqrt(
  a.acceleration.x * a.acceleration.x +
  a.acceleration.y * a.acceleration.y +
  a.acceleration.z * a.acceleration.z
);

// Threshold-based fall detection
if (totalAccel > 15.0) {
  digitalWrite(BUZZER_PIN, HIGH);  // FALL / IMPACT detected
} else {
  digitalWrite(BUZZER_PIN, LOW);   // Normal motion
}

Why total magnitude?

A fall produces a characteristic impact spike β€” a sudden surge in resultant acceleration across all axes simultaneously β€” regardless of the wearable's orientation. Using the vector magnitude instead of individual axes makes the detector orientation-agnostic, so it works whether DoraShield is worn on the wrist, chest, or clipped to a belt.

Tuning the threshold

The default threshold of 15.0 m/sΒ² is a starting point. To tune it for real-world accuracy:

Step Action
1 Open Serial Monitor at 115200 baud
2 Have the wearer perform normal activities (walking, sitting, standing up)
3 Note the peak totalAccel values during normal motion
4 Simulate a controlled fall onto a soft surface and note the spike value
5 Set threshold between the highest normal-motion peak and the lowest fall spike

General guidance:

Scenario Typical totalAccel
Standing still ~9.8 m/sΒ² (gravity only)
Walking 10–13 m/sΒ²
Sitting down quickly 12–14 m/sΒ²
Fall / hard impact > 15–25 m/sΒ²

A threshold too low β†’ false positives on vigorous movement. Too high β†’ missed falls. Tune per user and wearable placement.

Extending the detection algorithm

The current firmware uses a simple single-threshold check. More robust approaches to consider:

Enhancement Description
Free-fall pre-phase Detect a brief near-zero-g window (< ~2 m/sΒ²) before the impact spike β€” characteristic of true falls
Gyroscope fusion Add angular velocity check: falls often produce rapid rotation on at least one axis
Debounce window Require the threshold to be exceeded for N consecutive samples before triggering
TinyLSTM (future) Replace threshold logic with a trained time-series classifier for higher precision

The ELDORA roadmap targets a TinyLSTM model on ESP32 as the next detection layer for reduced false positives.


βš™οΈ Configuration

Update the following constants in FallDetection.ino before flashing:

// ── Hardware Pins ─────────────────────────────────────────
#define I2C_SDA    4   // MPU6050 I2C data
#define I2C_SCL    5   // MPU6050 I2C clock
#define BUZZER_PIN 3   // Active buzzer output

The fall detection threshold (15.0 m/sΒ²) and serial baud rate (115200) are set inline in the loop() and setup() functions respectively. Update them directly in FallDetection.ino to suit your hardware and deployment environment.


πŸš€ Build & Flash

Prerequisites

  • Arduino IDE 2.x with ESP32 board support installed
  • ESP32 board package URL: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

Required Libraries

Install via Arduino Library Manager (Sketch β†’ Include Library β†’ Manage Libraries):

Library Install Name Purpose
Wire (bundled with ESP32 core) I2C bus communication
Adafruit MPU6050 Adafruit MPU6050 IMU driver and I2C abstraction
Adafruit Unified Sensor Adafruit Unified Sensor Standardized sensor event interface

ℹ️ The Adafruit MPU6050 library depends on Adafruit Unified Sensor β€” the Library Manager will prompt you to install both.

Flash Steps

# 1. Clone the repository
git clone https://github.com/Eldoraaa/dorashield.git
cd dorashield

# 2. Open FallDetection.ino in Arduino IDE

# 3. Select board:
#    Tools β†’ Board β†’ ESP32 Arduino β†’ ESP32 Dev Module
#    (or the specific ESP32 variant you are using)

# 4. Update pin and threshold constants in FallDetection.ino

# 5. Connect ESP32 via USB, select the correct COM port

# 6. Upload
#    Sketch β†’ Upload  (or Ctrl+U)

# 7. Open Serial Monitor at 115200 baud to observe live sensor output

πŸ‘₯ Team

ELDORA β€” BINUS BM Team Passage to ASEAN Hackathon 2026

Name Role
Stanley Nathanael Wijaya Team Lead
Lutfi Alvaro Pratama IoT Engineer
Andrian Pratama Mobile Developer
Khalisa Amanda Sifa Ghaizani Backend Developer
Devon Nicholas AI Engineer

πŸ“§ Contact

Have questions, want to collaborate, or interested in ELDORA?

Channel Details
πŸ“§ Email stanley.n.wijaya7@gmail.com
✈️ Telegram @xstynwx
πŸ’¬ Discord stynw7

Hackathon BINUS


Made with 🀍 by BINUS BM Team πŸ”₯

About

DoraShield Fall Detection IOTπŸ“±

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages