An IoT-based smart parking system that uses RFID technology for vehicle access control with real-time monitoring and data logging capabilities.
This project implements a complete smart parking solution that includes:
- RFID-based access control for entry and exit gates
- Real-time monitoring dashboard
- MongoDB database for user management and logging
- Servo motor controlled gates
- Date-wise filtering and data export functionality
- Arduino Uno - Main microcontroller
- 2x MFRC522 RFID Readers - For entry and exit detection
- Servo Motor - Gate control mechanism
- RFID Tags/Cards - User identification
- Jumper Wires & Breadboard - Connections
| Component | Arduino Pin |
|---|---|
| Entry RFID (SS) | Pin 10 |
| Entry RFID (RST) | Pin 9 |
| Exit RFID (SS) | Pin 7 |
| Exit RFID (RST) | Pin 6 |
| Servo Motor | Pin 8 |
| SPI MOSI | Pin 11 |
| SPI MISO | Pin 12 |
| SPI SCK | Pin 13 |
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - Database (using MongoDB Atlas)
- Socket.io - Real-time communication
- SerialPort - Arduino communication
- HTML5/CSS3/JavaScript - Web interface
- Bootstrap 5 - UI framework
- Socket.io Client - Real-time updates
- Moment.js - Date/time formatting
smart-parking-system/
βββ backend/
β βββ models/
β β βββ User.js
β β βββ Log.js
β βββ server.js
β βββ seed.js
β βββ mock-rfid.js
β βββ package.json
β βββ .env
βββ frontend/
β βββ src/
β β βββ index.html
β β βββ index.js
β βββ package.json
βββ arduino/
β βββ smart_parking.ino
βββ README.md
- Node.js (v14 or higher)
- MongoDB Atlas account
- Arduino IDE
- USB cable for Arduino connection
git clone <repository-url>
cd smart-parking-systemcd backend
npm init -y
npm install express mongoose cors socket.io serialport moment dotenvCreate a .env file in the backend directory:
MONGODB_URI=mongodb+srv://username:password@cluster0.mongodb.net/smart-parking
ARDUINO_PORT=COM3
PORT=5000cd ../frontend
npm init -y
npm install parcel-bundler socket.io-client momentSeed the database with initial user data:
cd backend
node seed.js- Open
arduino/smart_parking.inoin Arduino IDE - Install required libraries:
- MFRC522 library
- Servo library (built-in)
- Upload the code to your Arduino Uno
- Start the Backend Server:
cd backend
node server.js- Start the Frontend Development Server:
cd frontend
npm run start- Access the Dashboard:
Open your browser and navigate to
http://localhost:1234
cd backend
node mock-rfid.js- Live updates when vehicles enter or exit
- Connection status indicator
- Recent activity log
- RFID-based authentication
- Authorized user database
- Automatic gate control
- Date-wise log filtering
- CSV export for entry/exit logs
- MongoDB data persistence
- Responsive design
- Modern Bootstrap UI
- Real-time notifications
{
name: String, // User's full name
regNo: String, // Registration number
rfidUID: String, // RFID card UID
isAuthorized: Boolean // Authorization status
}{
userId: ObjectId, // Reference to User
name: String, // User's name
regNo: String, // Registration number
rfidUID: String, // RFID card UID
type: String, // 'entry' or 'exit'
timestamp: Date // Log timestamp
}| Method | Endpoint | Description |
|---|---|---|
| GET | /api/logs/entry |
Get entry logs |
| GET | /api/logs/exit |
Get exit logs |
| GET | /api/logs/download/entry |
Download entry logs as CSV |
| GET | /api/logs/download/exit |
Download exit logs as CSV |
date- Filter logs by specific date (YYYY-MM-DD format)
entry-update- New entry detectedexit-update- New exit detectedunauthorized- Unauthorized access attempt
The Arduino sends data to the backend in the format:
RFID_UID|GATE_TYPE
Example:
DF3489C1|entry
DF3489C1|exit
-
Arduino not connecting:
- Check COM port in
.envfile - Verify USB connection
- Use Device Manager to find correct port
- Check COM port in
-
MongoDB connection failed:
- Verify connection string in
.env - Check network connectivity
- Ensure MongoDB Atlas cluster is running
- Verify connection string in
-
RFID not reading:
- Check wiring connections
- Verify RFID library installation
- Test with known working RFID cards
-
Frontend not updating:
- Check Socket.io connection
- Verify backend server is running
- Check browser console for errors
Use the mock RFID script for demonstration:
cd backend
node mock-rfid.jsTo add authorized users to the system:
- Update the
backend/seed.jsfile with new user data - Run the seeding script:
node seed.jsOr add users directly to MongoDB Atlas through their web interface.
- RFID UIDs are stored in plain text (suitable for demo purposes)
- No encryption implemented in current version
- Access control based on database authorization flags