A wearable ESP32 + FreeRTOS system that classifies in-game actions — dribbles, passes, shots — in real time, while an ultrasonic sensor watches the space around the player. Multi-task scheduling, dynamic acceleration thresholds, and angle validation all run on the player's foot.
Football performance analytics typically rely on broadcast video or expensive stadium-wide tracking. The brief: build a wearable, real-time system that monitors a single player's interactions with the ball — dribbles, passes, shots — while also detecting nearby defenders, all on a microcontroller. Latency matters: the system has to keep up with live play.
Three concepts were compared via FMEA: ball-mounted IMU + UWB anchors, foot-mounted IMU + ultrasonic, and a multi-IMU BLE mesh. Concept 2 won on feasibility, ruggedness and cost — the FMEA flagged ultrasonic beam-occlusion as the highest-RPN risk and drove the mounting and field-of-view decisions.
The MPU6050 handles motion classification at high rate. The HC-SR04 watches for nearby defenders at low rate. FreeRTOS keeps both tasks isolated and passes events to a logic task through queues — so a 10-second ultrasonic ping can never block a 20 Hz IMU read.
The MPU6050 streams accelerometer + gyroscope data over I²C at 400 kHz. Touch detection looks for sudden acceleration spikes; classification thresholds split the action: dribble (2.0-3.0 g), pass (3.0-5.0 g), shot (> 5.0 g).
Pitch and roll are computed from accelerometer components — pitch via atan2(accel_y, sqrt(accel_x² + accel_z²)), roll via atan2(-accel_x, accel_z). Touches outside valid playing angles are discarded as false positives.
HC-SR04 fires a 10 µs trigger pulse, emits eight 40 kHz ultrasonic bursts, and times the echo. Distance = (pulse · 343 m/s) / 2. A 30 ms timeout prevents lockup in noisy environments.
Sensor tasks are independent; a logic task at priority 6 owns touch decisions; the defender task runs at priority 4. Queue-based message passing keeps tasks decoupled. A possession/off-ball state machine drives the live statistics output.
"GOOD POSITIONING — clear space" if the nearest defender is > 150 cm; "BAD POSITIONING — defender in close proximity" otherwise. Action counts (dribbles / passes / shots) update live alongside max-acceleration tracking.
The hardware lives in a 3D-printed ESP32-S3 case designed in Fusion 360 and sliced on a Bambu Lab A1. Two openings expose the HC-SR04 transducers; a separate clip holds the MPU6050 close to the player's ankle. Cabling is strain-relieved through the strap to survive a real game.
The system reliably distinguishes the three action classes during bench tests and continues to run cleanly when worn. The ultrasonic threshold gives a readable, immediate "good positioning" / "bad positioning" call without starving the IMU pipeline. The dual-sensor architecture cleanly separates technical skill (motion) from tactical awareness (space) — and the FreeRTOS scaffolding leaves room to add sensor fusion or BLE telemetry later.