Vibration anomaly detection: ESP32 + MPU6050
Not startedDetect vibration anomalies on a motor/fan using an ESP32 and MPU6050 IMU with statistical thresholds.
Practice in the Flight Lab: Spot the anomaly
Subareas
Steps & what each needs
- Wiring: MPU6050 VCC→3V3, GND→GND, SDA→GPIO21, SCL→GPIO22; mount the sensor rigidly to the motor/fan.
- I2C init: Wire.begin(21,22) at 400 kHz, wake the MPU6050 (PWR_MGMT_1=0), verify WHO_AM_I=0x68, set accel range and DLPF.
- Sampling rate: fixed-rate timer sampling (e.g. 500 Hz–1 kHz); record timestamps and check for dropped samples.
- Logging: stream CSV over serial (timestamp, ax, ay, az) and save to file on the host.
- Baseline: record several normal runs; compute windowed RMS/peak features and their median & MAD.
- Thresholds: robust z = 0.6745·(x−median)/MAD; flag when |z| exceeds a threshold (e.g. 3.5) for N consecutive windows.
- Fault injection: add an imbalance mass or loosen the mount; confirm detection within 5 s.
- FPR measurement: run detection on held-out normal runs and report the false-positive rate.
- Repo writeup: public GitHub repo with code, sample data, FPR results, and a fault-caught-within-5-s plot.
Resources
- Random Nerd Tutorials: ESP32 + MPU-6050 ↗randomnerdtutorials.com
- Arduino-ESP32 getting started (Espressif) ↗docs.espressif.com
- ESP-IDF I2C driver (Espressif) ↗docs.espressif.com
- MPU-6050 product page (TDK InvenSense) ↗invensense.tdk.com
- Adafruit MPU6050 guide ↗learn.adafruit.com
- Arduino Wire (I2C) library ↗docs.arduino.cc
- Median absolute deviation (Wikipedia) ↗en.wikipedia.org
- Standard score / Z-score (Wikipedia) ↗en.wikipedia.org
- NIST: detecting outliers ↗itl.nist.gov