Skip to main content
Version: FILS English

Smart 2D LiDAR Radar & Advanced Security Hub

A comprehensive bare-metal 2D scanning system and multi-sensor security alarm built with Rust and Embassy on the STM32.

info

Author: DULCE Andrei-Marian
GitHub Project Link: https://github.com/UPB-PMRust-Students/fils-project-2026-andrrei509

Description

This project is an advanced, multi-layered active security and environmental monitoring hub built on the STM32. The core feature is a 2D scanning system using a VL53L0X Time-of-Flight (ToF) sensor mounted on a 28BYJ-48 stepper motor, which performs a 180° back-and-forth sweep and streams 18-byte Cartesian coordinate frames to a laptop via USB CDC ACM to render a real-time radar map in Python (pygame). Additional sensors — a Doppler radar, vibration sensor, sound sensor, photoresistor, and BMP180 barometer — provide intrusion detection and environmental telemetry. Two RGB LEDs give local visual feedback for proximity zones and security status, while a PWM-driven buzzer sounds proximity alerts.

Motivation

I chose this project because it combines precise motor control, real-time data acquisition from a vast array of sensors, and PC-device USB communication into a single robust system. It is a highly practical and technically challenging way to explore asynchronous embedded programming in Rust.

Architecture

System Architecture Diagram

Main software and system components:

  • Scanning Module: reads distance from VL53L0X via I2C (or generates mock ghost-room data when the sensor is unavailable) and steps the motor via GPIO in a strict ping-pong sweep.
  • Intrusion Detection Module: reads Doppler radar (RCWL-0516), vibration (SW-420), and sound sensors with multi-sample polling to catch short pulses.
  • Environmental Module: reads BMP180 temperature/pressure (I2C) and photoresistor ambient light (ADC) for night mode detection.
  • Local Feedback Module: drives two RGB LEDs (proximity zones + security status) and a PWM buzzer for proximity alarms.
  • Communication Module: streams serialized 18-byte ScanPoint payloads via USB CDC ACM to the PC, and receives single-byte motor commands (Auto/Right/Left/Stop).

Log

Week 4

  • Established the project idea and worked on the component list.

Week 5-6

  • Ordered all hardware components (STM32, VL53L0X, stepper motor, etc.).
  • Researched the Embassy framework and USB Bulk transfer implementation in Rust.

Week 7

  • Components arrived, started testing and tinkering with them.

Week 8-9

  • Hardware Integration. Began assembling the core scanning module by mounting the VL53L0X ToF sensor to the 28BYJ-48 stepper motor shaft.
  • Circuit Prototyping. Mapped out the pin connections on the 830-point breadboard for the I2C bus (sensor), GPIO sequence (ULN2003 driver), and the security sensor array.
  • Software Design. Drafted the Embassy task architecture, defining the synchronization channels between the scanning task and the USB communication task.

Hardware

The system uses an STM32 Nucleo-U545RE-Q as the central hub. It orchestrates a VL53L0X ToF sensor mounted on a 5V stepper motor for spatial scanning, alongside a suite of security sensors (Doppler radar, vibration, sound) and environmental sensors (BMP180, photoresistor). Two RGB LEDs provide local visual feedback and a PWM buzzer handles proximity alerts. Everything is wired on a universal 830-point breadboard.

Schematics

KiCAD Schematic

Complete system schematic for the Smart 2D LiDAR Security Hub.

Breadboard Assembly

Breadboard Photo 1

Breadboard wiring setup - view 1.

Breadboard Photo 2

Breadboard wiring setup - view 2.

Breadboard Photo 3

Breadboard wiring setup - view 3.

Bill of Materials

DeviceUsagePrice
STM32 Nucleo-U545RE-QThe main microcontroller106.59 RON
VL53L0X ToF SensorDistance measurement (I2C)28.00 RON
Universal Breadboard 830 pointsPrototyping base15.67 RON
28BYJ-48 5V Stepper Motor + ULN2003 DriverMotor for sensor sweeping15.00 RON
RCWL-0516 Doppler Radar SensorMicrowave motion detection6.20 RON
BMP180 Sensor ModuleTemperature and pressure sensing (I2C)4.50 RON
Passive Buzzer 3.3VProximity audio alarm (PWM)3.00 RON
PhotoresistorsAmbient light sensing (ADC)7.60 RON
Vibration / Tilt SensorTamper detection6.00 RON
Microphone / Sound SensorAcoustic trigger5.00 RON
2× RGB LED 5mm (Common Cathode + Common Anode)Proximity zones and system status indicators5.00 RON
[Transistors (2N2222) & Diodes (1N4148)]Buzzer transistor driver and flyback protection10.00 RON
[Assorted Resistors (330Ω, 1kΩ, 10kΩ)]Current limiting (LEDs) and pull-ups/downs5.00 RON
[Capacitors (100uF, 470uF, 100nF)]Power filtering and decoupling15.00 RON
[Dupont Wires (M-M, M-F, F-F)]Establishing connections25.00 RON
[Switches & PCB Buttons]Power control and inputs15.00 RON
Total272.56 RON

Software

LibraryDescriptionUsage
embassy-stm32Async HAL for STM32Hardware access for I2C, GPIO, ADC, PWM, and USB
embassy-executorAsync task executorSchedules 7 concurrent firmware tasks
embassy-timeEmbedded timersDelay management and periodic sensor polling
embassy-usbUSB device stackImplementing USB CDC ACM endpoints for PC communication
embassy-syncAsync synchronization primitivesChannels and Signals to safely move sensor data between tasks
embassy-embedded-halAdapter for Embedded HALBridging Embassy drivers with the standard Rust embedded ecosystem
embassy-futuresFuture combinatorsjoin3 for running USB device, TX, and RX concurrently
serdeData serialization frameworkDerive macros for ScanPoint and SystemStatus structs
cortex-mARM Cortex-M low-level accessHandling low-level CPU operations and critical sections
cortex-m-rtStartup and runtime for ARMManaging the reset handler and memory initialization of the STM32
panic-probeDebug panic handlerCatching code crashes and printing the stack trace over the debug probe
defmtDeferred formattingHigh-efficiency logging to debug sensor values in real-time
defmt-rttRTT transport for defmtSends defmt log frames over the debug probe's RTT channel
micromathno_std math libraryComputing sin/cos for polar-to-Cartesian coordinate mapping
vl53l0xToF Sensor DriverReading distance data from the laser sensor over I2C
bmp180-embedded-halBMP180 Sensor DriverReading temperature and pressure over I2C
static_cellStatic allocationSafe 'static references for USB buffers, channels, and shared I2C bus
embedded-halEmbedded HAL traitsCommon trait interface used by sensor drivers
  1. Embassy Framework Documentation
  2. STM32U545RE Reference Manual
  3. Rust Embedded Book
  4. VL53L0X API and Documentation