RisalDash RisalDash

Project · Wearable · MPU6050

A wearable that nags when you slouch

Everyone slouches; nobody notices themselves doing it. A $2 MPU6050 strapped to the upper back notices for you: it measures the forward-lean angle against gravity, gives you five seconds of grace, then buzzes until you sit up — and keeps honest statistics of how many minutes you actually spent hunched today.

ProjectWearableMPU6050ESP32
ESP32 posture monitor project: MPU6050 wearable with lean angle, buzzer coach and slouch stats

The angle — gravity is the protractor

No gyro fusion needed for posture: when you lean forward, gravity's projection on the accelerometer's axes shifts, and one atan2 turns that into degrees-from-upright. The interesting part is the coaching logic: a threshold, a grace timer (reaching for coffee shouldn't buzz), a nag, and a slouch clock:

// Forward lean from the accelerometer alone — gravity is the reference:
lean = atan2f(ax, sqrtf(ay * ay + az * az)) * 57.3f;   // degrees from upright

// The coaching loop: threshold + grace timer + nag + stats
bool over = lean > limit;
if (over && !overSince) overSince = millis();
if (!over) { overSince = 0; buzz = false; }

if (over && millis() - overSince > 5000) {   // 5 s grace — reaching for coffee is fine
  if (!buzz) { warns += 1; evlog->print("Slouching - sit up!"); }
  buzz = true;                               // real: tone(BUZZER_PIN, 2000, 100);
  badMin += tickMinutes;                     // today's slouch clock
}

The dashboard — stats make it stick

The buzzer corrects the moment; the statistics change the habit. A live angle gauge, a Good/Slouching badge, today's slouch minutes, the warning count and a trend chart — plus the threshold as a number widget, so you tighten the rule as your posture improves:

dash.layout("Posture", RICON_MOTION);
dash.gauge("Forward lean", &lean, 0, 60, "deg");
dash.badge("Verdict", &state).labels("Good", "Slouching", "-");
dash.stat("Slouch today", &badMin, "min");
dash.stat("Warnings", &warns, "");
dash.chart("Lean trend", &lean, "deg");

dash.layout("Settings", RICON_GAUGE);
dash.number("Threshold", &limit, 5, 40, 1);  // tune the slouch angle live
dash.beginAP("RisalDash-Posture", "12345678");

The shipped example (examples/04_Templates/PostureMonitor) runs on RisalFakeIMU — its pitch wanders through good and bad zones, so you can watch the grace timer, the nag and the clock all work before strapping anything on. The general IMU playground (3D cube, compass, steps) is the shipped MotionIMU template.

Making it wearable

PartNote
ESP32 (or C3 mini)the C3 is smaller and sips less
MPU6050I²C, mounted flat on the upper back / collar
Active buzzer or vibro motorvibration is more discreet at the office
18650 or small Li-Po + TP4056see the battery guide

Calibrate once at startup: average a second of readings while sitting straight and subtract that offset — then "upright" is your upright, not the sensor's mounting angle.

Watch the coaching loop fire on a fake IMU before you sew anything.