Skip to content

RashadHummatov85/breathing-biofeedback

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Force-Sensing Biofeedback System for Guided Breathing

A senior design project that combines embedded hardware, real-time ML classification, and a desktop GUI to guide users through breathing exercises using live pressure feedback.


Overview

This system reads pressure data from a force-sensing resistor worn against the body during breathing. The signal is sampled by an Arduino via USB serial, classified by a Random Forest model in real-time, and visualized in a PyQt6 desktop application — giving users immediate feedback on their breathing pattern.


System Architecture

[FlexiForce A201 Sensor]
        │
        ▼
  [Arduino UNO]  ──── USB Serial ────►  [Python Backend]
   ADC sampling                          │
   Serial TX                             ├── Random Forest Classifier
                                         │     (breathing phase detection)
                                         │
                                         └── PyQt6 GUI
                                               ├── Live waveform plot
                                               └── Guided breathing visual

Features

  • Real-time pressure signal acquisition via FlexiForce A201 + Arduino UNO
  • USB serial communication between Arduino and PC
  • Random Forest ML model for breathing phase classification
  • PyQt6 desktop GUI with live waveform and breathing guidance animation
  • Modular codebase — hardware, ML, and GUI are decoupled

Hardware Requirements

Component Details
Arduino UNO Microcontroller for ADC and serial TX
FlexiForce A201 Thin-film pressure sensor
10kΩ resistor Pull-down for voltage divider
47µF capacitor Signal smoothing

Circuit Diagram

image

The FlexiForce sensor is connected to Arduino pin A0 via a 10kΩ pull-down resistor and a 47µF smoothing capacitor, powered from the 5V and GND pins.


Software Requirements

  • Python 3.9+
  • PyQt6
  • scikit-learn
  • numpy
  • pyserial
  • matplotlib (for waveform rendering)

Install dependencies:

pip install -r requirements.txt

Getting Started

  1. Flash the Arduino sketch

    Open firmware/sdp_firmware.ino in the Arduino IDE and upload to your UNO.

  2. Connect the Arduino via USB

    Plug into your PC and note the assigned COM port (Windows) or /dev/ttyXX (Linux/macOS).

  3. Configure the serial port

    Update the PORT variable in config.py:

    PORT = "COM5"  # or "/dev/ttyUSB0" on Linux
  4. Run the application

    python main.py

Project Structure

SDP/
├── firmware/
│   └── sdp_firmware.ino       # Arduino sketch
├── ml/
│   ├── train.py               # Model training script
│   ├── model.pkl              # Trained Random Forest model
│   └── data/                  # Training data (pressure readings + labels)
├── gui/
│   ├── main_window.py         # PyQt6 main window
│   └── breathing_widget.py    # Guided breathing animation
├── config.py                  # Serial port and app settings
├── main.py                    # Entry point
├── requirements.txt
└── README.md

ML Model

The Random Forest classifier was trained on labeled pressure sequences to detect distinct breathing phases (inhale, exhale, hold). Features are extracted from sliding windows of raw ADC readings.

To retrain the model on your own data:

python ml/train.py --data ml/data/

Demo

Adsız tasarım Adsız tasarım (1)

The dashboard shows real-time breathing metrics — breathing rate, I:E ratio, tidal volume, variability, and apnea detection — along with a live feedback message and the ML model's classified pattern with confidence score.


Author

Rashad Hummatov
Computer Engineering, ADA University — Class of 2026
LinkedIn · GitHub


Releases

No releases published

Packages

 
 
 

Contributors