An edge-computing biosensor system built on a Raspberry Pi Zero 2W. This system handles real-time I2C data polling, signal processing, and local Long Short-Term Memory (LSTM) neural network inference to predict and analyze Heart Rate Variability (HRV).
The 3D-printed enclosure featuring the MAX30102 PPG/SpO2 sensor.
This project bridges physical hardware sensors with edge AI inference, operating entirely on a constrained ARM architecture.
- 🧠 Compute Node: Raspberry Pi Zero 2W.
- 📡 Sensors: MAX30102 (PPG/SpO2) via I2C, BioAmp EXG Pill (ECG) via Arduino Nano ADC buffer.
- 🖥️ Display & UI: 0.96" I2C OLED display with hardware-debounced GPIO interrupts.
- 🤖 AI Engine: TensorFlow LSTM sequence prediction for RR-interval forecasting and HRV time-domain metric extraction (SDNN, RMSSD).
Internal layout showing the Pi Zero 2W, OLED display, BioAmp EXG Pill, and physical UI switches.
Key Connections (Pi Zero 2W):
-
I2C Bus (OLED & MAX30102):
SDA$\rightarrow$ GPIO 2|SCL$\rightarrow$ GPIO 3 -
UI Buttons:
UP(GPIO 17),DOWN(GPIO 26),SELECT(GPIO 22),MENU(GPIO 10) - ECG Interface: Serial parsing via connected Arduino Nano handling the BioAmp EXG Pill analog outputs.
Full system wiring diagram generated in EasyEDA.
To prevent the I2C polling loop from bottlenecking the GUI, the system utilizes isolated threading:
- 📊 Sensor Thread (
heartrate_monitor.py): Continuously fills a 100-sample buffer at 25Hz. - 🧮 DSP Pipeline (
hrcalc.py): Applies a 4-point moving average filter, removes DC shift, and calculates local maxima/minima for SpO2 calibration. - 🎛️ Main Thread (
main.py): Handles OLED screen rendering, GPIO state machines, and synchronized data logging via threading locks.
1. Clone and Install Dependencies:
git clone <https://github.com/Anu13lol/Real-Time-AI-Biosensor>
cd <repo-folder>
pip3 install -r requirements.txt