A Real Time Smart Physiological Stress Monitoring System

Published Jun 12, 2026
 20 hours to build
 Intermediate

A real-time, end-to-end IoT and Machine Learning pipeline that detects human stress levels using physiological data. This project reads continuous electrocardiogram (ECG) and photoplethysmography (PPG) data on an ESP32 edge device, batches the high-frequency data, and transmits it to a Flask server. It uses a Machine Learning model to predict "Stress" or "No Stress." A React frontend provides a responsive, real-time medical dashboard.

display image

Components Used

ESP32 WROOM
WiFi Development Tools - 802.11 ESP32 General Development Kit, embeds ESP32-WROOM-32E, 4MB flash.
1
MAX30102 Pulse Oximeter and Heart-Rate Sensor
MAX30102 is an integrated pulse oximetry and heart-rate monitor sensor solution.
1
Breadboard
Breadboard
1
Connecting Wire Jumper Wires
Connecting Wire Breadboard wires
15
ECG Electrodes
Biometric Sensors Disposable Surface EMG/ECG/EKG Electrode - 24mm (10 pack)
3
ECG Sensor Module (AD8232 or ADS1292R)
For capturing ECG signals
1
Description

 

In this project, we are building an end-to-end clinical-grade IoT biometric monitor. We will use an ESP32 to capture raw electrocardiogram (ECG) and photoplethysmography (PPG) data, send it over Wi-Fi to a Python Flask backend, process 19 Heart Rate Variability (HRV) metrics, and use a Machine Learning ensemble to predict "Stress" or "No Stress" in real-time on a beautiful React.js dashboard.

 

The Vision & Social Impact:

  • Chronic stress and workplace burnout represent a modern silent epidemic, directly contributing to cardiovascular diseases and mental health crises.
  • Traditional assessment relies on subjective, retrospective questionnaires prone to human bias. Our system introduces a paradigm shift in behavioral health by creating an objective, continuous, and completely non-invasive stress tracking pipeline.
  • By providing instantaneous physiological feedback, users can actively modify their behavior, practice real-time down-regulation techniques, and manage their well-being before a physical crisis occurs. 
  • This project shifts healthcare from reactive treatment to proactive, data-driven self-awareness.

     

Commercialization & Productization Prospects:

This architecture is custom-built for high scalability and seamless transition into an entrepreneurship program.

  • Corporate Wellness SaaS: The React dashboard can scale into a multi-user corporate portal where enterprises monitor anonymous, aggregated workforce stress levels to optimize workplace environments.
  • Wearable Integration: The entire hardware footprints of the ESP32, AD8232, and MAX30102 can easily be miniaturized onto a single custom PCB, fitting into a lightweight chest strap or smartwatch prototype.
  • B2B Licensing: The signal processing algorithm that converts raw values to 19 HRV metrics on a Flask server can be packaged as an API and licensed to existing health-tech applications.

     

Technology Practicality & Cost-Efficiency:

  • Clinical ECG diagnostic equipment costs thousands of dollars and requires complex hospital setups.
  • Our solution proves that high-performance medicine can be democratized
  • Built entirely from off-the-shelf, low-cost commodity hardware totaling under $20, this system provides near-clinical observation accuracy at a fraction of the price, making continuous health tracking accessible to low-income populations and developing medical infrastructures.

     

Technical Architecture & Deep Design Detail:

The pipeline is engineered to extract clinical-grade biological markers on low-cost hardware through a three-tier architecture: 

  1. The Edge Layer (MicroPython/ESP32): To prevent data loss during high-frequency sampling (~200Hz for ECG), we implemented an asynchronous dual-core threading architecture. Core 1 is dedicated entirely to precise sensor polling, while Core 0 handles Wi-Fi batching and network transmission.
  2. The Computational Brain (Flask/Python): Raw bio-signals are prone to motion artifacts. The backend applies digital bandpass filtering to isolate R-peaks cleanly. Instead of calculating basic heart rate, the system evaluates a moving 60-second sliding window to extract 19 distinct time-domain and frequency-domain Heart Rate Variability (HRV) metrics.
  3. The Ensemble Predictor: Rather than relying on a single classifier, we deployed a pre-trained Ensemble Machine Learning framework (trained on WESAD). This mitigates individual model biases, resulting in robust, reliable classifications ("Healthy", "Stressed") pushed to a React.js dashboard via WebSockets.

 

Components List:

Component NameQuantityPurpose
ESP32 Dev Board1Acts as the Edge AI node. Reads sensor data and transmits payloads over Wi-Fi via HTTP POST.
MAX30102 Module1Optical sensor used to calculate live heart rate (BPM) and blood oxygenation (SpO2).
AD8232 Module1Amplifies and filters the micro-electrical signals of the heart to provide an ECG waveform.
ECG Electrodes3Disposable pads attached to the user's skin to pick up cardiac electrical activity.
Breadboard & Wires1Used to route 3.3V power and establish a common ground for the sensor network.
All components used in the project with there purpose

 

Software Stack: 

  • Micro-Python (Thonny)
  • Python 3
  • Flask
  • Scikit-learn
  • React.js
  • Socket.io-client.

     

Circuit Connections:

ComponentPinConnected To (ESP32)
MAX30102VCC / VIN3.3V
MAX30102GNDGND
MAX30102SDAGPIO 21
MAX30102SCLGPIO 22
AD82323.3V3.3V
AD8232GNDGND
AD8232OUTPUTGPIO 36 (VP / ADC0)
AD8232LO+GPIO 32
AD8232LO-GPIO 33
Entire pin connection of all components

 

Implementation:

  1. Wire the Hardware: Connect the sensors to the ESP32 following the pinout table above. Ensure a common ground.
  2. Flash the Edge Device: Upload the MicroPython firmware to the ESP32 using Thonny IDE.
  3. Start the Brain: Run the Python Flask backend. It will begin listening on Port 5000 for the ESP32's TCP packets.
  4. Launch the UI: Start the React.js development server to initialize the WebSocket connection with Flask.
  5. Calibrate: Attach the ECG electrodes, place your finger on the MAX30102, and wait 60 seconds for the sliding window to fill and generate the first ML prediction.

 

Edge Programming:

  • Reads the analog voltage from the AD8232.
  • Rapidly polls the MAX30102 without blocking, checking for optical peaks to calculate BPM and SpO2.
  • Batches this data and transmits it via HTTP POST exactly once every 5 seconds.

 

Machine Learning Inference:

  • Sliding Window: It appends the live data into a 60-second rolling buffer.
  • Signal Processing: It applies bandpass filters to the raw waveform, detects precise R-peaks, and computes 19 clinical Heart Rate Variability (HRV) metrics (like RMSSD, LF/HF ratio).
  • Ensemble Machine Learning: It feeds these 19 metrics into a pre-trained Scikit-Learn Machine Learning pipeline (trained on the WESAD dataset) to instantly classify the data as "Healthy" or "Depressed."

 

Medical Dashboard:

  • Sweeping line charts for ECG and optical pulse waveforms.
  • Large metric cards for live BPM and Blood Oxygenation (SpO2).
  • A dynamic UI status ring that glows Green for Healthy or Red for Stress based on the ML confidence score.

 

Testing and Demonstration:

  • Attach the three AD8232 biomedical pads to your chest/arms.
  • Place your index finger gently on the red glowing LED of the MAX30102.
  • Start your Flask server and React app.
  • Power up the ESP32.

     

Video:

Conclusion:

To conclude, by combining the raw hardware capabilities of the ESP32, the fast prototyping of MicroPython, and the predictive power of ensemble Machine Learning, we have created an open-source, edge-to-cloud biometric monitor. This architecture can be easily adapted for sports science, sleep studies, or personal mental health tracking.

 

Code: https://github.com/kathan-majithia/Smart_Physiological_Monitoring_System

Codes

Downloads

eproject Download
circuit Download

Institute / Organization

The Charutar Vidya Mandal University
Comments
Ad