This shows you the differences between two versions of the page.
iothings:proiecte:2022:smart_parking_system [2023/01/19 09:40] andrei.popa0805 |
iothings:proiecte:2022:smart_parking_system [2023/01/19 22:12] (current) andrei.popa0805 |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Smart Parking System ====== | ====== Smart Parking System ====== | ||
+ | Master: **AAC2** \\ | ||
+ | Student: **Popa-Artene Andrei** | ||
===== Project Overview. Introduction ===== | ===== Project Overview. Introduction ===== | ||
- | This research project aims to investigate the potential of utilizing advanced technologies, specifically the ESP32 module, to design and implement an intelligent parking system. The proposed system will feature a fixed number of parking spaces and will utilize a servomotor to simulate a parking barrier that can operate in two distinct modes, depending on the direction of a vehicle's approach. The manual mode will enable an operator to manually raise and lower the barrier via the use of two buttons, while the automatic mode will employ proximity sensors to automatically raise the barrier as a vehicle approach. \\ | + | This research project aims to investigate the potential of utilizing advanced technologies, specifically the ESP32 module, to design and implement an intelligent parking system. The proposed system features a fixed number of parking spaces and utilizes a servomotor to simulate a parking barrier that can operate in two distinct modes, depending on the direction of a vehicle's approach. The manual mode enables an operator to manually raise and lower the barrier via the use of two buttons, while the automatic mode employs proximity sensors to automatically raise the barrier as a vehicle approach. \\ |
- | Furthermore, the proposed parking system will feature a ventilation subsystem that simulates environmental conditions within the parking lot via the use of temperature and humidity sensors, as well as a motor that controls a fan. The ventilation subsystem will be designed to operate in response to temperature and humidity levels that exceed pre-defined thresholds, in order to ensure optimal environmental conditions within the parking lot. \\ | + | \\ |
- | To facilitate monitoring and management of the system, a web-based interface will be implemented that allows real-time monitoring of environmental conditions within the parking lot, and the ability to determine the need for ventilation based on sensor data. Through the implementation of this research project, the feasibility of utilizing advanced technologies such as the ESP32 module to create a more efficient and user-friendly parking system will be evaluated. | + | Furthermore, the proposed parking system features a ventilation subsystem that simulates environmental conditions within the parking lot via the use of temperature and humidity sensors, as well as a motor that controls a fan. The ventilation subsystem is designed to operate in response to temperature and humidity levels that exceed pre-defined thresholds, in order to ensure optimal environmental conditions within the parking lot. \\ |
+ | \\ | ||
+ | To facilitate monitoring and management of the system, a web-based interface is implemented that allows real-time monitoring of environmental conditions within the parking lot, and the ability to determine the need for ventilation based on sensor data. Through the implementation of this research project, the feasibility of utilizing advanced technologies such as the ESP32 module to create a more efficient and user-friendly parking system was evaluated. | ||
===== Project Architecture ===== | ===== Project Architecture ===== | ||
==== Hardware Architecture ==== | ==== Hardware Architecture ==== | ||
- | The proposed system architecture from a hardware perspective includes a selection of electronic components that are chosen based on their functional capabilities and cost-effectiveness. | + | The proposed system architecture from a hardware perspective includes a selection of electronic components that were chosen based on their functional capabilities and cost-effectiveness. |
* The core component of the system is the **ESP32 microcontroller**, developed and manufactured by Espressif Systems, a Chinese company based in Shanghai. The ESP32 series is a low-cost, low-power system-on-a-chip that integrates Wi-Fi and dual-mode Bluetooth capabilities, making it an ideal choice for this application; \\ | * The core component of the system is the **ESP32 microcontroller**, developed and manufactured by Espressif Systems, a Chinese company based in Shanghai. The ESP32 series is a low-cost, low-power system-on-a-chip that integrates Wi-Fi and dual-mode Bluetooth capabilities, making it an ideal choice for this application; \\ | ||
{{ :iothings:proiecte:2022:esp32_microprocessor.png?300 |}} | {{ :iothings:proiecte:2022:esp32_microprocessor.png?300 |}} | ||
Line 26: | Line 30: | ||
{{ :iothings:proiecte:2022:pushbutton.png?200 |}} \\ | {{ :iothings:proiecte:2022:pushbutton.png?200 |}} \\ | ||
The simulated diagram of the hardware architecture is highlighted in the picture below, where the wiring of the system is detailed and can be optimally analyzed. | The simulated diagram of the hardware architecture is highlighted in the picture below, where the wiring of the system is detailed and can be optimally analyzed. | ||
- | {{ :iothings:proiecte:2022:wiring_smart_parking_system.png |}} \\ | + | {{ :iothings:proiecte:2022:wiring_smart_parking_system2.png |}} \\ |
- | From an electrical point of view, the hardware architecture was configured below for a better understanding of how the system works and how can it be implemented from scratch. \\ | + | From an electrical point of view, the hardware architecture was configured and displayed below for a better understanding of how the system works and how can it be implemented from scratch. \\ |
{{ :iothings:proiecte:2022:electric_diagram_smart_parking.png |}} \\ | {{ :iothings:proiecte:2022:electric_diagram_smart_parking.png |}} \\ | ||
In the end, the physically hardware architecture fully configured on the breadboard can be observed in the picture below where the barrier between the ultrasonic sensors can be also noticed. | In the end, the physically hardware architecture fully configured on the breadboard can be observed in the picture below where the barrier between the ultrasonic sensors can be also noticed. | ||
{{ :iothings:proiecte:2022:schema_smart_parking_system.png?300 |}} | {{ :iothings:proiecte:2022:schema_smart_parking_system.png?300 |}} | ||
+ | A full view of the parking lot is illustrated in the picture below. The difference between these two pictures is that in this case the whole parking lot can be observed and, implicitely, the placement of the system on the table. | ||
+ | {{ :iothings:proiecte:2022:pov_smart_parking2.png |}} | ||
==== Software Architecture ==== | ==== Software Architecture ==== | ||
- | In regards to the software architecture implemented for this project, a fundamental aspect to consider is the organization of the file system. As depicted in the diagram below, a comprehensive examination of each file will be conducted in this chapter, in order to thoroughly explain the configuration of each hardware component and its role in the overall system behavior. | + | In regards to the software architecture implemented for this project, an important aspect to consider is the structure of the file system. As depicted in the diagram below, a comprehensive examination of each file will be conducted in this chapter, in order to thoroughly explain the configuration of each hardware component and its role in the overall system behavior. |
{{ :iothings:proiecte:2022:filesystem_smart_parking.png?300 |}} | {{ :iothings:proiecte:2022:filesystem_smart_parking.png?300 |}} | ||
The file "project_IoT.ino" represents the configuration that is uploaded onto the ESP32 microcontroller. In the initial segment of code, the inclusion of the necessary libraries is essential to achieve the intended outcomes. | The file "project_IoT.ino" represents the configuration that is uploaded onto the ESP32 microcontroller. In the initial segment of code, the inclusion of the necessary libraries is essential to achieve the intended outcomes. | ||
- | * The AsyncTCP.h and ESPAsyncWebServer.h libraries were used to facilitate communication with the web interface designed for this project; | + | * The **AsyncTCP.h** and **ESPAsyncWebServer.h** libraries were used to facilitate communication with the web interface designed for this project; |
* The **DHT.h** library is used for the Humidity and Temperature sensor; | * The **DHT.h** library is used for the Humidity and Temperature sensor; | ||
* The **ESP32Servo.h** is used for the SG90 Servomotor; | * The **ESP32Servo.h** is used for the SG90 Servomotor; | ||
- | * The WiFi.h library serves to establish a connection to the desired WiFi network to which the ESP32 board will connect; | + | * The **WiFi.h** library serves to establish a connection to the desired WiFi network to which the ESP32 board will connect; |
* The **SPIFFS.h** library is used to mount the file system of the ESP32 board. | * The **SPIFFS.h** library is used to mount the file system of the ESP32 board. | ||
Line 50: | Line 55: | ||
#include <WiFi.h> | #include <WiFi.h> | ||
#include <ESPAsyncWebServer.h> | #include <ESPAsyncWebServer.h> | ||
- | </code> \\ | + | </code> |
This snippet of code declares several variables and constants that are used in the program. The Servo object "myservo" is created to control a servo motor. The trigPin1, echoPin1, trigPin2, and echoPin2 constants represent the pin numbers that are used for the trigger and echo pins of two ultrasonic sensors. The led1 and led2 constants represent the pin numbers of two LEDs. The button1 and button2 constants represent the pin numbers of two buttons. The DHT_PIN constant represents the pin number of the DHT11 sensor, DC_Motor and servoPin constants represents the pin number of the DC Motor and Servo Motor respectively. The ssid and password constants are used to store the WiFi network's name and password. The "state" variable is used to keep track of the state of the trigger button from the web interface and the "servoPos" variable is used to store the position of the servo motor. The AsyncWebServer object "server" is created and set to listen on port 80. The DHT object "dht" is created and connected to the DHT11 sensor on pin DHT_PIN. | This snippet of code declares several variables and constants that are used in the program. The Servo object "myservo" is created to control a servo motor. The trigPin1, echoPin1, trigPin2, and echoPin2 constants represent the pin numbers that are used for the trigger and echo pins of two ultrasonic sensors. The led1 and led2 constants represent the pin numbers of two LEDs. The button1 and button2 constants represent the pin numbers of two buttons. The DHT_PIN constant represents the pin number of the DHT11 sensor, DC_Motor and servoPin constants represents the pin number of the DC Motor and Servo Motor respectively. The ssid and password constants are used to store the WiFi network's name and password. The "state" variable is used to keep track of the state of the trigger button from the web interface and the "servoPos" variable is used to store the position of the servo motor. The AsyncWebServer object "server" is created and set to listen on port 80. The DHT object "dht" is created and connected to the DHT11 sensor on pin DHT_PIN. | ||
<code> | <code> | ||
Line 75: | Line 80: | ||
</code> | </code> | ||
- | The next snippet of code is the setup function, which is executed once when the program starts. The Serial.begin(115200) line initializes serial communication at a baud rate of 115200. The ESP32PWM::allocateTimer(0), ESP32PWM::allocateTimer(1), ESP32PWM::allocateTimer(2), ESP32PWM::allocateTimer(3) lines are used to allocate timers for the PWM functionality. The myservo.setPeriodHertz(50) sets the frequency of the PWM used to control the servo to 50Hz, and myservo.attach(servoPin, 500, 2400) attaches the servo to the pin specified by the servoPin constant and sets the pulse width range. Next lines set the specified pins as input or output. The dht.begin() line starts communication with the DHT11 sensor. | + | The next snippet of code is the setup function, which is executed once when the program starts. The Serial.begin(115200) line initializes serial communication at a baud rate of 115200. The next four lines are used to allocate timers for the PWM functionality. The myservo.setPeriodHertz(50) sets the frequency of the PWM used to control the servo to 50Hz, and myservo.attach(servoPin, 500, 2400) attaches the servo to the pin specified by the servoPin constant and sets the pulse width range. Next lines set the specified pins as input or output. The dht.begin() line starts communication with the DHT11 sensor. |
<code> | <code> | ||
void setup() { | void setup() { | ||
Line 210: | Line 215: | ||
The first if statement checks if the button1 is pressed by checking if the button1State variable is LOW, if it is, then it performs the following actions: | The first if statement checks if the button1 is pressed by checking if the button1State variable is LOW, if it is, then it performs the following actions: | ||
- | The servo motor is set to an angle of 90 degrees by calling myservo.write(90). | + | * The servo motor is set to an angle of 90 degrees by calling myservo.write(90). |
- | The led1 is turned on by calling digitalWrite(led1, HIGH) | + | * The led1 is turned on by calling digitalWrite(led1, HIGH) |
- | The led2 is turned off by calling digitalWrite(led2, LOW) | + | * The led2 is turned off by calling digitalWrite(led2, LOW) |
- | A delay of 5 seconds is added by calling delay(5000) | + | The second if statement checks if the button2 is pressed by checking if the button2State variable is LOW, if it is, then it performs the reverse actions described above. |
- | The second if statement checks if the button2 is pressed by checking if the button2State variable is LOW, if it is, then it performs the following actions: | + | |
- | The servo motor is set to an angle of 0 degrees by calling myservo.write(0) | + | |
- | The led1 is turned off by calling digitalWrite(led1, LOW) | + | |
- | The led2 is turned on by calling digitalWrite(led2, HIGH) | + | |
- | A delay of 5 seconds is added by calling delay(5000) | + | |
- | It's important to notice that this code is checking the state of the buttons in each iteration of the loop function and performs the action only once per button press. | + | |
<code> | <code> | ||
// Check if button 1 is pressed | // Check if button 1 is pressed | ||
Line 237: | Line 236: | ||
} | } | ||
</code> | </code> | ||
- | #TODO | + | This code is reading the humidity and temperature from a DHT11 sensor, and then checking if the values read are valid. If they are not, it will print an error message. Then it checks if the humidity is greater than 80 or the temperature is greater than 40 or the state variable is equal to 1, if any of these conditions are true, it turns on the DC motor by setting its pin to high. If none of these conditions are true, it turns off the DC motor by setting its pin to low. |
<code> | <code> | ||
// Read humidity and temperature | // Read humidity and temperature | ||
Line 256: | Line 255: | ||
} | } | ||
</code> | </code> | ||
- | The ESP32 microcontroller fully controls all the sensors and motors involved in this project. In other words, the entire control logic of the project was designed to function this way, having this microcontroller as the command unit of everything that is happening, as it is displayed also in the demo video attached to this project. Moreover, the next file which will be analyzed, index.html, was flashed on the microcontroller's internal memory in order to obtain the webpage highlighted in the picture below. In the webpage, the user can observe in a friendly and intuitive manner the evolution of the humidity and temperature in time, and decide if it is necessary to ventilate the parking lot by triggering the button located at the top of the page. \\ | + | In this project, the ESP32 microcontroller serves as the central control unit for the operation of all sensors and motors involved. This is demonstrated also in the demo video. Additionally, the file "index.html" was uploaded to the microcontroller's internal memory in order to facilitate the display of a user-friendly web interface, as depicted in the picture below. Through this interface, users can easily monitor the temporal evolution of humidity and temperature and make a decision to activate the ventilation system via the button provided at the top of the page. \\ |
- | {{ :iothings:proiecte:2022:preview_web_server_smart_parking.png |}} | + | <note tip>The flash on the ESP32 internal memory of the "index.html" file was realized with a plugin called **ESP32FS**, documented in the resource chapter of this project.</note> |
- | #TODO | + | {{ :iothings:proiecte:2022:preview_web_server_smart_parking.png |}} \\ |
+ | The above code is the HTML document that contains the structure, layout, and styling of the web page depicted above. The web page is used to display two Highchart graph and a switch button. The switch button is used to turn on and off the ventilation system, when the switch is on the button is green, and when it's off it's red. The page uses a stylesheet to define the layout and design of the page elements such as the switch, the labels and the charts. The JavaScript code is used to create the charts and to handle the switch button "onchange" event. | ||
<code> | <code> | ||
<!DOCTYPE HTML><html> | <!DOCTYPE HTML><html> | ||
Line 372: | Line 372: | ||
</style> | </style> | ||
</head> | </head> | ||
- | </code> | ||
- | #TODO | ||
- | <code> | ||
<body> | <body> | ||
<h2>Smart Parking System</h2> | <h2>Smart Parking System</h2> | ||
Line 389: | Line 386: | ||
<div id="chart-temp" class="container"></div> | <div id="chart-temp" class="container"></div> | ||
</body> | </body> | ||
- | </code> | ||
- | #TODO | ||
- | <code> | ||
<script> | <script> | ||
var chartL1 = new Highcharts.Chart({ | var chartL1 = new Highcharts.Chart({ | ||
Line 470: | Line 464: | ||
xhttp.send(); | xhttp.send(); | ||
}, 3000 ) ; | }, 3000 ) ; | ||
- | </code> | ||
- | #TODO | ||
- | <code> | ||
function togglePin() { | function togglePin() { | ||
var switchButton = document.getElementById("switchButton"); | var switchButton = document.getElementById("switchButton"); | ||
Line 487: | Line 478: | ||
</html> | </html> | ||
</code> | </code> | ||
+ | To sum up, a simple yet efficient software architecture was obtained and the whole system's usability was highlighted in the diagram below. | ||
+ | {{ :iothings:proiecte:2022:activity_diagram_smart_parking2.png |}} | ||
===== Usability. Demo Video ===== | ===== Usability. Demo Video ===== | ||
- | The way the proposed solution is working was highlighted in the video attached in the link below. Here, one can observe the full environment and the hardware implementation's placement in the parking lot. The example displays how the ultrasonic sensors sense the activity which happens in front of them, how the barrier can be moved manually using the buttons or automatically when the ultrasonic sensors detect some movement, the LEDs which indicate the state of the barrier (open/closed) and the web server interface in which the evolution in time of the humidity and temperature can be seen in the graphs and the trigger button of the DC Motor which should be pressed when temperature/humidity exceed a desired treshold. | + | The way the proposed solution is working was highlighted in the video attached in the link below. There, the full environment and the hardware implementation's placement in the parking lot can be observed. The example displays how the ultrasonic sensors sense the activity which happens in front of them, how the barrier can be moved manually using the buttons or automatically when the ultrasonic sensors detect some movement, the LEDs which indicate the state of the barrier (open/closed) and the web server interface in which the evolution in time of the humidity and temperature can be seen in the graphs and the trigger button of the DC Motor which should be pressed when temperature/humidity exceed a desired treshold. \\ |
+ | Link: [[https://drive.google.com/file/d/1O56uAq17g-68r0betEHjXbiDiJ5rza-4/view?usp=share_link]] | ||
+ | ===== Future Work & Improvements ===== | ||
+ | This project presents a smart parking system that utilizes an ESP32 microcontroller, two ultrasound sensors, a servomotor, two buttons, a humidity and temperature sensor, two LEDs and a DC motor. The system is capable of detecting the presence of cars at the entrance of the parking lot. However, there is still room for improvement. | ||
+ | Future work on this project could include the following: | ||
+ | * Enhancing the user interface by incorporating a LCD screen to display the temperature, humidity, and the number of cars in the parking lot in real-time. This would provide users with more information about the parking lot conditions and make the system more user-friendly. | ||
+ | * Integrating a camera and Optical Character Recognition (OCR) algorithm to capture the image of the car's number plate, and using it to keep a record of the cars that entered the parking lot and the time they entered. This would provide more security to the parking lot and make it easier to track cars that have entered the parking lot. | ||
+ | * Adding a buzzer or LED indicator to alert the user when the parking lot is full. This would help users avoid parking in a lot that is already full. | ||
+ | Overall, the project can be improved by adding more features to make it more user-friendly, efficient and secure. | ||
===== Conclusions ===== | ===== Conclusions ===== | ||
The implementation of the ESP32 module has proven to be highly effective in providing the necessary intelligence and connectivity capabilities to the parking system, allowing for efficient allocation and management of parking spaces. \\ | The implementation of the ESP32 module has proven to be highly effective in providing the necessary intelligence and connectivity capabilities to the parking system, allowing for efficient allocation and management of parking spaces. \\ | ||
The use of a servomotor to simulate a parking barrier, along with the implementation of manual and automatic modes of operation, has resulted in a more secure and user-friendly parking experience for users. The integration of temperature and humidity sensors in the ventilation subsystem has not only ensured a comfortable environment for the users but also helped to reduce energy consumption by only activating the ventilation when needed.\\ | The use of a servomotor to simulate a parking barrier, along with the implementation of manual and automatic modes of operation, has resulted in a more secure and user-friendly parking experience for users. The integration of temperature and humidity sensors in the ventilation subsystem has not only ensured a comfortable environment for the users but also helped to reduce energy consumption by only activating the ventilation when needed.\\ | ||
- | The web-based interface has provided an easy way for the administrator to monitor and manage the system, it could also be further developed to allow users to check the parking space availability in advance, reserve parking spots and make payments.\\ | + | The web-based interface has provided an easy way for the administrator to monitor and manage the system, it could also be further developed to allow users to check the parking space availability in advance or reserve parking spots.\\ |
The results of this study have shown that it is possible to develop an intelligent parking system that is not only efficient but also cost-effective by using commercially available modules like the ESP32. | The results of this study have shown that it is possible to develop an intelligent parking system that is not only efficient but also cost-effective by using commercially available modules like the ESP32. | ||
- | This research can be expanded to include more sensors and modules to improve the overall performance and user experience, such as facial recognition or license plate recognition to further automate the parking process. | + | This research can be expanded to include more sensors and modules to improve the overall performance and user experience, such as license plate recognition to further automate the parking process. |
===== Resources & References ===== | ===== Resources & References ===== | ||
Line 521: | Line 522: | ||
[21][[https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/storage/spiffs.html]] \\ | [21][[https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/storage/spiffs.html]] \\ | ||
[22][[https://randomnerdtutorials.com/esp32-web-server-arduino-ide/]] \\ | [22][[https://randomnerdtutorials.com/esp32-web-server-arduino-ide/]] \\ | ||
+ | [23][[https://github.com/me-no-dev/arduino-esp32fs-plugin]] |