Skip to main content
Version: FILS English

Sonar using ToF Distance Sensors

A Sonar using ToF Distance Sensors to detect foreign objects and deliver geographical information

info

Author: Abdulqader Albaidhani
GitHub Project Link: https://github.com/UPB-PMRust-Students/fils-project-2026-Albaidany

Description

My Project Idea: A sonar radar using a Time-of-Flight (ToF) distance sensor to detect foreign objects in an area, when an object enters the sonar's radius, an alert sound queue will occur, the sonar measures accross an area with both manual (using buttons) and automatic movements (using a button to switch modes).

Motivation

I chose to make this because I'm very passionate about Intel-gathering gadgets and I wanted to persue many more similar ideas, this is a concept I really found interesting and I wanted to replicate it.

Architecture

Control Layer: NUCLEO-U545RE-Q microcontroller running Rust with Embassy. Handles servo control (PWM), reads distance data via I2C from the sensor, processes button inputs, manages automatic/manual scanning logic, generates buzzer signals/sound queues, and streams radar data (angle + distance) to the laptop over USB.

Sensing Layer: VL53L0X Time-of-Flight (ToF) distance sensor mounted on a custom rotating platform. it measures distance in real time at the current angle using time-of-flight (ToF) technology, providing precise range data for radar visualization via laptop.

Actuation Layer: SG90 Micro Servo Motor driven by PWM signals from the MCU. Rotates the sensor across a 0°–180° sweep, allowing spatial scanning of the environment. movement supports both automatic scan and manual directional control via user input using buttons, when in manual mode and inactive for ~3 seconds, the system returns back to automatic sweeping mode.

Log

Week 5 - 11 May

Week 12 - 18 May

Week 19 - 25 May

Hardware

NUCLEO-U545RE-Q USB cable VL53L0X Time-of-Flight Distance Sensor Module SG90 Micro Servo Motor Passive Buzzer
Green LED Red LED Push buttons Resistors Breadboard(atm) Jump wires

Schematics

Place your KiCAD or similar schematics here in SVG format.

Bill of Materials

DeviceUsagePrice
STM32 Development BoardThe microcontroller105 RON
VL53L0X Time-of-Flight Distance SensorDistance Sensor25 RON
USB CableCable for data transfer5 RON
SG90 Servo MotorSensor movement15 RON
Passive buzzer x3Sound queues2 RON
LEDs x4Visual queues4 RON
Buttons x3Manual controls5 RON
Resistors + Jumpers + breadboardsSupporting the circuit30 RON

Software

LibraryDescriptionUsage
embassy-stm32Embassy HAL for STM32 microcontrollersGPIO, timers, UART, sensor integration
embassy-executorAsync task executorRunning concurrent tasks (sensor read, servo control, USB streaming)
embassy-timeAsync timers and delaysServo sweep timing, debounce, 3s timeout logic
embassy-syncSynchronization primitivesSharing data between tasks (angle, distance, mode)
embassy-futuresAsync utilitiesTask coordination and control flow
embassy-usbUSB device stack (CDC ACM)Sending radar data to laptop via USB
embedded-halHardware abstraction traitsGeneric interfaces for I2C, PWM, GPIO
vl53l0x custom driversDriver for VL53L0X sensorReading distance measurements over I2C
cortex-mARM Cortex-M support crateLow-level MCU access
cortex-m-rtRuntime for Cortex-M devicesStartup, interrupt vectors
heaplessFixed-capacity data structuresBuffers for USB data (angle + distance)
  1. Visual of a Sonar
  2. Different types of Sonars