G14: Human stress support system using ECG - shalan/CSCE4301-WiKi GitHub Wiki
Project Title: Human stress support system using ECG
| Name | GitHub |
|---|---|
| Ismaiel Sabet | IsmaielSemo |
| Islam Abdeen | Islamauc |
| Shaza Ali | ShazaAli |
Github Repo: https://github.com/
1. The Proposal
Abstract / Elevator Pitch
Stress is one of the most pervasive health challenges in academic and professional environments, yet it remains entirely invisible to the surrounding system. Most people only recognize they are stressed after the fact that performance has already degraded or focus has slipped.
This project presents a wearable, real-time stress detection system that monitors a user's electrocardiogram (ECG) signal to identify physiological stress and respond with guided biofeedback. The system captures cardiac electrical activity through the ECG sensor, digitizes it, and applies signal processing algorithms to extract heart rate variability (HRV) features correlated with stress.
The system was built to demonstrate a low-power, low-cost embedded health-monitoring pipeline that bridges biosignal acquisition, real-time DSP, behavioral feedback, and wireless communication, all running on a single microcontroller with BLE event logging to a smartphone terminal.
Project Objectives & Scope
Minimum Viable Product (MVP)
- Acquire a clean ECG signal from the AD8232 electrodes attached to the user
- Sample the analog ECG signal through the ADC on pin PA0 of the STM32L432KC
- Apply DCP signal processing to detect stress indicators from the raw waveform
- Implement system control logic: if stressed → enable Breathing Mode; else → Monitor
- Drive a breathing guide LED (PB3) with a dimming/pulsing pattern when stress is detected
- Transmit event logs wirelessly via BLE Bluetooth Module over UART (PA2) to a smartphone terminal
Stretch Goals
- Implement adaptive thresholding for stress detection to personalize sensitivity per user
- Add historical HRV trending and session summaries over BLE
- Develop a dedicated mobile app (beyond a serial terminal) for data visualization
- Implement low-power sleep modes between ADC samples to extend battery life
- Add SD card or flash logging for offline session data storage
2. System Architecture
2.1 High-Level Block Diagram:
2.2 Subsystem Breakdown
1. AD8232 ECG Electrodes (Input — Analog Front End)
The AD8232 is a single-lead ECG signal conditioning module. It filters, amplifies, and buffers the millivolt-level differential signal from electrodes placed on the user's body, outputting a clean analog voltage suitable for ADC conversion. This is the physical entry point for all biometric data in the system.
2. Analog-to-Digital Converter — PA0 (Capture & Convert)
The STM32L432KC's onboard 12-bit ADC, configured on pin PA0, samples the conditioned ECG analog voltage at a sufficient rate (typically 250–500 Hz) to capture cardiac waveform features. The digitized samples are fed directly into the signal processing pipeline.
3. DCP: ECG Signal Processing (Detect Stress)
This software module implements the core DSP logic — including filtering, R-peak detection, RR-interval extraction, and HRV-based stress classification. It operates on the ADC sample stream and outputs a binary or scaled stress indicator to the System Control Logic.
4. System Control Logic (Decision & Coordination)
Acting as the system's central state machine, this module interprets the stress classification output and routes behavior accordingly:
- If Stressed → activates Breathing Guide mode (LED dimming pattern via PB3)
- Else → remains in passive Monitor mode It also packages event data and dispatches them over UART (PA2) to the BLE module.
5. Bluetooth Module — BLE (Wireless Output)
A BLE peripheral module receives UART event logs from the STM32 on PA2 and broadcasts them wirelessly to a paired smartphone. This allows clinicians, researchers, or the user themselves to observe real-time stress events and mode transitions.
6. Breathing Guide LED — PB3 (Biofeedback Output)
A PWM-driven LED connected to PB3 produces a smooth dimming/brightening pattern that guides the user through a regulated breathing cycle (e.g., 4s inhale / 4s exhale). This serves as the primary real-time intervention when stress is detected.
7. Smartphone Terminal (User-Facing Output)
A generic BLE serial terminal app on the smartphone displays event logs streamed from the system, including stress detection events, mode transitions, and session metadata — providing human-readable visibility into system state.
Component Selection:
Schematics & Wiring:
Circuit diagrams, pinout tables, and breadboard layouts.
Bill of Materials (BOM):
A table listing component names, part numbers, quantities, costs, and links to datasheets.
Power Budget:
Calculations ensuring your power supply can handle the peak current draw of all components combined.
4. Software Implementation
4.1 Software Architecture:
Description of the firmware design (e.g., Bare-metal Superloop, Interrupt-driven, or RTOS).
4.2 Flowcharts & State Machines:
Visual diagrams mapping out the core logic, state transitions, and interrupt service routines (ISRs).
4.3 Key Algorithms:
Explanations of any complex logic used (e.g., PID control loops, digital filtering, sensor fusion).
4.4 Development Environment:
Compilers, IDEs, and toolchains used (e.g., Keil, PlatformIO, STM32CubeIDE).
5. Testing, Validation & Debugging
5.1 Unit Testing:
How individual hardware components and software functions were tested in isolation.
5.2 Integration Testing:
How the system was tested as a whole.
5.3 Challenges & Solutions:
A log of major bugs, hardware failures, or design flaws you encountered, and the engineering steps you took to solve them.
6. Results & Demonstration
6.1 Final Prototype:
High-quality photos of the completed build.
6.2 Video Demonstration:
A link to a short video showing the system working in real-time under various conditions.
6.3 Performance Metrics:
Data showing how well the project met its initial objectives (e.g., "Response time was measured at 12ms, well within our 50ms goal").
7. Project Management (ToDo)
7.1 Division of Labor
| Team Member | Responsibilities |
|---|---|
| Ismaiel Sabet | Hardware setup: AD8232 wiring, electrode interfacing, ADC configuration on PA0, power supply regulation, PCB/breadboard layout |
| Shaza Ali | Firmware & DSP: ECG signal processing algorithm (DCP, R-peak detection, HRV stress classification), System Control Logic state machine, PWM LED breathing pattern (PB3) |
| Islam Abdeen | Wireless & Integration: BLE UART communication (PA2), smartphone terminal setup, system integration testing, documentation and demo preparation |
Note: All members are jointly responsible for system-level debugging, final integration testing, and project presentation.
7.2 Timeline
Milestone List
| Milestone | Planned Date |
|---|---|
| M1 — component procurement | Week 1 |
| M2 — Hardware assembly: AD8232 + STM32 wiring | Week 2 |
| M3 — DSP module: R-peak detection working | Week 2 |
| M4 — Stress classification logic tested | Week 3 |
| M5 — LED breathing pattern implemented (PB3 PWM) | Week 3 |
| M6 — BLE UART event logging to smartphone terminal | Week 4 |
| M7 — Full system integration & end-to-end test | Week 4 |
| M8 — Final demo & documentation submission | Week 5 |
8. Appendices & References
8.1 Source Code Repository:
Link to your GitHub/GitLab repo.
8.2 References:
Links to datasheets, tutorials, academic papers, and course materials used during development.