Smart Parking Assistant
Introduction
The Smart Parking Assistant is a system designed to detect the presence of a vehicle in a parking space and indicate whether the space is FREE or OCCUPIED. The system uses an STM32 Nucleo-L031K6 as the main controller and an HC-SR04 ultrasonic sensor to measure the distance between the sensor and the vehicle.

The measured distance is continuously processed by the STM32 and compared with a predefined parking threshold of 200 cm. The current distance and parking status are displayed on an SSD1306 OLED display, while an LED provides a visual indication of an occupied parking space.
The complete system was designed and tested using the Wokwi simulation environment to verify the distance measurement and parking-status detection.
Components Required
S. No. | Component | Quantity | Purpose |
1 | STM32 Nucleo-L031K6 | 1 | Main controller for processing distance data |
2 | HC-SR04 Ultrasonic Sensor | 1 | Measures the distance to the vehicle |
3 | SSD1306 OLED Display | 1 | Displays distance and parking status |
4 | LED | 1 | Indicates an occupied parking space |
5 | Jumper Wires | As required | Provides electrical connections between components |
System Overview and Working Principle
The Smart Parking Assistant consists of an STM32 Nucleo-L031K6, an HC-SR04 ultrasonic sensor, an SSD1306 OLED display, and an LED. The STM32 acts as the main controller and processes the distance data received from the ultrasonic sensor.
Working Principle
The HC-SR04 ultrasonic sensor measures the distance between the sensor and the vehicle.
The STM32 triggers the ultrasonic sensor and calculates the distance using the received echo signal.
The measured distance is compared with a predefined threshold of 200 cm.
If the distance is 200 cm or less, the parking space is considered OCCUPIED and the LED is switched ON.
If the distance is greater than 200 cm, the parking space is considered FREE and the LED remains OFF.
The measured distance and parking status are displayed on the SSD1306 OLED and Serial Monitor for real-time monitoring.
Circuit Connections
Component | Pin | STM32 Nucleo Pin | Purpose |
HC-SR04 | TRIG | D2 | Sends the ultrasonic trigger pulse |
HC-SR04 | ECHO | D3 | Receives the reflected ultrasonic signal |
HC-SR04 | VCC | 3.3V | Power supply |
HC-SR04 | GND | GND | Ground |
SSD1306 OLED | SDA | D4 | I²C data |
SSD1306 OLED | SCL | D5 | I²C clock |
SSD1306 OLED | VCC | 3.3V | Power supply |
SSD1306 OLED | GND | GND | Ground |
LED | Anode (+) | D6 | Parking-status indicator |
LED | Cathode (−) | GND | Ground |
Programming and Implementation
The Smart Parking Assistant is programmed using the Arduino framework for the STM32 Nucleo-L031K6. The program measures the distance using the HC-SR04 sensor and compares it with the predefined parking threshold.
5.1 Pin Configuration
The following pins are defined:

5.2 Distance Measurement
The HC-SR04 is triggered using a short pulse, and the duration of the returned echo is used to calculate the distance.

5.3 Parking Status and LED
The calculated distance is compared with the 200 cm threshold. A distance of 200 cm or less indicates an occupied space, while a greater distance indicates a free space. The LED is switched accordingly.

5.4 OLED Display
The OLED displays the measured distance and the current parking status as FREE or OCCUPIED. The same information is also sent to the Serial Monitor.

Source Code
Simulation and Output
The Smart Parking Assistant was successfully simulated in Wokwi to verify ultrasonic distance measurement, parking-status detection, LED indication, and OLED display output.
During testing, different distances were applied using the HC-SR04 simulation slider. The system correctly identified the parking space as:
Distance ≤ 200 cm → OCCUPIED → LED ON
Distance > 200 cm → FREE → LED OFF
The measured distance and corresponding status were also displayed on the OLED and Serial Monitor.

Future Scope
The Smart Parking Assistant can be further enhanced by:
Multiple parking slots can be monitored using additional ultrasonic sensors.
IoT connectivity can be added for remote monitoring of parking-space availability.
A mobile or web application can display the status of parking spaces in real time.
Entry and exit management can be integrated for automated parking systems.
Cloud-based data storage can be used to record parking occupancy information.
Automated vehicle guidance can be added to direct drivers toward available parking spaces.
Conclusion
The Smart Parking Assistant was successfully designed and simulated using the STM32 Nucleo-L031K6, HC-SR04 ultrasonic sensor, SSD1306 OLED display, and LED. The system accurately measures the distance to a vehicle and compares it with the predefined 200 cm threshold.
When the measured distance is 200 cm or less, the system identifies the parking space as OCCUPIED and turns the LED ON. For distances greater than 200 cm, it indicates FREE and keeps the LED OFF. The successful Wokwi simulation confirms that the system performs the intended parking-space detection and real-time status display.

Comments