Build it step by step
0 of 7 doneTest the sensor
Print the acceleration when you walk.
Detect steps
Print a line for each heel strike.
Work out the cadence
Average the last five intervals.
Check with a count
Walk 20 steps and compare.
Add the cue
Tick at the target rhythm.
Add the button
Switch measure and cue.
Make the clip
Fit it on the shoe.
How do you build a walking cadence trainer?
A shoe clip measures steps per minute and beeps a rhythm to help with rehabilitation walking. You need Seeed XIAO ESP32C3, LIS3DH accelerometer, Passive buzzer, Li-Po battery 3.7 V 500 mAh and Tactile push button 6 mm. It takes 7 steps and about 150 minutes.
- Level
- Intermediate
- Time
- About 150 min
- Parts
- 5
Parts list
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| LIS3DH VCC and GND | XIAO 3V3 and GND | Power |
| LIS3DH SDA and SCL | XIAO D4 and D5 | I2C |
| Passive buzzer plus | XIAO D1 | Cue tone |
| Passive buzzer minus | XIAO GND | Ground |
| Button | XIAO D2 and GND | Switch between measure and cue |
| LiPo | XIAO BAT pads | Power and charging |
Code
The clip on the shoe detects each heel strike as a sharp peak and works out steps per minute from the last five steps. Press the button to switch to cue mode, which ticks at the target rhythm so a walker can match each step to the beat; rhythmic cues are used in some walking rehabilitation. This is a hobby aid, not a medical device. Any target rhythm and any rehabilitation exercise should be set by a physiotherapist or doctor who knows the person, and walking should stop at once if it causes pain or imbalance. The beep is a short, quiet tick; keep the volume low and do not use headphones near traffic. Mount the clip securely on the laces or the side of the shoe so that it does not rub or come loose, and keep the LiPo in a protected pouch, never worn while charging. Arduino IDE with the ESP32 boards package, board "XIAO_ESP32C3".
Runs on a virtual Seeed XIAO ESP32-C3 in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
// Walking cadence trainer: measure steps per minute, or beep a target rhythm. Library: Adafruit LIS3DH. Board: XIAO ESP32C3.
#include <Wire.h>
#include <Adafruit_LIS3DH.h>
Adafruit_LIS3DH lis;
const int BUZZ = D1, BTN = D2;
int targetSpm = 100; // target steps per minute, set with your physiotherapist or trainer
bool cueMode = false;
float filt = 0, base = 9.8; bool above = false;
unsigned long lastStep = 0, lastBeep = 0, lastBtn = 0, intervals[5]; int idx = 0, nInt = 0;
void setup() {
pinMode(BTN, INPUT_PULLUP);
Wire.begin();
lis.begin(0x18);
lis.setRange(LIS3DH_RANGE_8_G);
Serial.begin(115200);
}
float cadence() { // average of the last 5 step intervals
if (nInt < 3) return 0;
unsigned long s = 0; for (int i = 0; i < nInt; i++) s += intervals[i];
return 60000.0 / (s / (float)nInt);
}
void loop() {
if (!digitalRead(BTN) && millis() - lastBtn > 400) { cueMode = !cueMode; lastBtn = millis(); tone(BUZZ, cueMode ? 1800 : 900, 150); }
sensors_event_t e; lis.getEvent(&e);
float mag = sqrt(e.acceleration.x * e.acceleration.x + e.acceleration.y * e.acceleration.y + e.acceleration.z * e.acceleration.z);
filt += (mag - filt) * 0.4; base += (filt - base) * 0.01;
float swing = filt - base;
if (!above && swing > 4.0 && millis() - lastStep > 300) { // heel strike
above = true;
unsigned long dt = millis() - lastStep; lastStep = millis();
if (dt < 2000) { intervals[idx] = dt; idx = (idx + 1) % 5; if (nInt < 5) nInt++; } else { nInt = 0; idx = 0; } // long gap: start again
Serial.print("Cadence "); Serial.print(cadence(), 0); Serial.println(" steps per minute");
}
if (above && swing < 1.5) above = false;
if (cueMode && millis() - lastBeep >= 60000UL / targetSpm) { tone(BUZZ, 1500, 40); lastBeep = millis(); } // a short tick at the target rhythm
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Walk steadily | Cadence close to your real count |
| Stand still for 2 seconds | Starts again on the next step |
| Cue mode | Even ticks at the target rate |
| Change the target | Tick rate follows |
If it does not work
Counts too many steps
Raise the swing threshold or the minimum time.
Misses steps
Lower the threshold or move the clip to the heel side.
No ticks
Check the buzzer pin and that it is passive.
Cadence jumps
Average over more steps.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the walking cadence trainer?
Seeed XIAO ESP32C3, LIS3DH accelerometer, Passive buzzer, Li-Po battery 3.7 V 500 mAh and Tactile push button 6 mm.
How long does the walking cadence trainer take to build?
About 150 minutes for a intermediate maker, in 7 steps.
How do I know the walking cadence trainer works?
Walk steadily: Cadence close to your real count. Stand still for 2 seconds: Starts again on the next step. Cue mode: Even ticks at the target rate.
Counts too many steps: what should I check?
Raise the swing threshold or the minimum time.
Misses steps: what should I check?
Lower the threshold or move the clip to the heel side.
No ticks: what should I check?
Check the buzzer pin and that it is passive.
Cadence jumps: what should I check?
Average over more steps.
