PlekCheck - Smart Parking

by JordenDecraemer in Circuits > Raspberry Pi

10 Views, 0 Favorites, 0 Comments

PlekCheck - Smart Parking

3201331b-cbcd-40a3-a99c-2a0daaf793fd.jpg

Hey there!

For my school project at MCT Howest Kortrijk, I created a Smart Parking System for businesses. The goal of this project was to make parking easier and more efficient using real-time data. The system detects available spots using sensors and visual indicators, and it's all managed by a Raspberry Pi running the database, backend, and webserver.

In this Instructable, I’ll walk you through how I built this project in 4 weeks — step by step — so you can recreate it or even improve it for your own needs!

This is my first Instructable, so if you have any questions, feel free to ask and I’ll get back to you as soon as I can!

My GitHub: https://github.com/howest-mct/2024-2025-projectone-mct-JordenDecraemer

Supplies

Transistor_Rechts.png
Ultrasone_Uitgang.png
VL53L0X_Ingang.png
Temperature_sensor.png
RFID.png
Servo_motor.png
Led_Rechts.png
Light_sensor.png
Button.png
LCD_display.png
Led_barrier.png
download.jpg
images.jpg

Servo-motor

A servo motor is a small motor that moves to a specific angle or position based on a control signal. It is commonly used in robots, RC cars, airplanes, and automation systems.

HC-SR04

The HC-SR04 is an ultrasonic distance sensor. It uses sound waves to measure the distance to an object — kind of like how a bat "sees" in the dark!

LDR

LDR stands for Light Dependent Resistor — also called a photoresistor. It is a sensor that changes resistance based on light: More light = less resistance, Less light = more resistance. So, it's used to detect light levels (like day/night).

BUTTON

A button is a simple electronic component that acts as a switch. When you press it, it closes the circuit, allowing current to flow. When you release it, the circuit opens again.

LED

LED stands for Light Emitting Diode. It’s an electronic component that lights up when electricity flows through it — but only in one direction.

Transistor

A transistor is a small electronic component that works like a switch or amplifier. It can control a large current using a small signal.

VL53L0X

The VL53L0X is a time-of-flight (ToF) distance sensor made by STMicroelectronics. It can measure very accurate distances using laser light — even better than an ultrasonic sensor like the HC-SR04.

RFID

RFID stands for Radio-Frequency Identification. It’s a wireless technology that allows you to identify and track objects or people using radio waves.

DS18B20 Temperature Sensor

The DS18B20 is a one-wire sensor that measures the temperature, manufactured by Maxim Integrated. There are 2 sorts of DS18B20 sensors, the component only (Which I used) and the waterproof version, which is much bigger, but that’s not what I needed for my project, so I used the component only. The sensor can measure the temperature in a range of -55°C to +125°C (-67°F to +257°F) and it has an accuracy of 0.5°C from -10°C to +85°C. It also has a programmable resolution from 9 bits to 12 bits.

Datasheet: https://datasheets.maximintegrated.com/en/ds/DS18...

Potentiometer sensor

A potentiometer is resistor with three terminals which is manually adjustable by just rotating the upper part of the sensor. The position of the upper part determines the output voltage of the potentiometer.

MCP3008

To read the data from my potentiometer I used an MCP3008, which is an 8 channel 10 bit analog to digital convertor with the SPI interface and is pretty easy to program.

PCF8574

The PCF8574 is an I²C I/O Expander. It allows you to add 8 extra digital I/O pins (inputs or outputs) to your Arduino, ESP32, or other microcontrollers — using only 2 wires (SDA and SCL).

LCD Display 16x2

I used a basic LCD Display to print my temperature, volume and IP address.

Datasheet: https://www.engineersgarage.com/electronic-compon...

Raspberry Pi 4 & 32GB SD Card

My whole project runs on my Raspberry Pi 4 with a configured image.

GPIO T-Part, 5 Breadboards, resistors and lots of jumperwires

To connect everything I needed breadboards, resistors and jumperwires, I used the GPIO T-part so I have more space and it is clear which pin is which.

Schematic and Wiring

52.jpg

For my schematic I used Fritzing, it's a program you can install which allows you to create a schematic really easy in different kinds of views.

Download Fritzing: http://fritzing.org/

So make sure you connect everything in the right way! In my case the colors of the wires are not the same like on the schematic.

Database Design

DB_EER_Diagram.png

We are collecting a lot of data from the sensors connected, so we need a database to store the data and sensors in. Later we'll see how to configure the database on the Raspberry Pi and how to add data to it. But first the database design or ERD (Entity Relationship Diagram) has to be made and mine was also normalised with 3NF. That's why we split up the sensors into another table and work with ID's.

Overall this is a really basic and easy database design to further work with.

Preparing the Raspberry PI

SD Card configuration

First, you need a 16GB SD Card where you can put your image on and a program to upload a start image to the SD card.

Software: https://sourceforge.net/projects/win32diskimager/

Start image: https://www.raspberrypi.org/downloads/raspbian/

So once these are downloaded:

Put your SD card in your computer.

Open up Win32 which you just downloaded.

Select the Raspbian image file which you also just downloaded.

Click on 'write' to the location of your SD card.

This may take some time, depending on your hardware. Once this is done, we are ready to make some final adjustments before putting the image into our RPi.

Go to your SD card's directory, search for the file named 'cmdline.txt' and open it.

Now add 'ip=192.168.168.169' on the same one line.

Save the file.

Create a file named 'ssh' without extension or content.

Now you can SAFELY eject the SD card from your computer and put it into the Raspberry Pi WITHOUT power. Once the SD card is into the RPI, connect a LAN cable from your computer to the RPi LAN port, once this is connected you can connect the power to the RPi.


Now we want to control our Raspberry Pi, this is done through Putty.

Putty software: https://www.putty.org/

Once downloaded, open up Putty and insert the IP '192.168.168.169' and Port '22' and connection type: SSH. Now we can finally open our command line interface and login with the starter login information -> User: pi & Password: raspberry.


Raspi-config

sudo raspi-config

What is really important for this project is the interfacing section, we have to enable a lot of different interfaces, enable all the following interfaces:

One-wire

SPI

I2C

Now that we're done with raspi-config, let's try and make a connection with internet.


Wi-Fi connection

First, you have to be root for the following commands

sudo -i

Once you're root, use the following command. SSID is your network name and password is obviously it's password.

wpa_passphrase "ssid" "password" >> /etc/wpa_supplicant/wpa_supplicant.conf

In case you made a mistake, you can check, update or delete this network by just entering that file:

nano /etc/wpa_supplicant/wpa_supplicant.conf

So after we entered our network, let's enter the WPA client interface

wpa_cli

Select your interface

interface wlan0

Reload the file

reconfigure

And finally you can see if you are connected well:

ip a

Update & upgrade


Now that we are connected to the internet, updating the already installed packages would be a smart move, so let's do that first before installing other packages.

sudo apt-get update

sudo apt-get upgrade

MariaDB Database

Install the MariaDB database server:

sudo apt-get install mariadb-server

Apache2 Webserver

Install the Apache2 webserver:

sudo apt install apache2

Python

Install Python:

update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1

update-alternatives --install /usr/bin/python python /usr/bin/python3 2

Python package

You will have to install all these packages to make the backend work perfectly:

annotated-types

anyio

bidict

click

fastapi

h11

idna

lgpio

mysql-connector-python

pydantic

pydantic_core

python-engineio

python-socketio

rpi-lgpio

simple-websocket

smbus

sniffio

spidev

starlette

typing_extensions

uvicorn

wsproto

Forward Engineering Our Database to the RPi!

nog in te vullen

So now the setup is done, we can finally begin writing our backend program!

I used my own classes and these are also all included in my GitHub. Link is in the intro in case you missed it ;)

In my backend file I used threading classes, so everything can run at the same time and it won't interrupt each other. And at the bottom you got all the routes so we can easily get data in our frontend.

Writing the Frontend (HTML, CSS & JavaScript)

Now that the backend is done, we can start writing the full front-end.

HTML & CSS was done pretty easy, tried working mobile first as much as possible, since we most of the times use a mobile device, it would be easier to control from a mobile dashboard.

You can design your dashboard in any way you want to, i'll just leave my code and design here, you can do whatever you like!

And Javascript was not that hard, worked with a few routes from my backend, tons of event listeners and some socketio structures.

Building My Case and Putting It All Together

28.jpg
1.jpg
2.jpg
3.jpg
4.jpg
5.jpg
6.jpg
7.jpg
8.jpg
9.jpg
10.jpg
11.jpg
12.jpg
13.jpg
14.jpg
15.jpg
16.jpg
17.jpg
18.jpg
19.jpg
20.jpg
21.jpg
22.jpg
23.jpg
24.jpg
25.jpg
26.jpg
27.jpg
30.jpg
31.jpg
32.jpg
33.jpg
34.jpg
35.jpg
36.jpg
37.jpg
38.jpg
39.jpg
40.jpg
41.jpg
42.jpg
43.jpg
44.jpg
45.jpg
46.jpg
47.jpg
48.jpg
49.jpg
50.jpg
51.jpg
52.jpg
3201331b-cbcd-40a3-a99c-2a0daaf793fd.jpg
29.jpg

I first started with some sketches of how I wanted the case to look, something important was that it had to be big enough for everything to fit in, since we got a big circuit to put in the case.

I made the case out of wood, I think it is the easiest to work with when you don't have that much experience with building cases and you also have a lot of things you can do with it.

I started from a regular plank and just started drawing/sawing the wood. Once I had my basic case, I just had to drill holes in it (a lot on the front of the case, as you can see on the pictures :P) and put some nails in it, it's a really basic case, but it looks pretty cool and fits perfect.

And once the case was done, it was time to put it all together, as you can see on the last picture! It is kinda a mess inside the box, but everything works and I did not have that much more space, so I advice you to maybe create a bigger case if you are recreating my project.