Skip to content
Buy 10+ on select items — save 10% auto-applied
Free US shipping on orders $35+
Order by 3pm ET — ships same-day from the US
Skip to main content

ESP32 MPU6050: Build a Wrist Sleep Tracker | ShillehTek

May 27, 2026 23 views

ESP32 MPU6050: Build a Wrist Sleep Tracker | ShillehTek
Project

Build an ESP32 + MPU6050 wrist-worn sleep tracker that logs motion all night and plots deep sleep vs REM from activity, using parts from ShillehTek.

3 hr Intermediate / Advanced5 parts

Project Overview

ESP32 + MPU6050 wrist sleep tracker: An MPU6050 worn on your wrist measures movement throughout the night. The ESP32 logs the readings, classifies sleep stages from movement intensity (deep sleep = stillness; REM = movement bursts), and uploads the night’s curve to a phone dashboard in the morning. Same idea behind Fitbit, Garmin, Whoop at $20 instead of $200.

  • Time: ~3 hours
  • Skill level: Intermediate / Advanced
  • What you will build: A wearable IMU + Wi-Fi data logger that profiles your sleep each night.
ESP32-C3 and MPU6050 wrist-worn sleep tracker with TP4056 charger assembled in a wearable form
MPU6050 + ESP32 + TP4056 = wrist-worn sleep tracker, no monthly fee.

Parts List

From ShillehTek

External

  • Small LiPo cell (400-500 mAh fits a wristband)
  • 3D-printed or fabric wristband enclosure

Note: MPU6050 uses I2C. Your ESP32-C3 board may label I2C pins differently, so follow your specific dev board pinout when wiring SDA/SCL.

Step-by-Step Guide

Step 1 - The Wristband

Goal: Create a comfortable enclosure that keeps the IMU stable on your wrist.

What to do: Build or print a compact wristband enclosure that fits the ESP32-C3, MPU6050, TP4056, LiPo cell, and buzzer.

3D-printed wristband enclosure sized to hold an ESP32-C3, MPU6050, battery charger, and LiPo
Compact 3D-printed case sized for an adult wrist.

Expected result: A wrist-wearable enclosure that can securely hold the electronics overnight.

Step 2 - Wire It Up

Goal: Connect the MPU6050 (I2C), buzzer (GPIO), and TP4056 (battery charging) to the ESP32-C3 and power system.

What to do: Wire the MPU6050 on I2C, connect the buzzer to a GPIO, and integrate the TP4056 to charge the LiPo cell from USB.

ESP32-C3 sleep tracker electronics connected to an MPU6050 IMU, TP4056 charger, 400mAh LiPo, and buzzer
ESP32-C3 + MPU6050 + TP4056 + 400mAh LiPo + buzzer.
Wiring diagram showing ESP32-C3 connected to MPU6050 over I2C, a buzzer on a GPIO pin, and TP4056 charging a LiPo cell via USB
MPU6050 on I2C, buzzer on a GPIO, TP4056 charges the cell from USB.

Expected result: The modules are connected and physically fit in the wrist enclosure without strain on wires.

Step 3 - Sketch (Activity Logging)

Goal: Log motion intensity so lower values indicate deeper sleep and spikes indicate movement bursts.

What to do: Upload the sketch below. It reads the MPU6050, computes acceleration magnitude minus gravity, tracks the 1-minute peak, and prints an activity value to Serial.

Code:

#include <Wire.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
Adafruit_MPU6050 mpu;
unsigned long minuteStart = 0;
float minuteMax = 0;
void setup() {
  Serial.begin(115200);
  mpu.begin();
  mpu.setAccelerometerRange(MPU6050_RANGE_4_G);
  minuteStart = millis();
}
void loop() {
  sensors_event_t a, g, t;
  mpu.getEvent(&a, &g, &t);
  // Compute total acceleration magnitude minus gravity
  float mag = abs(sqrt(a.acceleration.x*a.acceleration.x +
                       a.acceleration.y*a.acceleration.y +
                       a.acceleration.z*a.acceleration.z) - 9.8);
  if (mag > minuteMax) minuteMax = mag;
  if (millis() - minuteStart >= 60000) {
    Serial.print("Activity (1min peak m/s^2): ");
    Serial.println(minuteMax, 2);
    // Store in EEPROM / push to server. Lower = deeper sleep.
    minuteMax = 0;
    minuteStart = millis();
  }
  delay(100);
}

Expected result: Serial output prints one activity value per minute, where smaller values represent stillness and larger values represent motion.

Step 4 - Use It

Goal: Wear the tracker overnight and view your activity curve in the morning.

What to do: Wear the device before bed. In the morning, use Wi-Fi to dump data to your phone and plot activity vs time.

Wrist-worn ESP32 and MPU6050 sleep tracker being worn, ready to log overnight motion
Wear before bed. Wake to a buzzer tone. Dump data to your phone via Wi-Fi.
Sleep tracker activity data plotted over time showing deep sleep troughs and REM movement bursts
Plot activity vs time - clear "deep" troughs and "REM" bursts.

Expected result: A time-series activity plot that highlights periods of stillness and movement bursts overnight.

Step 5 - Where to Take It Next

Goal: Extend the build with additional sensors and better data workflows.

What to do: Consider these add-ons and upgrades:

  • Add a MAX30102 to log resting heart rate + SpO8 alongside motion
  • Wake-up alarm that triggers during a light-sleep window (smarter than fixed-time alarms)
  • Stream nightly data to a Google Sheet or InfluxDB for long-term trend analysis
  • Add temperature sensing (BMP280) for skin-temp-aware fever detection

Expected result: A clear set of next steps for turning the basic motion logger into a more complete wearable.

Conclusion

This ESP32 + MPU6050 wrist tracker logs motion overnight so you can estimate deep sleep vs REM from movement intensity and keep full control of your data.

Want the exact parts used in this build? Grab them from ShillehTek.com. If you want help customizing this project or building something for your product, check out our IoT consulting services.

Reference credit: Instructables.