Skip to content
NIK710Public

About

Embedded bike theft detection system using an ESP32-S3, IMU, BLE, and a React Native mobile app.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

Repository files navigation

BikeGuard

Embedded bike theft detection using an ESP32-S3, MPU6050 IMU, Bluetooth Low Energy, and an on-device machine learning classifier.

BikeGuard is a prototype system that monitors a bicycle's motion and classifies whether that motion is consistent with a theft attempt. The project spans the full sensing to inference pipeline: embedded firmware collects accelerometer and gyroscope data, a React Native Android app controls the device and records labeled examples, and a Python/scikit-learn pipeline trains a classifier whose learned rules can be exported back to C++ for on-device inference.

System Overview

flowchart LR
    IMU[MPU6050 IMU<br/>Acceleration + Gyroscope] -->|I2C| ESP[ESP32-S3<br/>C++ Firmware]
    ESP <-->|BLE| APP[React Native<br/>Android App]
    APP --> DATA[Labeled IMU<br/>Recordings]
    DATA --> ML[Python + scikit-learn<br/>Motion Classifier]
    ML -->|Export decision rules| ESP
Loading

The MPU6050 provides six-axis motion measurements to the ESP32-S3 over I2C. The firmware handles sensor sampling, device control, and BLE communication with the Android app. The app can connect to BikeGuard, arm/disarm the system, and record labeled IMU sessions for building the training dataset.

Hardware Prototype

BikeGuard ESP32-S3 and MPU6050 hardware prototype

The current prototype is built around an ESP32-S3 and MPU6050 accelerometer/gyroscope. The breadboard setup was used to develop and test sensor sampling, BLE communication, data collection, and the classification pipeline before moving toward a more integrated physical design.

Android App

The React Native app provides a BLE interface for interacting with the embedded device. It scans for nearby BLE devices, connects to BikeGuard, displays system state, and provides controls for arming the device and starting a data-recording session.

BikeGuard device control screen BikeGuard labeled IMU recording screen
Device control Labeled data collection

For data collection, a recording is assigned an action label and a binary theft / no-theft classification before capture. This makes it possible to collect labeled motion directly from the physical prototype rather than manually matching sensor logs to labels afterward.

Data Pipeline

Each recording contains timestamped acceleration and gyroscope measurements from the MPU6050 along with the recording session, action, and theft label.

Example labeled BikeGuard IMU dataset

The sensor stream includes:

  • accel_x, accel_y, accel_z
  • gyro_x, gyro_y, gyro_z
  • recording/session metadata
  • an action label describing the motion
  • a binary theft label

Keeping a session identifier is also important for evaluation: recordings are split between training and testing by recording session, rather than allowing windows from the same recording to appear in both sets.

Motion Classification

The current ML pipeline uses a lightweight decision tree classifier designed to be simple enough to translate into C++ and execute directly on the ESP32-S3.

  1. Split each IMU recording into 50-sample windows.
  2. Compute acceleration and gyroscope magnitudes.
  3. Extract 10 statistical features: mean, standard deviation, minimum, maximum, and range for each magnitude signal.
  4. Split training and testing data by recording session.
  5. Train a binary theft vs. normal-motion decision tree using scikit-learn.
  6. Export the learned tree rules to C++ for on-device inference.

Exploring the motion data

Acceleration magnitude during an example theft attempt

The pipeline also makes it possible to visualize how recorded motions differ. The example below compares acceleration magnitude from a normal bump with a labeled theft attempt.

Normal bicycle motion compared with a theft attempt

These plots are exploratory examples from collected recordings; they are not presented as classifier performance metrics.

Tech Stack

Layer Technologies
Embedded C++, ESP32-S3
Sensors MPU6050 IMU, I2C
Wireless Bluetooth Low Energy (BLE)
Mobile React Native, Android
Data / ML Python, scikit-learn
Classification Statistical feature extraction, decision tree

What We Built

  • C++ firmware for IMU sampling, device control, and BLE communication
  • A React Native Android app for BLE device control and labeled motion-data collection
  • A data pipeline for turning raw accelerometer/gyroscope recordings into windowed statistical features
  • A scikit-learn pipeline for training a binary motion classifier
  • A path for exporting the learned decision-tree rules to C++ for on-device inference

Next Steps

The current classifier focuses on binary theft detection. A natural next step is multiclass motion classification so BikeGuard can distinguish between different suspicious events, such as wheel tampering and lock tampering, rather than only predicting theft vs. normal motion.

Additional work can then focus on collecting a larger and more varied real-world dataset and evaluating how well the classifier generalizes across different bicycles, mounting positions, and everyday motion.


BikeGuard is an ongoing prototype exploring embedded sensing, BLE-connected data collection, and lightweight edge ML for physical security.

About

Embedded bike theft detection system using an ESP32-S3, IMU, BLE, and a React Native mobile app.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages