How to Build a Fitness Wristband Prototype with ESP32

Heart-rate sampling, step estimation, and low-power OLED display

ESP32HealthIntermediate50 minutes4 components

Updated

How to Build a Fitness Wristband Prototype with ESP32
For illustrative purposes only
On this page

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

Interactive wiring diagram

Components needed

ComponentTypeQtyBuy
MAX30102 Heart Sensorsensor1€33.90
MPU6050 Motion Sensorsensor1€4.75
SSD1306 OLEDdisplay1€4.30
Vibration Motoractuator1€2.70

Prices and availability are indicative and may have been updated by the supplier. Schematik may earn a commission from purchases made through affiliate links.

Assembly

1

Connect health sensors on I2C

Wire MAX30102, MPU6050, and OLED to SDA GPIO21 and SCL GPIO22.

2

Add haptic alert output

Drive the vibration motor using GPIO25 through a transistor stage.

Pin assignments

PinConnectionType
GPIO 21max30102-1 SDAI2C
GPIO 22max30102-1 SCLI2C
GPIO 19max30102-1 INTDIGITAL
GPIO 21wearable-imu-1 SDAI2C
GPIO 22wearable-imu-1 SCLI2C
GPIO 21wearable-oled-1 SDAI2C
GPIO 22wearable-oled-1 SCLI2C
GPIO 25vibe-1 SIGPWM

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.io
Libraries: Adafruit MPU6050, Adafruit SSD1306, SparkFun MAX3010x