TCS Pune

Motion Gesture Sensor Classifier

Intermediate · 5–7 hours

Motion Gesture Sensor Classifier

Classify stationary, circle and shake gestures from fixed sensor windows.

Arduino Nano 33 BLE Sense / nRF528403-axis accelerometerEdge Impulse export or TensorFlow Lite Micro

Learning objectives

  • Understand accelerometer sampling and coordinate axes
  • Collect balanced labelled time-series data
  • Explain train/validation/test separation
  • Deploy and profile an int8 classifier

Prerequisites

  • Arduino C/C++ basics
  • Sampling frequency and serial logging
  • Basic classification metrics

Dataset and labelling plan

  1. Define three gestures plus an explicit unknown class
  2. Collect from multiple users and orientations
  3. Use equal capture duration per class
  4. Keep test sessions separate from training captures
  5. Document sample rate, window length and overlap

Training and validation pipeline

  1. Inspect raw signals for clipping and missing samples
  2. Extract spectral or statistical features consistently
  3. Train a small classifier and review confusion matrix
  4. Quantise to int8 and compare accuracy
  5. Export a C++ library or .tflite model
  6. Test unseen gestures and low-confidence rejection

Model deployment procedure

  1. Freeze preprocessing and class order
  2. Add model bytes and resolver to firmware
  3. Allocate tensor arena from measured requirement plus margin
  4. Match device sampling/window logic to training exactly
  5. Run inference outside time-critical interrupt handlers
  6. Log class, confidence, latency and rejection result

Memory and performance targets

MetricTargetUnitWhy it matters
Validation accuracy>= 85%Demonstrates useful separation on unseen sessions
Flash usage<= 700KBMust fit application and update margin
Peak RAM / arena<= 180KBPrevents allocation failure and stack collision
Inference latency<= 40msMust finish within the sampling schedule

Deployment checkpoints

CheckExpected resultEvidence
Dataset splitNo samples from one capture appear in both train and testDataset manifest
QuantisationInt8 accuracy loss remains within 3 percentage pointsEvaluation report
On-device outputKnown gestures classify and unknown motion rejectsSerial evidence
TimingWorst-case loop remains responsive during inferenceTimestamp trace

Inference code

// Pseudocode: identical preprocessing is mandatory
read_window(accel_buffer);
features = preprocess(accel_buffer);
if (invoke_model(features) != OK) enter_safe_fallback();
result = top_class_with_confidence();
if (result.confidence < 0.70) report_unknown();
else report_class(result);

Troubleshooting

SymptomLikely causeCorrective action
All gestures become one classWindow/sample rate differs from trainingMatch acquisition and feature pipeline
Model invokes but output is randomTensor type, scale or zero-point mismatchUse exported quantisation parameters
Intermittent crashTensor arena or stack overlapMeasure peak RAM and increase safe margin
High desktop accuracy, poor device resultDataset leakage or narrow dataRebuild session-separated test set

Safety, privacy and model limits

  • Do not collect identifiable motion data without consent.
  • Remove names and unnecessary metadata from exported datasets.
  • Gesture output must not directly control hazardous machinery.
  • Model confidence is not calibrated safety probability.

Measured deployment profile

Log in to record deployment measurements

Interview and viva questions

  1. Why must one recording session not be split across train and test?
  2. What changes during int8 quantisation?
  3. Why is an unknown/reject policy necessary?
  4. How do window length and overlap affect latency?
  5. Which memory regions hold model, tensor arena and stack?

Lesson notes

Responsible TinyML workflow

Keep raw data, preprocessing, model version, compiler options and measured device results together. A desktop accuracy score does not prove embedded performance. Validate representative unseen samples on the actual target and define an explicit fallback for low confidence or out-of-distribution input.

Deployment evidence

Record the dataset split, confusion matrix, exported model hash, firmware build, board revision, peak memory, average and worst-case latency, power conditions and failures. Never treat an educational classifier as a safety-certified decision system.

Ready when you are

Need help with your laptop or computer?

Send us the model and fault details. Start your repair request online or contact TCS Pune directly.

WA