Skip to main content
Version: FILS English

RustParking

An embedded project that simulates a real-life parking, using a barrier to allow cars to enter and exit a parking lot

info

Author: Tzikas Alexandros \

GitHub Project Link: https://github.com/UPB-PMRust-Students/fils-project-2026-AlexTzikas

Description

This project is designed to be a model of a real-life parking; it uses two ultrasonic sensor to detect cars approaching a barrier (operated by a SG90 servomotor), both entering and exiting the parking, opening the barrier for exiting cars and opening the barrier for entering cars. If the parking is full or blocked (entry can be temporarly blocked via a button), the barrier will not open for any cars attempting to enter. A buzzer will play a sound effect when a car tries to enter/exit. The number of available parking slots is shown by 4 LEDs that will be lit for free spaces and unlit for occupied spaces. An alarm button can be pressed to block the barrier, make an alarm sound and make a red led blink. The computations and processing are all done by the microcontroller (STM32-NUCLEO-U545RE-Q).

Motivation

I chose this project because it is a real-life application witch can help me learn rust better, as it help me understand subjects such as real-time sensor integration; it was also suggested to me by a coleague as beeing a reliable project idea.

Architecture

System Architecture

Input:

HC-SRO4 ultrasonic sensor will receive signals to see the ditance of a car from the sensor and will send the signals through a GPIO pin

Block Button will be high/low depending on whether it is pushed or not, used for temporarly blocking the barrier.

Alarm Button will be high/low depending on whether its pushed or not, used to make the parking enter an aalarm state

Processing:

STM32-NUCLEO-U545RE-Q will do computations and signal processing and send data to the laptop via USB.

Output:

SG90 servomotor will receive signals to open/close a barrier when a car enters/exits

status LEDs a green and a red led will be set high/low depending on whether the barrier is open or closed

parking space LEDs 4 yellow LEDs will be set high/low depending on the number of available parking spots.

Buzzer will go high/low at frequencies specified by the code to produce different sounds

Log

Week 13 April - 19 April

I got the components (except the ESP32-CAM) and set up the start of my project (memory.x,cargo.toml,Config.toml,build.rs) and also created the GitHub page for the project

Week 20 April - 26 April

I got the rest of the components (the ESP32-CAM, some wires and a battery holder) and started assembling the project, starting with the servomotor; I wired the servomotor and wrote some code to test it, worked mostly fine, but each time would stop working after a while; suspected it was because of insuficient power so I decided to get some batteries for power. Afterwards wired the first sensor and started testing; had errors, as sensor would not correctly detect distance - did a lot of debugging to narrow down the problem.

Week 27 April - 3 May

The problem with the servomotor got fixed after I got some batteries to power it with. I wasted a lot of time on the sensor problem and failed fixing it even after several attemps, because I had incorrectly identified the problem's source as beeing a faulty connection; in the meantime, I added a green and a red led, with the green led lighting up when the barrier was supposed to open and the red led beeing lit for the rest of the time (will probably change in future); also worked on writing code for more tests with the sensor and did more research on how it worked; work stalled for a few days as I was trying to figure out the actual problem with the sensor;

Week 4 May - 10 May

After more debugging I finally found the problem with the sensor and fixed it; I added the second sensor and transitioned from the testing code to the code for the final parking system - spent some time doing research on how to write the code, and more time debugging/fixing errors and unexpected problems

Week 11 May - 17 May

More software - base form of the project was completed; also rearanged things on the breadboard, as it was a bit messy. Towards the week's end, I started looking into implementing authorization via an ESP-CAM. After some hours, it became clear that I would not be able to finish such a feature in time, due to forgetting an important hardware component neccesary for the implementation, but mostly due to a lack of time as next week I had to focus on other projects/examinations.

Week 18 May - 24 May

Not much done during the week due to a lack of time because of other projects/examinations; I got some cardboard for the actual parking lot and started adding some extra things - a buzzer that would play tunes for succesful entry/exit, 4 LED's to show parking availability and a button to block the barrier from opening. Rearranged stuff again due to lack of space on the breadboard, also attached servo to make the barrier stationary.

Week 25 May - Pm fair

Started week by revising code. Added an alarm button that makes a red led light on and off and makes the buzzer play an alarm like sound while blocking the barrier both for entry and exit.

Hardware

Hardware picture

STM32-NUCLEO-U545RE-Q will do computatiosn, signals processing and transmit data to the laptop

HC-SRO4 ultrasonic sensor – a sensor witch receives and transmis signals to measure distance

SG90 servo motor will open/close the barrier

LED will provide visual feedback during testing

Buzzer will play different chimes for succesful entry/exit and for failed entry

Buttons one will temporarly block the barrier from beeing opened, one will make the parking enter an alarm state

Schematics

KiCAD Schematics

Bill of Materials

DeviceUsagePrice
STM32-NUCLEO-U545RE-Qmicrocontrollerborrowed from politehnica
HC-SRO4 ultrasonic sensor x 2measuring distance from barrier36 Lei
SG90 servo motor x 4moving the barrier48 Lei
Breadboard kitConnecting components124 Lei
female-male wiresconnecting components1 Leu
female-female wiresconnectign components2 Lei
4xAA battery holderholding batteries for power8 lei

Software

LibraryDescriptionUsage
embassy-stm32async HAL for STM32 microcontrollerscontrols PWM(servo, sensor), UART (ESP32), GPIO
embassy-timetiming and delay for embassy projectsused for delays, timing measurements, ultrasonic echo timing and servo contorl intervals
embassy-executorasync task executorruns synchronous tasks, currently servomotor control and readinf of ultrasonic sensor
embedded-halhardware abstraction for embedded rustPWM traits like enablind PWM and setting duty cycle
defmtlogging for embedded rustprint debugging information like sensor state, distances from sensor, system status
defmt-rrtrrt backend for defmtsend debug logs from STM to laptop
panic-probepanic handlerused to report problems during debuggging

| Sensor documentation | | Sensor tutorial | | Sensor tutorial | | Servomotor documentation | | STM documentation | | Servomotor tutorial | | Buzzer tutorial | | Buzzer help | | Rust Book | | Embassy Intro | | PullUp resistors | | Pin Map | | Other |