This shows you the differences between two versions of the page.
iothings:proiecte:2021:remote_reverse_parking [2022/01/25 20:05] vlad_alexandru.albu created first version |
iothings:proiecte:2021:remote_reverse_parking [2022/01/27 22:16] (current) vlad_alexandru.albu add demo video |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Project description ====== | ====== Project description ====== | ||
- | The purpose of this project, called „**Remote reverse parking**//__Italic Text__//”, is to bring the IoT domain to the automobile industry. In the last years, IoT had a massive jump in popularity and usage in domains like smart homes, electronic devices, but the presence in the automobile industry is in a incipient stage. | + | The purpose of this project, called „**Remote reverse parking**”, is to bring the IoT domain to the automobile industry. In the last years, IoT had a massive jump in popularity and usage in domains like smart homes, electronic devices, but the presence in the automobile industry is in a incipient stage. |
- | The project simulates the behavior of a car that can be parked remotely, without a driver inside the car, using a WEB page connected via Wi-Fi to the car. | + | The project simulates the behavior of a car that can be parked remotely, without a driver inside the car, using a WEB page connected via Wi-Fi to the car. |
- | For the implementation, I used ESP32 microcontroller, a DC motor, a DC motor controller (L293D integrated Circuit), an ultrasonic sensor (HC-SR04), 2 LEDs, one buzzer and a breadboard power supply module. | + | For the implementation, I used ESP32 microcontroller, a DC motor, a DC motor controller (L293D integrated Circuit), an ultrasonic sensor (HC-SR04), 2 LEDs, one buzzer and a breadboard power supply module. |
====== Hardware description ====== | ====== Hardware description ====== | ||
- | In my project I used the next components: | + | In my project I used the next components: |
- | + | ||
- | - **Microcontroller ESP32:** | + | **1. [[https://cleste.ro/placa-dezvoltare-esp-wroom-32-esp-32s.html|Microcontroller ESP32:]]** |
- | ESP32 is a low-power system on a chip microcontroller, development board, that is characterized by a small price, but offering very good capabilities, especially for IoT applications, making usage of the built-in Wi-Fi and Bluetooth capabilities. | + | |
+ | ESP32 is a low-power system on a chip microcontroller, development board, that is characterized by a small price, but offering very good capabilities, especially for IoT applications, making usage of the built-in Wi-Fi and Bluetooth capabilities. | ||
+ | |||
+ | //Project usage:// | ||
+ | |||
+ | * The ESP32 is the main part of the project, is used to create the web server and controls all the hardware components of the project. | ||
+ | |||
+ | {{ :iothings:proiecte:2021:rrm_esp32.jpg?200 |}} | ||
+ | __//Image 1: [[https://ro.mouser.com/ProductDetail/Espressif-Systems/ESP32-DevKitC-32UE?qs=GedFDFLaBXFguOYDKoZ3jA%3D%3D|ESP32]]// | ||
+ | __ | ||
- | //Project usage://__Underlined Text__ | + | **2. [[https://cleste.ro/senzor-ultrasonic-hc-sr04.html|HC-SR04 ultrasonic sensor:]]** |
- | * The ESP32 is the main part of the project, is used to create the web server and controls all the hardware components of the project. | + | |
- | - **HC-SR04 ultrasonic sensor:** | + | The sensor is used to measure distance to an object. It uses one transmitter to send an ultrasonic wave that will travel in air until reaching an obstacle and then will be reflected back to the sensor’s receiver module. |
- | The sensor is used to measure distance to an object. It uses one transmitter to send an ultrasonic wave that will travel in air until reaching an obstacle and then will be reflected back to the sensor’s receiver module. | + | |
- | //Project usage://__Underlined Text__ | + | //Project usage:// |
* Used to measure the distance between the simulated car and an eventual obstacle. | * Used to measure the distance between the simulated car and an eventual obstacle. | ||
* Based on the measured distance, the DC motor is controlled, reducing the speed, until a full stop, when the distance is small. | * Based on the measured distance, the DC motor is controlled, reducing the speed, until a full stop, when the distance is small. | ||
* It is connected to the 5V ESP32 output, the „trigger” pin, used to send the wave, to ESP32 pin GPIO 5, and „echo” pin, used to receive the wave, to ESP32 GPIO 18 pin. | * It is connected to the 5V ESP32 output, the „trigger” pin, used to send the wave, to ESP32 pin GPIO 5, and „echo” pin, used to receive the wave, to ESP32 GPIO 18 pin. | ||
- | - **DC Motor, L293D motor controller and breadboard power supply module:** | + | {{ :iothings:proiecte:2021:rrm_hc-sr04.jpg?300 |}} |
- | The //DC motor// is standard, with operating voltage between 3V – 6V. | + | __//Image 2: [[https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.elecrow.com%2Fhcsr04-ultrasonic-ranging-sensor-p-316.html&psig=AOvVaw0pYkJYOV2Zy03smg6ESJLK&ust=1643230227655000&source=images&cd=vfe&ved=0CAsQjRxqFwoTCICMk-LjzfUCFQAAAAAdAAAAABAQ|HC-SR04 ultrasonic sensor]] |
- | //L293D// IC is a motor controller capable to drive 2 DC motors, and is used to control the motor speed. | + | // |
- | The //breadboard power supply// is used to generate 3.3V or 5V output, from a 9V-12V external source, for example a battery, and is connected directly to the VCC and ground pins of the breadboard. | + | __ |
- | //Project usage://__Underlined Text__ | + | **3. [[https://ardushop.ro/ro/motoare-si-drivere/437-motoras-curent-continuu.html?gclid=CjwKCAiA3L6PBhBvEiwAINlJ9Lp3btwfEgRLbzGz_DGDiGtbaorAFwZQUpWjHT6sdFiZabed_9XHaBoC8I4QAvD_BwE|DC Motor]], [[https://www.emag.ro/circuit-integrat-l293d-ai823-s757/pd/DLBS4TMBM/?cmpid=93116&gclid=CjwKCAiA3L6PBhBvEiwAINlJ9KNPUi1dpzbuIJHPeyimSBnEN2Rpw15H6xvq1zl-vuQwa2a2eXiT_xoC3HIQAvD_BwE|L293D motor controller]] and [[https://ardushop.ro/ro/home/40-modul-sursa-de-alimentare-5v-33v.html?gclid=CjwKCAiA3L6PBhBvEiwAINlJ9CR2toA4tqfQVtq5XY0pz-Hg0jMgYk60E9bX4gFauxsg8pVCWoo4eBoCFEwQAvD_BwE|breadboard power supply module]]:** |
+ | |||
+ | The //DC motor// is standard, with operating voltage between 3V – 6V. | ||
+ | |||
+ | //L293D// IC is a motor controller capable to drive 2 DC motors, and is used to control the motor speed. | ||
+ | |||
+ | The //breadboard power supply// is used to generate 3.3V or 5V output, from a 9V-12V external source, for example a battery, and is connected directly to the VCC and ground pins of the breadboard. | ||
+ | |||
+ | //Project usage:// | ||
* The DC motor is used to simulate the car moving, will star to run at a constant speed, and when getting close to an obstacle, based on some distance intervals, the speed will be reduced. The motor is connected directly to the L293D controller. | * The DC motor is used to simulate the car moving, will star to run at a constant speed, and when getting close to an obstacle, based on some distance intervals, the speed will be reduced. The motor is connected directly to the L293D controller. | ||
* L293D controller is used to control the DC motor speed, using the PWM ESP32 pins. The module power supply is connected to the output of the breadboard power supply, the pins for controlling the DC motor direction are connected to ESP32 GPIO 26 and GPIO 27, and the „enable” pin, used to set the motor speed, to GPIO 14. | * L293D controller is used to control the DC motor speed, using the PWM ESP32 pins. The module power supply is connected to the output of the breadboard power supply, the pins for controlling the DC motor direction are connected to ESP32 GPIO 26 and GPIO 27, and the „enable” pin, used to set the motor speed, to GPIO 14. | ||
* The dedicated breadboard power supply module was added to power only the DC motor and L293D module, and is alimented by a 9V battery. | * The dedicated breadboard power supply module was added to power only the DC motor and L293D module, and is alimented by a 9V battery. | ||
- | - **LEDs and buzzer:** | + | {{ :iothings:proiecte:2021:rrm_moto_l293d_power.jpg?400 |}} |
- | //Project usage://__Underlined Text__ | + | //__Image 3: [[https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.elecrow.com%2Fhcsr04-ultrasonic-ranging-sensor-p-316.html&psig=AOvVaw0pYkJYOV2Zy03smg6ESJLK&ust=1643230227655000&source=images&cd=vfe&ved=0CAsQjRxqFwoTCICMk-LjzfUCFQAAAAAdAAAAABAQ|DC motor]], [[https://www.google.com/url?sa=i&url=https%3A%2F%2Fprotosupplies.com%2Fproduct%2Fdual-h-bridge-motor-driver-l293d%2F&psig=AOvVaw17LL4YPKiTeQnheQHfGOQx&ust=1643230335237000&source=images&cd=vfe&ved=0CAsQjRxqFwoTCIDVspXkzfUCFQAAAAAdAAAAABAF|L293D motor driver]] and [[https://www.google.com/url?sa=i&url=https%3A%2F%2Felectropeak.com%2Fbreadboard-power-supply&psig=AOvVaw0kHfoaz_gRobNRSjfT_eJe&ust=1643230377901000&source=images&cd=vfe&ved=0CAsQjRxqFwoTCOju7ankzfUCFQAAAAAdAAAAABAE|Breadboard Power Supply]] |
+ | __ | ||
+ | // | ||
+ | |||
+ | **4. [[https://www.optimusdigital.ro/ro/optoelectronice-led-uri/37-led-galben.html|LEDs]] and [[https://www.optimusdigital.ro/ro/audio-buzzere/635-buzzer-activ-de-3-v.html|buzzer]]:** | ||
+ | |||
+ | //Project usage:// | ||
* The LEDs and buzzer are used in the project to generate external warnings for the eventual peoples that will be near the car, to let them now that it will start moving. | * The LEDs and buzzer are used in the project to generate external warnings for the eventual peoples that will be near the car, to let them now that it will start moving. | ||
* The 2 used LEDs are started when the car is turned on, from the web page, they will blink in synchrony, miming the hazard lights. The LEDs are connected to GPIO 32 and 33 pins, and to the ground with a 330Ω resistors. | * The 2 used LEDs are started when the car is turned on, from the web page, they will blink in synchrony, miming the hazard lights. The LEDs are connected to GPIO 32 and 33 pins, and to the ground with a 330Ω resistors. | ||
* The buzzer starts to emit sounds when the remote parking is started, and the DC motor starts to run. In the project I used an active buzzer, with integrated oscillator to generate the sounds, and is connected to ESP32 pin 23. | * The buzzer starts to emit sounds when the remote parking is started, and the DC motor starts to run. In the project I used an active buzzer, with integrated oscillator to generate the sounds, and is connected to ESP32 pin 23. | ||
+ | {{ :iothings:proiecte:2021:rrm_led_buzzer.jpg?200 |}} | ||
+ | //__Image 4: [[https://www.optimusdigital.ro/ro/optoelectronice-led-uri/37-led-galben.html|Yellow LED]] and [[https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.zipy.ro%2Fp%2Fali%2F100pcs-lot-active-buzzer-alarm-5v-buzzer-5v-sounder-speaker-buzzer%2F32698201158%2F&psig=AOvVaw3YTdiGyGSsSA8FsDJyD46s&ust=1643230430007000&source=images&cd=vfe&ved=0CAsQjRxqFwoTCIDQ_cLkzfUCFQAAAAAdAAAAABAQ|Active Buzzer]]__// | ||
- | The implementation on the breadboard is presented in the next images: | + | **The implementation on the breadboard is presented in the next images:** |
- | -------img | + | |
- | -------img | + | {{ :iothings:proiecte:2021:rrm_breadboard.jpg?600 |}} |
+ | //__Image 5: Breadboard implementation__// | ||
+ | |||
+ | {{ :iothings:proiecte:2021:rrm_real.jpg?500 |}} | ||
+ | //__Image 6: Real breadboard implementation__// | ||
The electrical diagram of the circuit is presented in the next image: | The electrical diagram of the circuit is presented in the next image: | ||
- | ------img | + | |
+ | {{ :iothings:proiecte:2021:rrm_schematic.jpg?600 |}} | ||
+ | //__Image 7: Schematic__// | ||
====== Software description ====== | ====== Software description ====== | ||
- | The code for the project is implemented using „Arduino IDE”. | + | The code for the project is implemented using „Arduino IDE”. |
===== Software implementation key features ===== | ===== Software implementation key features ===== | ||
- | - Wi-Fi connection and web server | + | * Wi-Fi connection and web server |
- | For the project, ESP32 board is set to operate in „Station Mode”. This means that the board is connected to a Wi-Fi router, retrieves the IP address and creates a web server based on it. The web server can be accessed by another device connected to the same Wi-Fi network. | + | For the project, ESP32 board is set to operate in „Station Mode”. This means that the board is connected to a Wi-Fi router, retrieves the IP address and creates a web server based on it. The web server can be accessed by another device connected to the same Wi-Fi network. |
- | To facilitate the connection to Wi-Fi, 2 libraries are used: | + | To facilitate the connection to Wi-Fi, 2 libraries are used: |
- | * //„WiFi.h”// – Provides dedicated Wi-Fi methods for connecting the ESP32 to internet; | + | - //„WiFi.h”// – Provides dedicated Wi-Fi methods for connecting the ESP32 to internet; |
- | * //„WebServer.h”// – Provides methods to set up the web server and handle HTTP requests. | + | - //„WebServer.h”// – Provides methods to set up the web server and handle HTTP requests. |
- | - Auto-refresh data in the web page | + | * Auto-refresh data in the web page |
- | The distance to an obstacle will be showed in the web page, and since the value is not fixed, is changing, I had 2 options, either refresh the web page at a certain fix time period, or update only the distance in the background. Since it is a more cleaner and correct way, I choose the second option. | + | The distance to an obstacle will be showed in the web page, and since the value is not fixed, is changing, I had 2 options, either refresh the web page at a certain fix time period, or update only the distance in the background. Since it is a more cleaner and correct way, I choose the second option. |
- | To achieve the auto-refresh of the distance value, I used **„AJAX”** //(Asynchronous JavaScript and XML)//, a technique used to update only portions of a web page, fast and dynamic, without refreshing the hole page. | + | To achieve the auto-refresh of the distance value, I used **„AJAX”** //(Asynchronous JavaScript and XML)//, a technique used to update only portions of a web page, fast and dynamic, without refreshing the hole page. |
- | Code modifications required: | + | Code modifications required: |
- | * Create a new function, linked to the web server, using „.on” method, that will handle the distance change, | + | - Create a new function, linked to the web server, using „.on” method, that will handle the distance change, |
- | * Integrated a JavaScript section in the HTML code, that will call, every second, the function mentioned before, and the displayed distance value will be updated in the web page. | + | - Integrated a JavaScript section in the HTML code, that will call, every second, the function mentioned before, and the displayed distance value will be updated in the web page. |
===== Software implementation overview ===== | ===== Software implementation overview ===== | ||
- | We can split the code functionality in 3 parts, representing the functioning states, what will be presented to the user in the web page and how the software manages the hardware. | + | We can split the code functionality in 3 parts, representing the functioning states, what will be presented to the user in the web page and how the software manages the hardware. |
- | ==== First part ==== | + | ==== First part ==== |
- | When the microcontroller is booted and the program starts, after the connection to the Wi-Fi is established, the main web page can be accessed, see the preview image below: | + | When the microcontroller is booted and the program starts, after the connection to the Wi-Fi is established, the main web page can be accessed, see the preview image below: |
- | ------img | + | |
- | In this step, all the hardware components are turned off. | + | {{ :iothings:proiecte:2021:rrm_web1.jpg?200 |}} |
- | From this step, we can go on and start the car. | + | //__Image 8: Home web page__// |
+ | |||
+ | In this step, all the hardware components are turned off. | ||
+ | |||
+ | From this step, we can go on and start the car. | ||
- | ==== Second part ==== | + | ==== Second part ==== |
- | After the car is started we go to the second web page, where the option to start the remote parking is available, see image below: | + | After the car is started we go to the second web page, where the option to start the remote parking is available. |
- | -----img---- | + | |
- | In this stage the LEDs will start to blink, noticing visually the user that the car is running. | + | In this stage the LEDs will start to blink, noticing visually the user that the car is running. |
- | From here 2 options are available, turn off the car and go back to „First part” or start remote parking and go to the „Third part” | + | |
+ | From here 2 options are available, turn off the car and go back to „First part” or start remote parking and go to the „Third part” | ||
+ | |||
+ | ==== Third part ==== | ||
+ | |||
+ | When the remote parking is started, the web page will be updated, and the start button for remote parking can now be used to stop the parking. | ||
+ | |||
+ | When getting closer to an obstacle, a pop-up warning message will appear on the web page, noticing the user that an obstacle is detected and the distance to it, as shown below: | ||
- | ==== Third part ==== | + | {{ :iothings:proiecte:2021:rrm_web2.jpg?200 |}} |
+ | //__Image 9: Remote parking started - web page__// | ||
- | When the remote parking is started, the web page will be updated, and the start button for remote parking can now be used to stop the parking. | + | From the hardware control side, the DC motor will start to run at constant speed, and will decrease the speed when the distance to obstacle, measured with HC-SR04, is decreasing. Also the buzzer will generate sounds in the background. |
- | When getting closer to an obstacle, a pop-up warning message will appear on the web page, noticing the user that an obstacle is detected and the distance to it. | + | |
- | From the hardware control side, the DC motor will start to run at constant speed, and will decrease the speed when the distance to obstacle, measured with HC-SR04, is decreasing. Also the buzzer will generate sounds in the background. | + | |
- | Next available user options are: stop the remote parking, during the parking process or after the parking is done, and go to „Second part”, or stop the car completely and go to „First part”. | + | Next available user options are: stop the remote parking, during the parking process or after the parking is done, and go to „Second part”, or stop the car completely and go to „First part”. |
- | The work flow and software implementation of the project is described in the next diagram: | + | The work flow and software implementation of the project is described in the next diagram: |
- | imggggg | + | |
+ | {{ :iothings:proiecte:2021:rrm_state_diagram.jpg?400 |}} | ||
+ | //__Image 10: State diagram__// | ||
====== Further development ====== | ====== Further development ====== | ||
- | Having a solid and tested starting point, I plan to continue developing the project in both hardware and user interface directions. | + | Having a solid and tested starting point, I plan to continue developing the project in both hardware and user interface directions. |
- | First, I want to switch from a basic web page interface to an Android/IOS Application, that will make the user-car interaction more easy. | + | First, I want to switch from a basic web page interface to an Android/IOS Application, that will make the user-car interaction more easy. |
Also functionality for front parking will be added. | Also functionality for front parking will be added. | ||
- | Secondly, on the hardware side, I want to add one more ultrasonic sensor, used for the front parking, and maybe even switch to more accurate distance sensors or even cameras. | + | |
+ | Secondly, on the hardware side, I want to add one more ultrasonic sensor, used for the front parking, and maybe even switch to more accurate distance sensors or even cameras. | ||
====== Conclusions ====== | ====== Conclusions ====== | ||
- | Implementing this project gave me the opportunity to work and learn how to use an Arduino controlled development board, ESP32, with Wi-Fi capabilities. The internet and wireless connections are now part of our lives more than ever before, and will still be in the future, so learning to take advantage of this capabilities is very benefic. | + | Implementing this project gave me the opportunity to work and learn how to use an Arduino controlled development board, ESP32, with Wi-Fi capabilities. The internet and wireless connections are now part of our lives more than ever before, and will still be in the future, so learning to take advantage of this capabilities is very benefic. |
- | Also, the IoT domain is in a continue expansion, making the human interaction with electronic devices more easy, and I think the domain chose by me for the project, automotive industry, can take advantage from integrating IoT solutions, more than in present. | + | Also, the IoT domain is in a continue expansion, making the human interaction with electronic devices more easy, and I think the domain chose by me for the project, automotive industry, can take advantage from integrating IoT solutions, more than in present. |
+ | ====== Source code, Demo video and Presentation ====== | ||
+ | [[https://we.tl/t-LU5gt92oTn]] | ||
+ | ====== Reference pages ====== | ||
+ | - [[https://en.wikipedia.org/wiki/ESP32]] | ||
+ | - [[https://components101.com/microcontrollers/esp32-devkitc]] | ||
+ | - [[https://components101.com/ics/l293d-pinout-features-datasheet]] | ||
+ | - [[https://components101.com/sensors/ultrasonic-sensor-working-pinout-datasheet]] | ||
+ | - [[https://lastminuteengineers.com/creating-esp32-web-server-arduino-ide/]] | ||
+ | - [[https://www.w3schools.com/asp/asp_ajax_intro.asp]] | ||
+ | - [[https://circuits4you.com/2018/11/20/web-server-on-esp32-how-to-update-and-display-sensor-values/]] |