podometre.ino
The acceleration norm deviates from 1 g on every shock: an edge on that signal, spaced by at least 300 ms, counts wrist steps. The simplest pedometer that works, no dedicated library.
Hardware required
An M5StickC Plus2 (ESP32-PICO-V3-02, 135×240 display, A/B/C buttons, passive buzzer on G2, IR + red LED on G19, MPU6886 IMU, microphone, 200 mAh battery). None.
Wiring
No wiring. Wear the stick on the wrist (strap or band) for a clean signal.
How it works
The implicit high-pass filter (|a| - 1 g) isolates impacts; the 0.35 g threshold and 300 ms refractory prevent double-counting. The buzzer beep confirms each step. In the Arduino IDE (esp32 package), board « M5StickCPlus2 »; « M5StickCPlus2 » or M5Unified library. On the PMIC-less v2, hold button C for >2 s to power on; HOLD (G4) latches the power.
Going further
Stats screen (steps/min, estimated distance), or daily total persisted to NVS every hour.
podometre.ino
// Detecteur de « tap » sur MPU6886 : compteur de pas au poignet.
#include <M5Unified.h>
int pas = 0;
float energiePrec = 0;
unsigned long dernierPas = 0;
void setup() {
auto cfg = M5.config();
M5.begin(cfg);
M5.Display.setRotation(1);
M5.Display.setTextSize(3);
}
void loop() {
M5.update();
M5.Imu.update();
auto a = M5.Imu.getAccel();
float norme = sqrtf(a.x * a.x + a.y * a.y + a.z * a.z); // en g
float energie = fabsf(norme - 1.0f); // ecart a la gravite
unsigned long t = millis();
if (energie > 0.35f && energiePrec <= 0.35f && t - dernierPas > 300) {
pas++;
dernierPas = t;
M5.Spk.tone(1200, 30);
}
energiePrec = energie;
M5.Display.setCursor(10, 40);
M5.Display.printf("%4d pas\n", pas);
M5.Display.setTextSize(1);
M5.Display.printf("|a|=%.2f g", norme);
if (M5.BtnB.wasPressed()) pas = 0; // B = remise a zero
delay(20);
}