This guide will help you create an IoT-based Car Parking System to monitor and manage parking spaces. The system will detect occupied and vacant parking spots, provide real-time updates, and manage parking availability through a cloud-based platform.
Components Required
- Microcontroller (e.g., Arduino or ESP32)
- Ultrasonic distance sensors
- Wi-Fi or GSM module (for communication)
- Power supply (for the microcontroller and sensors)
- Cloud service account (e.g., ThingSpeak, AWS IoT, or Azure IoT)
- Display or LED indicators (optional, for local status display)
Setting Up the Hardware
Follow these steps to set up the hardware:
-
Install the Ultrasonic Sensors
Place the ultrasonic sensors in each parking spot to measure the distance between the sensor and the vehicle. This will help detect whether a spot is occupied or vacant.
-
Integrate the Communication Module
Connect the Wi-Fi or GSM module to enable communication between the microcontroller and the cloud service. This allows for real-time updates and monitoring of parking space availability.
-
Set Up Display Indicators (Optional)
If desired, connect a display or LED indicators to show the status of each parking spot locally.
-
Power the System
Ensure all components are properly powered. Use a reliable power supply for the microcontroller and sensors.
Programming the Microcontroller
Write the code to read data from the ultrasonic sensors, process it to determine parking space occupancy, and send updates to the cloud. Below is a basic outline of the code using Arduino IDE:
#include <WiFi.h> // For ESP32 or ESP8266
#include <ThingSpeak.h>
// Configuration
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";
const char* apiKey = "YOUR_THINGSPEAK_API_KEY";
const int channelID = YOUR_CHANNEL_ID;
// Define pins
const int trigPin = 9;
const int echoPin = 10;
// Set up
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.println("Connected to WiFi");
ThingSpeak.begin(client);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
long duration;
int distance;
// Trigger the sensor
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read the sensor
duration = pulseIn(echoPin, HIGH);
distance = (duration / 2) * 0.0344; // Convert to centimeters
// Check parking spot status
int parkingStatus = (distance < 20) ? 1 : 0; // 1 for occupied, 0 for vacant
// Send data to ThingSpeak
ThingSpeak.setField(1, parkingStatus);
ThingSpeak.updateChannel(channelID, apiKey);
delay(30000); // Update every 30 seconds
}
This code reads the distance from the ultrasonic sensor to determine if a parking spot is occupied. It then sends this data to ThingSpeak for real-time monitoring.
Setting Up Cloud Integration
To visualize and manage parking space availability, integrate the system with a cloud service. Configure your cloud service to display the parking status and provide real-time updates and alerts.
Testing and Calibration
Test the system by checking the accuracy of the distance measurements and the correct detection of occupied and vacant parking spots. Adjust the sensor thresholds and calibration settings as needed for reliable operation.
Conclusion
The IoT Car Parking System provides an efficient and smart solution for managing parking spaces. By integrating ultrasonic sensors with a microcontroller and cloud services, this system enables real-time monitoring and management of parking availability, enhancing the convenience and efficiency of parking management.