Skip to content

Parking system with real time monitoring of parking spots, entries and departures.

License

Notifications You must be signed in to change notification settings

koutselakismanos/IoTParkingLot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IoT Parking Lot

Parking system with real-time monitoring of parking spots, entries, and departures. Designed and implemented for a university lab project.

demo.mp4

Architecture

architecture

  • 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

Database Schema

Database Schema

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.

MQTT Topics

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

Node.js server

The server subscribes to the parking_spot_state and parking_lot topics of the MQTT broker.

API Endpoints

  • /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
    {
        "parkingLotId":1,
        "event":"ENTRY",
        "id":1675008556177,
        "created_at":"2023-01-29T16:09:16.177Z"
    }
    

React client

Route paths

  • /
    • Calls /parking-lots from the server and lists parking lots.
  • /parking-lots/:id
    • Calls /parking-lots/:id from the server and subscribes to /events EventSource.

ESP32

The ESP32 publishes the parking_spot_state and parking_lot topics of the MQTT broker.

Circuit

Circuit

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.

Prerequisites

How to setup client and server

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

How to setup esp32

Install the PubSubClient into the arduino IDE.

Compile and flash the board.