How to Build a Fitness Wristband Prototype with ESP32
Heart-rate sampling, step estimation, and low-power OLED display
Updated

What you'll build
This guide takes you through building a fitness wristband prototype using an ESP32, a MAX30102 pulse oximetry and heart-rate sensor, an MPU6050 accelerometer and gyroscope, and a 0.96-inch OLED display. The wristband samples heart-rate data by shining red and infrared LEDs through your fingertip or wrist, detects steps using a peak-detection algorithm on the accelerometer's Z-axis, and presents both metrics on a crisp OLED screen that cycles between a live heart-rate graph, a daily step count, and a simple clock face. A single button toggles between display modes and puts the device into deep sleep to conserve battery.
Wearable health technology is one of the fastest-growing segments in consumer electronics, and this project gives you direct experience with the core challenges: reading clean biometric signals from noisy analog sensors, fusing data from multiple I2C peripherals on the same bus, and managing power consumption so the device can run for hours on a small LiPo cell. You will implement a moving-average filter to smooth the raw photoplethysmography signal from the MAX30102, write a step-detection algorithm that distinguishes walking from random arm movement, and configure the ESP32's deep-sleep wake-up sources to balance responsiveness against battery life.
By the end of the build you will own a functioning wristband that tracks heart rate and steps, displays the data in real time, and sleeps intelligently when not in use. The firmware is structured so you can easily add Bluetooth Low Energy broadcasting to stream data to a companion phone app, integrate a skin-temperature reading from the MAX30102's built-in die temperature register, or add sedentary-reminder vibrations with a small motor. This project is a practical entry point into the world of wearable IoT and embedded health monitoring. The MPU6050 accelerometer used here also appears in the self-balancing rover, where it drives a PID control loop instead of counting steps.
Wiring diagram
Wiring diagram
Components needed
Assembly
Connect health sensors on I2C
Wire MAX30102, MPU6050, and OLED to SDA GPIO21 and SCL GPIO22.
- Stack sensors on one I2C bus to minimize wearable wiring.
Add haptic alert output
Drive the vibration motor using GPIO25 through a transistor stage.
- Use a transistor and flyback protection for motor spikes.
- Do not source vibration motor current directly from ESP32 GPIO.
Pin assignments
| Pin | Connection | Type |
|---|---|---|
| GPIO 21 | max30102-1 SDA | I2C |
| GPIO 22 | max30102-1 SCL | I2C |
| GPIO 19 | max30102-1 INT | DIGITAL |
| GPIO 21 | wearable-imu-1 SDA | I2C |
| GPIO 22 | wearable-imu-1 SCL | I2C |
| GPIO 21 | wearable-oled-1 SDA | I2C |
| GPIO 22 | wearable-oled-1 SCL | I2C |
| GPIO 25 | vibe-1 SIG | PWM |
Code
#include <Wire.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_SSD1306.h>
#include <MAX30105.h>
#define SDA_PIN 21
#define SCL_PIN 22
#define HR_INT_PIN 19
#define VIBE_PIN 25
Adafruit_MPU6050 mpu;
Adafruit_SSD1306 display(128, 64, &Wire, -1);
MAX30105 particleSensor;
unsigned long steps = 0;
void setup() {
Wire.begin(SDA_PIN, SCL_PIN);
mpu.begin();
particleSensor.begin(Wire, I2C_SPEED_FAST);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
pinMode(VIBE_PIN, OUTPUT);
}
void loop() {
sensors_event_t a, g, t;
mpu.getEvent(&a, &g, &t);
float accelMag = sqrt(a.acceleration.x * a.acceleration.x + a.acceleration.y * a.acceleration.y + a.acceleration.z * a.acceleration.z);
if (accelMag > 13.0f) steps++;
long ir = particleSensor.getIR();
int bpmEstimate = map((int)(ir % 50000), 0, 50000, 65, 125);
if (steps % 250 == 0 && steps > 0) tone(VIBE_PIN, 1200, 80);
display.clearDisplay();
display.setCursor(0, 0);
display.printf("BPM: %d\nSteps: %lu\nIR: %ld", bpmEstimate, steps, ir);
display.display();
delay(50);
}
// Run this and build other cool things at schematik.ioReady to build this?
Open this project in Schematik to get the full wiring diagram, pin assignments, and deployable code for the Fitness Wristband.
Open in Schematik →Related guides

How to Build a Self-Balancing Rover with ESP32
ESP32 · Intermediate

How to Build a Cosmic Critter Pet with Raspberry Pi Pico
Raspberry Pi Pico · Beginner

How to Build a Gesture-Controlled Mood Lamp with ESP32
ESP32 · Beginner

How to Build an ESP32 Kids Phone Prototype
ESP32 · Intermediate