Inspiration

It's Valentine's Day — so we asked ourselves: what if you could actually measure love? The idea was simple — place a heart rate sensor on your valentine and watch their BPM spike when they see you. That heartbeat jump? That's love. We wanted to build a full end-to-end system that captures that moment in real time, from a raw analog pulse signal all the way to a live web dashboard.

What it does

HeartSense is a real-time vital signs monitor built on a Raspberry Pi. A pulse sensor reads your heartbeat through an ADS1115 ADC over I2C, sampling at 10 Hz. A K-type thermocouple (MCP9600) reads body temperature. The raw signal goes through a full Python DSP pipeline — outlier removal via median absolute deviation, a 4th-order Butterworth bandpass filter (0.5–3.5 Hz), and peak detection — to produce a clean, live BPM reading. The data streams over WebSockets to a React dashboard that displays BPM with color-coded zones (blue = low, green = normal, amber = elevated, red = high), temperature, and three real-time scrolling charts (pulse delta, cumulative signal, and temperature) updating 10 times per second.

How we built it

Hardware: Raspberry Pi with a pulse sensor connected through an ADS1115 16-bit ADC and a K-type thermocouple through an MCP9600 amplifier, both communicating over I2C/SMBus.

Backend: Python with NumPy and SciPy for signal processing. We read raw 16-bit 2's complement values from the ADC, handle byte-swapping, remove spike outliers using MAD-based detection with interpolation, apply a zero-phase Butterworth bandpass filter, and run peak detection with minimum-distance enforcement to calculate BPM. A Flask server with Flask-SocketIO streams sensor data to the frontend in real time.

Frontend: React + TypeScript app built with Vite, using Recharts for the real-time scrolling charts and socket.io-client for the WebSocket connection. BPM is color-coded into heart rate zones.

Simulation mode: We also built a full simulation mode so the project can be demoed anywhere without the physical hardware.

Challenges we ran into

  • I2C byte ordering: The ADS1115 returns big-endian data but the Raspberry Pi reads little-endian — we had to manually swap bytes and handle 2's complement conversion at the register level.
  • Noisy analog signals: The raw pulse output is extremely noisy. You can't just read it and call it BPM. We had to build a multi-stage processing pipeline with MAD-based spike removal and Butterworth bandpass tuning to get a usable signal.
  • Real-time at 10 Hz: Reading, processing, emitting, and rendering all within 100ms per cycle required careful threading and pipeline design.
  • Hardware debugging without an oscilloscope: We relied on printed values and matplotlib plots to diagnose sensor issues. We also spent time debugging an IR LED that turned out to be working — we just couldn't see infrared light (verified with a phone camera).
  • Temperature integration: We wrote the driver code to fully integrate the thermocouple signal into the pipeline, but ran into integration issues during the build and couldn't get that part running end-to-end in time.

Accomplishments that we're proud of

  • Built a true end-to-end system: raw analog electrical signals → real signal processing → polished live web dashboard.
  • Implemented real DSP — Butterworth filters, peak detection, motion artifact removal — not just reading a pre-processed sensor value.
  • Achieved sub-second latency from a physical heartbeat to an on-screen BPM update.
  • Built a simulation mode so the entire system is fully demo-able anywhere, with or without hardware.

What we learned

  • ADC at the register level: I2C communication, SMBus protocols, 2's complement encoding, byte swapping, and FSR configuration — all from reading datasheets at 1 AM over pizza.
  • DSP fundamentals: Bandpass filtering, FFT, peak detection, signal detrending, and why raw sensor data always needs multiple cleaning stages.
  • Hardware-to-web bridging: How to go from a Python script on a Raspberry Pi to a React/TypeScript frontend via WebSocket streaming with minimal latency.
  • Analog sensor debugging: Practical skills like verifying IR LEDs with phone cameras, using matplotlib as a poor man's oscilloscope, and soldering LEDs onto sensors.

What's next for HeartSense

  • Anomaly detection: Screen for irregular heartbeat patterns like arrhythmia.
  • Data logging: Store readings to a database for trend review over hours or days.
  • Mobile app: Adapt the React frontend to React Native for phone-based monitoring.
  • More sensors: Add SpO2 (blood oxygen) and ECG for complete vital signs coverage.
  • Cloud streaming: Enable remote monitoring for healthcare providers.

Built With

Share this project:

Updates