Parking system with real-time monitoring of parking spots, entries, and departures. Designed and implemented for a university lab project.
demo.mp4
- ESP32 was chosen for this project as it has a WLAN module
- Eclipse Mosquitto as the mqtt broker
- Node.js was used for subscribing to the mqtt broker, exposing an API to the client and communicating with the database
- React as the client
- PostgreSQL as the database
This database schema design allows you to store each ParkingLot, ENTRY and DEPARTURE event in chronological order. The same applies to the Parking space FREE and OCCUPIED events.
The message format for the parking_spot_state
is ParkingLotId|ParkingSpotName|ParkingSpotState
The ParkingSpotState is either FREE
or OCCUPIED
. Here is an example message:
1|A2|FREE
The message format for the parking_lot
is ParkingLotId|EntranceEvent
The EntranceEvent is either ENTRY
or DEPARTURE
. Here is an example message:
1|DEPARTURE
The server subscribes to the parking_spot_state
and parking_lot
topics of the MQTT broker.
- /health
- health check of the server
- /parking-lots
- List of parking lots
- /parking-lots/:id
- Get parking lot with the unique id, including the current parking spots state and a count of all entry and departure events.
- /events
- ServerSentEvents endpoint in JSON format for real-time events e.g.:
{ "parkingLotId":1, "event":"ENTRY", "id":1675008556177, "created_at":"2023-01-29T16:09:16.177Z" }
- /
- Calls
/parking-lots
from the server and lists parking lots.
- Calls
- /parking-lots/:id
- Calls
/parking-lots/:id
from the server and subscribes to/events
EventSource.
- Calls
The ESP32 publishes the parking_spot_state
and parking_lot
topics of the MQTT broker.
Circuit for the Fake Parking Model IoT Parking Lot, 2 IR proximity sensors for the entrance and exit. 2 IR proximity sensors for the parking spots.
Install dependencies
cd front-end && npm install
cd ..
cd server && npm install
Create .env and update environment variables:
cp .env.example .env
Run PostgreSQL and mosquitto broker:
docker compose up
Run migrations and seed database
npx prisma migrate reset
Run development server
cd server && npm start
Run development front-end
cd front-end && npm run dev
Install the PubSubClient into the arduino IDE.
Compile and flash the board.