Skip to main content
Version: ACS CC

SmartBike: Cyclometer and Smart Anti-Theft System

A bicycle speed monitoring system and anti-theft alarm, developed on an STM32 platform.

info

Author: Nicolae Andrei
GitHub Project Link: https://github.com/UPB-PMRust-Students/acs-project-2026-nikoeu.git

Description

The project consists of developing a "dashboard computer" for a bicycle, featuring two main functionalities: a cyclometer and an anti-theft system. The cyclometer function uses a magnetic sensor (Reed switch) mounted on the fork and a magnet on the spoke to calculate the speed and distance traveled, displaying the data on a small screen. The anti-theft function uses a gyroscope/accelerometer module to detect unauthorized movements or shocks when the bicycle is "armed". In case of suspicious movement, the system sends a notification to the user's phone via a Bluetooth Low Energy (BLE) connection, compatible with iPhone.

Motivation

Cycling is a useful and relaxing activity, but securing the bike and monitoring performance can often require the purchase of expensive commercial equipment. I chose this project to combine my passion for cycling with electronics and embedded programming. It represents an excellent challenge to learn how to manage hardware interrupts for the speed sensor, I2C communication for the gyroscope, and serial communication for the Bluetooth module.

Architecture

The system is centralized around the STM32 development board, which receives and processes signals from the sensors, updates the display, and manages wireless communication.

Components and Connections:

  • Microcontroller (STM32): The brain of the project. It manages the state logic (Armed/Disarmed/Riding).
  • Speed Sensor (Magnetic Contact / Reed): Connected to a digital pin on the STM32 acting as an interrupt (EXTI). With each wheel rotation, the sensor sends a signal that helps calculate the speed based on the wheel's circumference.
  • Motion Sensor (MPU6050): Connected via the I2C protocol to the STM32. It detects the acceleration and tilt of the bicycle for the alarm function.
  • 0.96" OLED Display: Also connected via I2C, used to display the current speed, alarm status, and distance.
  • Bluetooth Module (HM-10 / BLE): Connected via UART (TX/RX) to the STM32. It transmits data and alerts to a Bluetooth terminal application on iOS.

Architecture diagram

Log

[Week 27 April - 1 May]

Defined the project architecture, selected the final components, and ordered the necessary hardware parts (development board, sensors, Bluetooth module).

Hardware

The project requires components that are energy-efficient and small enough to be mounted on the bicycle's handlebars/fork.

  • STM32 Development Board: The central processor executing the code.
  • Magnetic Sensor (Reed Switch): A magnetically actuated switch, essential for counting wheel rotations.
  • MPU6050 Gyroscope/Accelerometer: Used to detect sudden changes in position (anti-theft).
  • HM-10 Bluetooth Module (BLE): Enables communication with iOS devices, which support the Bluetooth Low Energy standard.
  • 0.96" OLED Display: For the visual interface on the handlebars.
  • Power Module and Li-Ion Battery: To provide portability to the system.

Schematics

Schematic diagram

Photos

Hardware

Bill of Materials

DeviceUsagePrice
STM32The main microcontroller129 RON
HM-10 BLE Bluetooth ModuleiOS compatible wireless communication27 RON
MPU6050 Accelerometer ModuleMotion detection for the alarm16 RON
Magnetic Sensor / Reed SwitchWheel rotation detection14 RON
0.96" OLED Display I2CDisplaying speed and status25 RON
Battery and TP4056 charging modulePowering the system~25 RON
Wires, Breadboard, MiscConnecting the components17 RON

Software

Because the project is part of the PMRust course, the main ecosystem relies on the Rust programming language for embedded systems.

LibraryDescriptionUsage
embassy-stm32Hardware Abstraction Layer (HAL)Pin configuration, UART for Bluetooth, and I2C for sensors
embassy-executorAsync executorManaging asynchronous tasks (reading sensors and transmitting BLE simultaneously)
mpu6050 (or similar)MPU6050 DriverInterfacing and reading data from the accelerometer
embedded-graphics2D graphics libraryDrawing text (speed) on the OLED display
ssd1306OLED Display DriverHardware control of the small screen on the handlebars
  1. Embassy Guide for STM32
  2. Recommended iOS App: BLE Serial Terminal
  3. How a Hall/Reed sensor works on a bicycle