Skip to content

heitorctm/PROJ-fall_prevention-AI_training

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elderly Fall Prevention: AIoT System

2nd place at the ABINC IoT Award 2025 (Universities category), announced at Futurecom 2025 in São Paulo. Full coverage at UNIFOR

Real-time fall detection system based on weight sensors and artificial neural networks, developed at the VORTEX laboratory of Tec Unifor (Universidade de Fortaleza). The project originated from the dissertation of Marcela Bezerra Lima Deodato in the Professional Master's in Technology and Innovation in Nursing (MPTIE), with interdisciplinary development following the MIDTs methodology.

Falls in elderly people represent the second leading cause of death from unintentional injuries worldwide. The approach uses four load cells installed under the bed legs to monitor the occupant's weight distribution. A neural network model embedded in the ESP32 microcontroller classifies the user's position in real time and triggers an audible alarm when a fall is detected, with no need for wearables.


System Overview

┌─────────────────────────────────────────────────────────────────┐
│                        PHASE 1: DATA COLLECTION                 │
│   4x Load Cells (HX711) → ESP32 → Serial → CSV                 │
│               (coletar-dadosR02.ino)                            │
└───────────────────────────┬─────────────────────────────────────┘
                            │ dados_analisado.csv
┌───────────────────────────▼─────────────────────────────────────┐
│                        PHASE 2: TRAINING                        │
│   Preprocessing → MLP + comparative algorithms → Weights        │
│               (quedas-R02.ipynb)                                 │
└───────────────────────────┬─────────────────────────────────────┘
                            │ weights1.h / weights2.h / weights3.h
┌───────────────────────────▼─────────────────────────────────────┐
│                       PHASE 3: INFERENCE                        │
│   4x Load Cells → ESP32 (embedded MLP) → MP3 Alarm             │
│               (firmware_esp32.ino)                               │
└─────────────────────────────────────────────────────────────────┘

Hardware

Component Qty Connection (ESP32 GPIO)
HX711 Module + Load Cell 4 A: DT=13, SCK=12 · B: DT=14, SCK=27 · C: DT=26, SCK=25 · D: DT=33, SCK=32
JQ6500 MP3 Module 1 RX=16, TX=17
ESP32 1

The four load cells are installed under the bed legs, one at each corner. The sum of readings and the distribution across A/B/C/D determine the occupant's position and state.


Position Classes (12 states)

Index Description Safe
0 Out of bed
1 Side BC0
2 Sitting at D
3 Side AD0
4 Side BC1
5 Lying in the middle
6 Diagonal BD
7 Side AD1
8 Sitting in the middle
9 Sitting at C
10 Diagonal AC
11 Detecting fall

Neural Network Architecture

The MLP trained in the notebook and embedded in the firmware has the following architecture:

Input (4)  →  Dense 1024 (ReLU)  →  Dense 200 (ReLU)  →  Output 12 (Softmax)

Training hyperparameters:

  • Optimizer: Adam (lr = 0.0005)
  • Loss: Categorical Cross-Entropy
  • Epochs: 50 · Batch: 5000
  • Cross-validation: K-Fold (k=5)
  • Regularization: ReduceLROnPlateau

Results: Model Comparison

Evaluated on 2 held-out test volunteers (unseen during training):

Model Accuracy Precision Recall F1-Score
Decision Tree 77.34% 81.30% 81.74% 80.44%
Random Forest 83.71% 92.41% 86.83% 88.53%
K-Nearest Neighbors 87.26% 89.30% 89.75% 89.20%
Naive Bayes 87.39% 89.83% 89.59% 89.43%
MLP (Neural Network) 95.11% 96.02% 96.54% 96.21%

The MLP significantly outperforms all other algorithms, with a gain of approximately 8 percentage points over the second best (KNN/Naive Bayes).


Repository Structure

PROJ-00-prevencao_de_quedas/
├── coletar-dadosR02.ino    # Data collection firmware (ESP32)
├── firmware_esp32.ino      # Real-time inference firmware (ESP32)
├── quedas-R02.ipynb        # Notebook: preprocessing, training and comparison
├── dados_analisado.csv     # Dataset with readings from 14+ volunteers (~19 MB)
└── README.md

Note: the files weights1.h, weights2.h and weights3.h containing the trained network weights are generated by the notebook and must be added to the Arduino project folder before compiling the firmware.


Installation and Usage

Python Requirements

pip install numpy pandas tensorflow scikit-learn matplotlib

Jupyter Notebook (training and analysis)

jupyter notebook quedas-R02.ipynb

The notebook runs in order:

  1. Data anonymization and cleaning (outlier removal via IQR)
  2. One-hot encoding of position classes
  3. MLP training with K-Fold and weight export
  4. Comparison with Decision Tree, Random Forest, KNN and Naive Bayes
  5. Metrics and confusion matrix generation

ESP32 Firmware

Arduino dependencies:

  • HX711 (load cell readings)
  • BluetoothSerial (wireless monitoring)
  • JQ6500_Serial (MP3 alarm)

To compile:

  1. Generate the weight files by running the notebook completely
  2. Copy weights1.h, weights2.h, weights3.h to the sketch folder
  3. Compile and flash firmware_esp32.ino to the ESP32 board

To collect new data:

  • Use coletar-dadosR02.ino and monitor the serial output (format: line/A/B/C/D/SUM/command)
  • Available serial commands: pause, reboot, zero (tare)

Team

Name Role
Marcela Bezerra Lima Deodato Lead researcher (MPTIE master's student)
Heitor de Castro Teixeira Development (Computer Science graduate)
Joel Sotero da Cunha Neto Coordinator

Developed at the VORTEX Laboratory of Tec Unifor, institution maintained by Fundação Edson Queiroz, with MIDTs interdisciplinary methodology.


License

Property of the VORTEX Laboratory, Universidade de Fortaleza (UNIFOR).

Contact

About

The project originated from the dissertation of Marcela Bezerra Lima Deodato, a student of the Professional Master's in Technology and Innovation in Nursing (MPTIE) at Unifor, an institution maintained by Fundação Edson Queiroz, in partnership with VORTEX, a laboratory that is part of Tec Unifor, the Technology Park of Universidade de Fortaleza.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors