Skip to content

Marcobisky/CNN-for-mbed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Wearable Health Device for Body Temperature Monitoring and Fall Detection

This repository contains the source code, implementation details, and documentation for a Wearable Health Device (WHD) that monitors body temperature and detects falling events. The system is designed using an STM32 Nucleo-L432KC microcontroller and employs machine learning (CNN) for accurate fall detection. This project is my final Embedded System Design course assignment.


๐Ÿ“Œ Features

  • Body Temperature Monitoring ๐ŸŒก๏ธ using the TMP102 sensor.
  • Fall Detection ๐Ÿƒ using the ADXL345 accelerometer.
  • LED and Buzzer Alerts ๐Ÿšจ for abnormal temperature or falls.
  • Machine Learning with CNN ๐Ÿง  to improve detection accuracy.
  • Real-Time Data Visualization ๐Ÿ“Š via serial communication.

๐Ÿš€ Getting Started

1๏ธโƒฃ Prerequisites

  • Hardware

    • STM32 Nucleo-L432KC
    • TMP102 Temperature Sensor
    • ADXL345 Accelerometer
    • 9 LEDs & Passive Buzzer
    • Breadboard and Jumper Wires
  • Software & Libraries

    • PlatformIO (for STM32 development)
    • Mbed OS Library
    • Python 3.10 (for visualization)
    • torch, matplotlib, pyserial (for CNN training & visualization & Print information)

2๏ธโƒฃ Folder Description

  • Project/: Source code to download into L432KC.
  • Epoch_size_study/: Experiment files for finding the best epoch size.
  • History/: Test files, just omitted.

๐Ÿ—๏ธ System Architecture

Hardware & Sensor Connection

System Block Diagram

The device consists of three main modules:

  1. Temperature Sensor Module ๐ŸŒก๏ธ (TMP102)
  2. Fall Detection Module ๐Ÿƒ (ADXL345 Accelerometer)
  3. Alert & Communication Module ๐Ÿ“ข (LEDs & Buzzer)

TMP102 Sensor Register Structure

TMP102 Register Structure

ADXL345 Functional Overview

ADXL345 Functional Diagram


๐Ÿ“Š Machine Learning - CNN Model for Fall Detection

๐Ÿ“Œ Why CNN for Fall Detection?

  • Traditional threshold-based methods are unreliable.
  • CNN learns complex patterns in acceleration data.
  • Provides higher accuracy in real-world scenarios.

๐Ÿ“œ CNN Architecture

CNN Model Visualization

  • Input: Acceleration data in $x$, $y$, $z$ axes (over 5-time steps).
  • Layers: Convolutional, MaxPooling, Fully Connected.
  • Output: Probability of a fall event.

๐Ÿ“ˆ Model Training & Performance

  • Dataset: 167 manually labeled samples.
  • Epoch Selection: 750 epochs found optimal.
  • Accuracy: 76.9% for normal falls, 90% for slow falls.

Validation Loss Over Different Epochs

Epoch 50 Epoch 100 Epoch 250 Epoch 400 Epoch 500 Epoch 750


๐ŸŽ›๏ธ Real-Time Data Visualization

The device supports real-time monitoring of temperature and acceleration data.

Accelerometer Data - Before and After Max Acceleration Processing

Without Max Acceleration With Max Acceleration

Real-Time Temperature and Fall Detection

python visualization.py

This will open a live plot showing:

  • Temperature changes over time.
  • Detected fall events.
  • System status updates.

๐Ÿ” Results & Discussion

โœ… Fall Detection Accuracy

Scenario Total Falls Correct Detections False Positives Success Rate
Normal Falling 30 30 9 100%
Slow Falling 22 9 1 40.9%

Accelerometer-Based Fall Detection Results

Accuracy Result 1 Accuracy Result 2 Accuracy Result 3

โœ… Temperature Monitoring

Temperature (ยฐC) LED Status Alert
35.5 - 36.5 Normal โŒ
37.0 - 38.3 Warning โš ๏ธ
38.5 - 42.0 Danger ๐Ÿšจ

Temperature-Based Alerts

Temperature Result 1 Temperature Result 2 Temperature Result 3

LED Status Under Different Conditions

LED 27.2ยฐC LED 33ยฐC LED 28ยฐC LED 30ยฐC


๐Ÿ”ฎ Future Improvements

  • Improve CNN accuracy using more training data.
  • Reduce false positives by tuning model parameters.
  • Implement wireless communication (Bluetooth/WiFi).
  • Enhance power efficiency for prolonged battery life.

๐Ÿ“œ References


๐Ÿ“ฌ Contact

๐Ÿ“ง Email: marcobisky@outlook.com
๐Ÿ”— GitHub: github.com/marcobisky

About

This project is my Embedded System Design assignment (Patient CareGuard). MCU: STM32 Nucleo-L432KC, library: Mbed, IDE: Platformio, Module used: TMP102, ADXL345.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors