An ESP32 reads your pulse from a MAX30102 (MAX3010x) sensor on your fingertip and lets an LED beat with your heart.
The repository holds two versions:
| Sketch | What it is |
|---|---|
SrceLedUI/SrceLedUI.ino |
Heart Lab (newest): heart rate, SpO2 estimate, HRV and breathing, shown on a web page the ESP32 serves to your phone. The LED beats in a soft heartbeat shape and keeps your rhythm after you lift your finger. |
MAX30105-Blinky-Heart.ino |
The first, simple version: LED only, no Wi-Fi. |
Educational, art and research project. Not for medical use.
| Part | Notes |
|---|---|
| ESP32 dev board | e.g. ESP32-DevKitC |
| MAX30102 / MAX30105 pulse sensor module | I2C |
| LED + resistor (about 220 Ω) | any colour |
| Sensor / LED | ESP32 |
|---|---|
| Sensor VCC | 3.3 V |
| Sensor GND | GND |
| Sensor SDA | GPIO 21 |
| Sensor SCL | GPIO 22 |
| LED + (through the resistor) | GPIO 4 |
| LED − | GND |
In the Arduino Library Manager: SparkFun MAX3010x Pulse and Proximity Sensor Library (it also brings heartRate.h).
Board: ESP32 Dev Module (ESP32 core by Espressif). Serial Monitor: 115200 baud.
Put your Wi-Fi in the sketch:
const char* WIFI_SSID = "YOUR_WIFI_NAME";
const char* WIFI_PASSWORD = "YOUR_WIFI_PASSWORD";After start the Serial Monitor shows the address. Open it in the phone's browser (same Wi-Fi):
http://<the IP address>(Android usually needs this)http://heartlab.local(works on a PC)
Without Wi-Fi (no connection within 15 s) the ESP32 opens its own network HeartLab (password heartlab123,
change AP_PASSWORD in the sketch). Connect the phone to it and open http://192.168.4.1.
| Value | How |
|---|---|
| Heart rate (BPM) | SparkFun beat detection on the IR signal; instant value and the average of the last 5 beats |
| SpO2 estimate | red / IR ratio over 3 s windows (rough approximation) |
| Pulse signal (PI) | perfusion index: pulsing part of the IR signal / its steady part; depends on finger pressure |
| HRV (RMSSD) | beat-to-beat variation over the last 30 beats |
| Breathing | slow wave in the IR signal, counted over up to 90 s; needs about 40 s of a still finger (rough) |
| Status | no sensor / no finger / measuring / searching / irregular / stable |
- Live: big BPM number with a beating heart, the values above, and the IR + red pulse waveform.
- Technical: red and IR LED strength, finger threshold, LED on / off, demo mode (simulated heartbeat and breathing, no sensor needed). Changes apply at once.
- Pulse: the whole screen glows in time with the heartbeat, in a colour you pick (with a warning first: not suitable for people with photosensitive epilepsy; a reduced-motion option makes it softer).
- English / Slovenian (SL / EN button).
Starts with the first finger and beats in a "lub-dub" shape: a soft first flash and a smaller second one. Its rhythm glides toward your average and is nudged into step with each real beat. When you lift your finger it keeps beating in your last rhythm. The phone screen uses the same timing as the LED.
WIFI_SSID, WIFI_PASSWORD, AP_SSID, AP_PASSWORD, MDNS_NAME, the pins (LED_PIN, SDA_PIN, SCL_PIN), and the
starting sensor values (redAmp, irAmp, fingerThreshold; these can also be changed live on the Technical page).
No Wi-Fi, LED only:
- On every beat the LED flashes and fades out over 300 ms.
- The blink rate follows the average of the last 4 beats, updated every 5 seconds, so it changes smoothly.
- With no finger on the sensor (IR below 50000) and no rhythm yet, the LED stays off.
- The Serial Monitor (115200 baud) shows the IR value and the smoothed BPM (comments and messages are in Slovenian).
Upload, put a finger gently but firmly on the sensor, and after a few seconds the LED starts beating with you.