> ## Documentation Index
> Fetch the complete documentation index at: https://docs.edgeimpulse.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Magnetic Vision - Seeed Wio Terminal

> Classify motion speed and patterns using a Hall-effect sensor and Edge Impulse. No camera required!

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/no_camera_drama.png?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=2840b7d0489b886f267e0dc9c2cea2ba" alt="NO CAMERA DRAMA!" width="2760" height="1720" data-path=".assets/images/magnetic-vision/no_camera_drama.png" />
</Frame>

Created By: Aula Jazmati

Public Project Links:

* [Experiment 1](https://studio.edgeimpulse.com/public/1112065/live)
* [Experiment 2](https://studio.edgeimpulse.com/public/1092905/live)

Demo Video links:

* [Experiment 1 - Live demo — take 1](https://www.youtube.com/shorts/AFlcssnsRv8?feature=share)
* [Experiment 1 - Live demo — take 2](https://www.youtube.com/shorts/ThNNQYDxOLE?feature=share)
* [Experiment 1 - FAST detection](https://www.youtube.com/shorts/ysYRykSbt78?feature=share)
* [Experiment 1 - SLOW / NO\_CAR detection](https://www.youtube.com/shorts/SpL6P7tqWLs?feature=share)
* [Experiment 2 - Live demo](https://www.youtube.com/shorts/MMltPG_8UW0?feature=share)

GitHub Repo:

[https://github.com/aula9/Magnetic-Vision-Teaching-AI-to-See-Motion-Without-a-Camera](https://github.com/aula9/Magnetic-Vision-Teaching-AI-to-See-Motion-Without-a-Camera)

## Introduction

What if a machine could understand motion without seeing it? This project explores whether a simple Hall-effect sensor can capture enough information about a moving  object for a machine-learning model to recognize its motion — without any camera  or computer vision.

Using a Seeed Studio Wio Terminal, an A1302 linear Hall-effect sensor, and a small magnetic toy car, I recorded the magnetic field changes caused by the moving car.

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/tinyml_architecture.jpg?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=c6cf0ba66276354727bb68dcfe88da4f" alt="TinyML Architecture" width="1376" height="768" data-path=".assets/images/magnetic-vision/tinyml_architecture.jpg" />
</Frame>

These changes were treated as a time-series signal, uploaded to Edge Impulse, and  used to train two different machine-learning models that run entirely on-device.

The project contains two experiments:

* **Experiment 1**: Classify motion speed (FAST / SLOW / NO\_CAR) using statistical features.
* **Experiment 2**: Classify motion patterns (STRAIGHT / OSCILLATE / PAUSE) using a 1D CNN on raw signals.

The key finding: simple statistical features are sufficient for amplitude-based problems, but temporal patterns require more sophisticated, temporally-aware modeling.

## Requirements

### Hardware

* 1 x Seeed Studio Wio Terminal (ARM Cortex-M4F, built-in LCD)

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/wio_buttons.jpg?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=5bdffd6d7c9100dcdb5bef33493a0009" alt="Seeed Wio Terminal hardware" width="576" height="480" data-path=".assets/images/magnetic-vision/wio_buttons.jpg" />
</Frame>

* 1 x A1302 Linear Hall-Effect Sensor

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/a1302_sensor.jpg?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=cb60f26e5535ddf2f1bc9b26d4d09f49" alt="A1302 Linear Hall-Effect Sensor" width="949" height="761" data-path=".assets/images/magnetic-vision/a1302_sensor.jpg" />
</Frame>

* 1 x Magnetic toy car (from a magnetic science kit)

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/CAR.jpg?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=05247aad63890ede010a4c1db0e6a4e2" alt="Magnetic toy car (from a magnetic science kit)" width="949" height="566" data-path=".assets/images/magnetic-vision/CAR.jpg" />
</Frame>

* 3 x Jumper wires
* 1 x USB-C cable

### Software

* [Edge Impulse Studio](https://edgeimp.com/community26)
* [Arduino IDE](https://www.arduino.cc/en/software/) (v1.8.19 recommended)
* Python 3 (for the data logger)
* TFT\_eSPI library

### How It Works

The A1302 Hall-effect sensor is connected to the Wio Terminal's analog pin A0 (physical pin 13), powered at 3.3V for a wider ADC dynamic range. As the magnetic car moves near the sensor, the magnetic field changes, producing a time-varying analog signal.

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/wiring_diagram.jpg?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=4206f99d0b16d3bd620cb597be9488c5" alt="This is the wiring diagram connecting the Seeed Wio Terminal with the hall effect sensor" width="949" height="1280" data-path=".assets/images/magnetic-vision/wiring_diagram.jpg" />
</Frame>

The Wio Terminal samples this signal at 100 Hz and streams the readings over USB Serial to a Python logger on a PC. The logger automatically organizes the recordings into class-labeled folders (e.g., \`dataset/FAST/\`, \`dataset/SLOW/\`).

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/edgeimpulse/.assets/images/magnetic-vision/exp1_data_collection_slow1.jpg" alt="Experiment 1 - Data collection Slow" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp1_data_collection.jpg?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=f8fce85377b6ce7216f331085f081265" alt="Experiment 1 - Data collection Fast" width="949" height="1108" data-path=".assets/images/magnetic-vision/exp1_data_collection.jpg" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp2_data_collection_oscillate.jpg?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=404930e1296c2f1986b6d630bc42f21a" alt="Experiment 2 - Data collection Oscillate" width="949" height="1280" data-path=".assets/images/magnetic-vision/exp2_data_collection_oscillate.jpg" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp2_data_collection_straight.jpg?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=3452bba880d32228f45d777cff9bd010" alt="Experiment 2 - Data collection Straight" width="949" height="1280" data-path=".assets/images/magnetic-vision/exp2_data_collection_straight.jpg" />
</Frame>

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/edgeimpulse/.assets/images/magnetic-vision/exp2_data_collection_pause.jpg" alt="Experiment 2 - Data collection Pause" />
</Frame>

For on-device inference, the trained model is deployed as an Arduino library. When the user presses button B1, the Wio Terminal records 3–6 seconds of sensor data, runs the impulse locally, and displays the predicted class and confidence on its built-in LCD — with no PC or cloud connection required.

## Data Preparation

A Python script (`logger.py`) listens to the serial port and automatically saves each recording as a CSV file with the format `timestamp, value`. The dataset is organized into class-labeled folders.

Two separate data collection firmwares were used:

### Experiment 1

Records 600 samples (6 seconds at 100 Hz) for three classes:

* `FAST`: car moves rapidly past the sensor
* `SLOW`: car moves slowly past the sensor
* `NO_CAR`: no car present near the sensor

For Experiment 1: 10 recordings per class (30 total).

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp1_signals_comparison.png?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=65f0febc60b46587dd4cef1acd42accc" alt="Experiment 1 - Signals Comparison" width="740" height="367" data-path=".assets/images/magnetic-vision/exp1_signals_comparison.png" />
</Frame>

### Experiment 2

Records 300 samples (3 seconds at 100 Hz) for three classes:

* `STRAIGHT`: steady movement in one direction
* `PAUSE`: movement, brief pause, then continuation
* `OSCILLATE`: back-and-forth movement within the recording window

For Experiment 2: 28–29 recordings per class (86 total).

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp2_signals_comparison.png?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=5ebae1299fae0cb2fb35d648cffd697c" alt="Experiment 2 - Signals Comparison" width="740" height="555" data-path=".assets/images/magnetic-vision/exp2_signals_comparison.png" />
</Frame>

All CSV files were uploaded to Edge Impulse using the Data Acquisition tool, with each file automatically labeled based on its folder name.

## Building the ML Model

### Experiment 1 — Speed Classification

I designed an impulse with:

* Window size: 6000 ms (6 seconds at 100 Hz)

* Processing block: Flatten — extracts 7 statistical features per window:

  Mean, Standard Deviation, Minimum, Maximum, RMS, Skewness, Kurtosis

* Learning block: Classification (Keras)

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp1_raw_signal_fast.png?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=b4c3c35b0014c0b08584541a31e40d75" alt="Experiment 1 - Dataset" width="997" height="580" data-path=".assets/images/magnetic-vision/exp1_raw_signal_fast.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp1_impulse_design.png?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=4b02cbc2340bde9fe90dfab03045a3fa" alt="Experiment 1 - Impulse Design" width="1006" height="582" data-path=".assets/images/magnetic-vision/exp1_impulse_design.png" />
</Frame>

#### Neural network architecture

* Input: 7 features
* Dense (20 neurons, ReLU) → Dense (10 neurons, ReLU) → Dropout (0.2)
* Output: 3 classes, Softmax

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp1_dataset_fast.png?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=042f120e290f0cfd572e95e888a50eb5" alt="Experiment 1 - Define Parameters" width="1279" height="581" data-path=".assets/images/magnetic-vision/exp1_dataset_fast.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp1_training_results.png?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=ddaf623b1a90126884a2518105aa95d2" alt="Experiment 1 - Training the Classifier" width="1013" height="519" data-path=".assets/images/magnetic-vision/exp1_training_results.png" />
</Frame>

The model achieved 100% accuracy on both the validation and test sets.

Because the dataset is small and the setup is controlled, this result should be interpreted as a proof of concept rather than a general-purpose motion classifier.

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp1_inference_no_car.jpg?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=53d57243da4d020846d621876ec248ab" alt="Experiment 1 - Inference NO_CAR" width="1280" height="565" data-path=".assets/images/magnetic-vision/exp1_inference_no_car.jpg" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp1_inference_slow.jpg?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=5292fede56225d1035caae8d65ab9674" alt="Experiment 1 - Inference SLOW" width="948" height="1168" data-path=".assets/images/magnetic-vision/exp1_inference_slow.jpg" />
</Frame>

### Experiment 2 — Motion Pattern Classification

The same `Flatten` approach was tested first, but it only reached 61.5% accuracy confirming that statistical features alone cannot distinguish temporal patterns.

The approach was then changed to feed the raw 300-sample signal directly into a 1D Convolutional Neural Network.

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp2_data_explorer.png?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=4381871a21017c524db3b9555721fda1" alt="Experiment 2 - Dataset" width="1264" height="636" data-path=".assets/images/magnetic-vision/exp2_data_explorer.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp2_dataset_overview.png?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=66c3bcc3efc3630675994109258d06b7" alt="Experiment 2 - Dataset" width="1264" height="636" data-path=".assets/images/magnetic-vision/exp2_dataset_overview.png" />
</Frame>

* Window size: 3000 ms (3 seconds at 100 Hz)
* Processing block: Raw Data (300 samples)
* Learning block: Classification (Keras with 1D CNN)

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp2_impulse_design.png?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=9cd222d012a54cb6620153815f6f4429" alt="Experiment 2 - Impulse Design" width="1264" height="636" data-path=".assets/images/magnetic-vision/exp2_impulse_design.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp2_signal_oscillate.png?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=b9c55f090b7c1a85fa1530b1af5712fa" alt="Experiment 2 - Parameters" width="1264" height="636" data-path=".assets/images/magnetic-vision/exp2_signal_oscillate.png" />
</Frame>

#### Neural network architecture

* Input: 300 samples → Reshape (300 × 1)
* 1D Conv/Pool (4 filters, kernel 3) → 1D Conv/Pool (16 filters, kernel 3)
* Flatten → Dense (20, ReLU) → Dropout (0.2)
* Output: 3 classes, Softmax

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp2_architecture.png?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=3d1d003048914f38d496948ae6be9707" alt="Experiment 2 - Neural Networks Architecture" width="452" height="583" data-path=".assets/images/magnetic-vision/exp2_architecture.png" />
</Frame>

The final results of the 2nd experiment is:

* Validation accuracy: 76.3%
* Test accuracy: 66.67%

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp2_training_results.png?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=180ae39c5b7a8bfb6363563929ddf8f2" alt="Experiment 2 - Training results" width="942" height="522" data-path=".assets/images/magnetic-vision/exp2_training_results.png" />
</Frame>

### Deploying the Model

Both models were deployed as quantized (Int8) Arduino libraries from the Edge Impulse Deployment page. The Wio Terminal runs the impulse entirely on-device:

* Experiment 1 on-device performance: `< 1 ms` inference latency, `< 2 KB` RAM
* Experiment 2 on-device performance: `5 ms` inference latency, 13.8 KB RAM, 68.5 KB Flash

When the user presses B1, the Wio Terminal records the sensor data, runs the impulse locally, and displays the result instantly on its built-in screen. No PC, no cloud, and no Internet connection is required.

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp2_deployment.png?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=ffe03eed411cf7e2de906ff99f1b69ac" alt="Experiment 2 - Deployment" width="1264" height="636" data-path=".assets/images/magnetic-vision/exp2_deployment.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp2_inference_setup.jpg?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=2d2c6e4fb5fa274a36a126e7d32b7319" alt="Experiment 2 - Inference" width="949" height="1280" data-path=".assets/images/magnetic-vision/exp2_inference_setup.jpg" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/edgeimpulse/k-Al6fPYiHLotker/.assets/images/magnetic-vision/exp2_inference_pause.jpg?fit=max&auto=format&n=k-Al6fPYiHLotker&q=85&s=1bd8f5620a9af587f11e5f8b67aa8804" alt="Experiment 2 - Inference PAUSE" width="949" height="1280" data-path=".assets/images/magnetic-vision/exp2_inference_pause.jpg" />
</Frame>

## Conclusion

This project demonstrates that not all motion-recognition problems are equally suited to simple statistical feature extraction. While **Experiment 1** showed that speed classification can be solved almost perfectly with basic statistics (`Flatten`), **Experiment 2** proved that pattern classification requires more sophisticated, temporally-aware modeling (1D CNN on raw signals).

This is a meaningful finding in its own right: it shows precisely when simple embedded ML techniques are sufficient, and when a problem's underlying structure demands more advanced modeling. This is an important lesson for anyone building constrained, sensor-driven AI systems.

No camera. No images. Just a magnetic field, a sensor, and the right feature engineering.
