Chapter 6 Autonomous Driving Imagine a day in the future when you get into a car, tell it where you want to go, and then you can relax, read a book, listen to music, or even take a nap while the car takes you to your destination automatically.
Section 1 Overview of Autonomous Driving Course Objectives Understand the concept of autonomous driving Understand the key technologies of autonomous driving Understand the applications of autonomous driving Build the SharkBot car Have you ever seen a car that drives itself without a driver? How do they do it? A car that can drive itself without a driver is actually a self-driving car, which utilizes...
Page 7
So what is autonomous driving technology? How does it allow cars to drive autonomously? Autonomous Driving Technology Autonomous Driving Technology refers to the technology that enables vehicles to complete driving tasks autonomously without the intervention of human drivers. It senses the surrounding environment through sensors, cameras, radar and other equipment, and realizes the automatic driving of vehicles by making decisions and controlling them through computer systems.
Page 8
L5 (Fully Autonomous Driving): The vehicle can drive completely automatically under any conditions without human intervention. Key Technologies for Autonomous Driving The realization of autonomous driving technology depends on the concerted efforts of several key technologies. LiDAR (Laser Radar): Generates highly accurate 3D maps of the environment by emitting laser beams to measure distances.
Page 9
Vehicle to Vehicle (V2X): Realizing real-time communication between vehicles and vehicles (V2V) and vehicles and infrastructure (V2I) through 5G communication technology to improve traffic efficiency and safety. The Application Of Autonomous Driving There is a wide range of application scenarios for autonomous driving technology, and the following are some typical examples: Urban Transportation: Self-driving cars can travel autonomously on urban roads, reducing...
Page 10
SharkBot Shark Bot is a driverless smart car designed for intelligent transportation system. It is equipped with ESP32 S3 chip as the controller, ultrasonic sensors, roving sensors, voice recognition module, coding motors, RGB lights and other modules, and is capable of realizing multiple functions of autonomous driving.
Page 11
ITS Laboratory Assembling the SharkBot Project Description Build the SharkBot car according to the build step-by-step diagram. Note: step-by-step construction files "English\ACECode(Beginner)\4.Map\7.Assemble documentation" folder included with this tutorial. Hardware Scheme 1. Hardware list Picture Name Quantity Car PCB Ultrasonic sensor Wheels Acrylic plate set...
Section 2 Basic Motion of Smart Car Course Objectives Understand the working principle of the N20 motor. Master the control methods of the N20 motor. Master the basic motion control methods of the SharkBot car. Program to make the SharkBot walk in a square. How does a smart car move? Where does its "power"...
Page 14
need to understand the working principle of the motor, and learn to control the behavior of the motor through programming. The SharkBot uses the N20 motor. Next, we will explore how to control the movement of the SharkBot together. N20 motor 1.N20 motor introduction N20 motor is a kind of miniature DC motor, its working principle is based on electromagnetic induction.
Page 15
No-load speed 200 rpm Rated torque 3.0 kg.cm Deceleration ratio 1:150 2. Control of N20 Motor The N20 motor belongs to the category of DC motors, and its speed and direction of motion can be adjusted by adjusting the current. However, the ESP32 controller itself does not have the ability to directly drive DC motors, so it must use the driver chip to indirectly control the motor, and use PWM (Pulse Width Modulation) wave technology to accurately control the motor's operation.
Page 16
Pin21 LeftMotor Basic Motion Control for Smart Cars To control the Sharkbot smart car, you need to add the corresponding extension in ACECode. Open ACECode, click the 'Add Extension' button at the bottom left corner, and select 'Sharkbot' from the pop-up page. After adding the "Sharkbot"...
Page 17
Smart car typically achieve motion control through differential drive. Differential drive involves controlling the rotational speed and direction of the left and right wheels to enable movements such as forward, backward, left turn, and right turn of the smart car. In ACECode, there are multiple ways to implement the basic motions of the smart car: Method 1: Input corresponding PWM values to the left and right motors to control their movements.
Page 18
positive input value makes the motor rotate forward, while a negative input value makes it rotate backward. The larger the numerical value, the higher the motor speed. ① Forward movement: Both the left and right wheels rotate forward simultaneously at the same rotational speed. ②...
Page 19
Alternatively ⑤ Stop: Both the right and left wheels come to a halt. Method 2: Besides setting PWM values for each motor separately as in Method 1, ACECode provides a simpler way to control the basic movements of the smart car. Command 1: After entering the PWM value, select the smart car's motion direction from the dropdown menu.
Page 20
Tips In the implementation of the task of controlling the car traveling in a straight line, due to the inconsistency of the performance of the motor, the wheels are subject to ground friction differences and other factors, even if we set the same speed parameters to the two motors, the car in the actual driving process may still appear to deviate from the predetermined path of the situation.
ITS Laboratory The Smart Car Travels In A Square Project Description Programming the smart car to follow a square path in a clockwise direction. Hardware Scheme 1.Hardware List Picture Name Quantity SharkBot Type-C Data Cable...
Page 22
Programming 1.Program Flowchart 2.Coding The program source files included in this course are located in the "English\ACECode(Beginner)\3.ACECode program" folder within the materials provided with this tutorial. Click here to access the program files for this project.
Page 23
Tips 1.Before uploading the program, you need to switch ACECode to "Upload mode" and select the mainboard model as "ESP32S3". 2. Due to factors such as motor performance variations and different ground friction, the numerical values of the following parameters need to be adjusted according to actual conditions.
Section 3 Lighting Systems For Smart Cars Course Objectives Understand the working principle of RGB lights Understand the principle of the three primary colors of light Master the control methods of RGB lights Design the lighting system for an smart car Have you ever noticed the lights on your car? What do they do? Lights on a car are not just for...
Page 25
turn and so on. In addition, lights can also be used to beautify the appearance of the smart car, making it more technological sense. The lighting system on the SharkBot is composed of a WS2812 light strip containing two RGB light beads. Next, let's learn about the working principle of the WS2812 and design the lighting system for the SharkBot.
Page 26
RGB Light Strip Control The RGB LEDs on the WS2812 LED strip can be controlled individually in ACECode. The control commands for the LED strip are as follows: Command 1: Select the vehicle's "Left", "Right", or "All" lights from the dropdown menu, and adjust the RGB LED colors by modifying parameters such as "Color", "Saturation", and "Brightness".
Page 27
Light's three primary colors The working principle of RGB tri-color lamp is closely related to the principle of three primary colors. Primary colors are red, green and blue, they are the three primary colors of light, through different proportions of the mixture can produce a variety of colors.
Page 28
Right Turn: The right light is yellow, indicating that the vehicle is about to make a right turn. Stop: The light shows red, indicating that the vehicle has stopped. Through the combination of lights and motion states, smart cars can better interact with other vehicles and pedestrians to improve driving safety.
Page 29
ITS Laboratory Designing the Lighting System for Smart Cars Project Description Through the programmed control of RGB three-color lights, it realizes the combination of lights and the motion state of the smart car. Hardware Scheme 1.Hardware List Picture Name Quantity SharkBot Type-C Data Cable...
Page 31
2.Coding The program source files included in this course are located in the "English\ACECode(Beginner)\3.ACECode program" folder within the materials provided with this tutorial. Click here to access the program files for this project.
Chapter 7 Intelligent Driving In addition to realizing automatic driving, the intelligence of smart cars is also reflected in its ability to respond flexibly to changes in the environment and realize intelligent driving. Intelligent driving is the core ability of smart cars, which allows the vehicle to perceive the environment, analyze data and make decisions, so as to achieve safer, more efficient and more intelligent driving.
Section 1 Intelligent Obstacle Avoidance Course Objective Understand the working principle of the ultrasonic sensor Comprehend the principle of obstacle avoidance using the ultrasonic sensor Program to achieve automatic obstacle avoidance for SharkBot In the process of traveling, smart cars may encounter various obstacles, such as walls, furniture, pedestrians, etc.
Page 34
driving. The realization of this function requires the use of obstacle avoidance sensors, which can help the smart car "see" the obstacles ahead. There are many ways to realize automatic obstacle avoidance, common methods include: Ultrasonic Obstacle Avoidance:Utilizes ultrasonic sensors to detect the distance of obstacles ahead.
Page 35
40KHz) triggers the sensor to transmit ultrasonic waves. 2. Receive The Reflected Wave: ultrasonic waves encountered obstacles reflected back, received by the sensor, Echo pin output high level, did not receive the reflected ultrasonic waves, Echo pin output low level. We can calculate the duration of the high level of the Echo pin to obtain the propagation time of the ultrasonic wave.
Page 36
Note: In ACECode, after calculation and conversion, the ultrasonic distance measurement formula is: (Ultrasonic travel time) / 58, with the unit in centimeters (cm). The Principle of Ultrasonic Obstacle Avoidance The principle of ultrasonic obstacle avoidance is to use ultrasonic sensors to detect the distance of the obstacles in front, and adjust the motion state of the smart car according to the detection...
Page 37
Detection distance:The ultrasonic sensor continuously monitors the distance to the obstacle ahead. Determination of distance: Once the detected distance is less than the preset safety threshold, it is determined that there is an obstacle ahead. Perform obstacle avoidance: According to the obstacle avoidance strategy, the smart car can choose to stop, backward or steering and other operations.
ITS Laboratory Automatically Avoid Obstacles For Smart Cars Project Description The automatic obstacle avoidance function of the smart car is realized through programming. Hardware Scheme 1.Hardware List Picture Name Quantity SharkBot Type-C Data Cable...
Page 40
2.Coding The program source files included in this course are located in the "English\ACECode(Beginner)\3.ACECode program" folder within the materials provided with this tutorial. Click here to access the program files for this project.
Section 2 Anti - Collision Alarm System Course Objective Understand the working principle of the buzzer Understand the applications of the buzzer Comprehend the principle of the anti-collision alarm system Design an anti-collision alarm system for the smart car Have you ever seen a car make a "ticking" sound when you are backing up? How does it work? In everyday life, when a car is maneuvering in reverse or approaching an obstacle, a "tick-tock"...
Page 42
Anti-Collision Alarm Systems A collision alarm system is a safety system that detects obstacles through sensors and sounds an alarm when a hazard is detected. Its core objective is to prevent equipment from colliding with obstacles, thereby avoiding accidents and damage. Collision Avoidance Alarm System Workflow: Detection Phase: The system uses sensors (e.g.
Page 43
built-in oscillator and require an external signal to provide the operating frequency. It usually has a piezoelectric ceramic element inside, which deforms when an alternating voltage is applied and produces a sound. Passive buzzers are widely used in electronic devices that require audible alerts or alarms, such as alarm systems, home appliances, automobiles, timers and embedded systems.
Page 44
ITS Laboratory Anti-Collision Alarm System Project Description Through programming to realize the anti-collision alarm function of the smart car, when encountering an obstacle, the smart car emits an alarm sound and lights up a red light, and then automatically avoids obstacles.
Page 46
2.Coding The program source files included in this course are located in the "English\ACECode(Beginner)\3.ACECode program" folder within the materials provided with this tutorial. Click here to access the program files for this project.
Section 3 Vehicle-Mounted Music Course Objective Understand the principle of sound generation Understand the composition of music Program the SharkBot car to play music Do you want music in your car? How do you get the SharkBot to play music? In-vehicle music is an essential part of the car, which can relieve passengers' fatigue through soothing melodies and create a...
Page 49
How is sound generated? The foundation of music is sound. In order to understand the origin of music, we must first understand how sound is produced. Sound is triggered by the vibration of an object. When an object vibrates, the air, which is in close contact with it, also vibrates, creating sound waves.
Page 50
Rhythm controls the timing of notes. Every piece of music in the score has its own beat, which indicates how long the note lasts. This is shown as follows: (1) An ordinary note, such as "1", which occupies one beat. (2) If a note is underlined, e.g.
Page 51
ITS Laboratory Vehicle-Mounted Music Project Description Program the SharkBot to play <Twinkle Twinkle Little Star>. Hardware Scheme 1.Hardware List Picture Name Quantity SharkBot Type-C Data Cable...
Page 53
2.Coding The program source files included in this course are located in the "English\ACECode(Beginner)\3.ACECode program" folder within the materials provided with this tutorial. Click here to access the program files for this project.
Section 4 Intelligent Line Following (I) Course Objective Understand the working principle of the grayscale sensor. Comprehend the algorithm for 2 - channel grayscale sensor line following. Program to implement the simple line - tracking function of the smart car. How do you get a smart car to follow a fixed route? In some automation scenarios, such as logistics cars or smart buses in factories, it is often...
Page 55
used to realize the tracking function include: grayscale sensors, infrared sensors, magnetic sensors, LIDAR, vision sensors, etc. In this lesson, we will use grayscale sensors to realize the tracking function of smart cars. In this lesson, we will use the grayscale sensor to realize the tracking function of the smart car.
Page 56
following logic: 1. Sensor Layout Mount the two grayscale sensors symmetrically in the center of the front of the SmartBot, directly in front of the black line. On the SharkBot, of the two sensors in the center, the one on the left is connected to Pin5 of the ESP32 and the one on the right is connected to Pin6 of the ESP32.
Page 57
whether the sensor detects the black line. If the grayscale value of the sensor is lower than the threshold, it is considered that the black line is detected; otherwise, it is considered that the white ground is detected. In ACECode, you can measure the grayscale sensor values through the serial monitor.
ITS Laboratory Intelligent Line Tracking (I) Project Description Programming is implemented to make the smart car follow the black trajectory on the map. The map is shown below: Note: the map need to print their own, print the file can be attach ed to the tutorial folder "English\ACECode(Beginner)\4.Map\Map1(6 0x90cm).pdf".
Page 60
2.Coding The program source files included in this course are located in the "English\ACECode(Beginner)\3.ACECode program" folder within the materials provided with this tutorial. Click here to access the program files for this project.
Page 61
Attention If the car fails to travel normally during line tracking, this may be due to the following reasons: 1. The car is too slow. To solve the problem, you can increase the value of the motor PWM in the program to give the cart enough speed.
Section 5 Intelligent Line Following (II) Course Objective Understand the algorithm of line following using a 4-channel grayscale sensor. Program and implement the complex line-following function of an smart car. If the route becomes complicated (e.g., curves, intersections), do you think the 2-way sensor will still be able to handle it? In the last lesson, we used 2-channel grayscale sensors to realize a simple...
Page 63
grayscale sensors to realize the smart car's tracking function on complex routes. 4 - Channel Grayscale Sensor Line Tracking Algorithm 1. Sensor Layout The 4-channel grayscale sensor consists of four independent grayscale sensors, which are usually installed in front of the bottom of the smart car, lined up in a row, with the middle two sensors facing the black line, and the first and fourth sensors on both sides of the black line respectively.
Page 64
Sensor status smart car adjusting its movement Straight ahead Turn left Turn left Turn left Turn left Turn right Turn right Turn right Turn right...
Page 66
ITS Laboratory Intelligent Line Tracking (II) Project Description Programming is implemented to make the smart car follow the black trajectory on the map. The map is shown below: Note: The map needs to be printed by yourself, the print file is in the folder "English\ACECode(Beginner)\4.Map\Map2(60x90cm).pdf"...
Page 67
Programming 2.Coding The program source files included in this course are located in the "English\ACECode(Beginner)\3.ACECode program" folder within the materials provided with this tutorial. Click here to access the program files for this project.
Page 69
Attention If the car fails to travel normally during line tracking, this may be due to the following reasons: 1. The cart is too slow. To solve the problem, you can increase the value of the motor PWM in the program to give the cart enough speed.
Section 6 Speed Measurement Course Objective Understand the working principle of the encoder Understand the method of speed measurement using an encoder Write a program to measure the speed of the SharkBot motor How to accurately measure the speed of a smart car while it is traveling? Real-time monitoring of car speed is a very important function during the operation of smart car.
Page 71
Encoder is a kind of sensor used to detect rotation or linear motion, which convert mechanical displacement into electrical signal and then output pulse signal or digital signal to provide speed, position and direction information. Encoders are divided into photoelectric encoders and Hall encoders according to their working principles. In this lesson, we use incremental Hall encoder.
Page 72
Encoder-based Vehicle Speed Measurement Measuring the speed of smart car is actually measuring the speed of motor. Incremental Hall encoder outputs two-phase pulse signals, A and B, which can calculate the motor speed according to the number and time interval of pulses, and judge the motor rotation direction by detecting the phase relationship between phase A and phase B signals.
Page 73
counterclockwise. When the A-phase pulse signal is rising edge, the B-phase pulse is high level, indicating that the motor rotates clockwise. When the A-phase pulse signal is the rising edge, the B-phase pulse is the low level, indicating that the motor rotates counterclockwise. In ACECode, you can use the following commands to implement the speed measurement function for encoder motors.
Page 74
Command 2: Obtain the pulse count from the encoder. Command 3: Reset the encoder. This command can be used to reset the encoder after each speed measurement.
Page 75
ITS Laboratory Speed Measurement Project Description Through the N20 code motor and ACECode to realize the motor speed measurement, and display in the serial monitor. As shown in the figure below: Hardware Scheme 1.Hardware List Picture Name Quantity SharkBot Type-C Data Cable...
Page 76
Programming 2.Coding The program source files included in this course are located in the "English\ACECode(Beginner)\3.ACECode program" folder within the materials provided with this tutorial. Click here to access the program files for this project.
Page 77
Tips Since the rated voltage of the motor is 12V and the voltage provided by SharkBot is about 8V, the motor may not be able to reach the maximum speed of 200 rpm.
Section 7 Straight Line Driving Of Smart Cars Course Objective Understand the concept of closed-loop feedback Understand the concept of PID Apply the PID algorithm to control an smart car to drive in a straight line When the Smart Car is traveling in a straight line, it sometimes veers to one side and can't go in a straight line? What is the reason? Keeping a straight line is a basic but very...
Page 79
in real time according to the detected speed to ensure that the speed of the two wheels reaches the same value. This real-time control of wheel speed is called closed-loop feedback control. Closed-Loop Feedback Control Closed-Loop Feedback Control is an automatic control method in which the system monitors the output in real time and makes adjustments based on the feedback information to ensure that the system is stable and operates as expected.
Page 80
feedback control is shown as follows: In closed-loop feedback control, the control algorithm is the core, common closed-loop control algorithms are PID algorithm, fuzzy control algorithms, neural network control algorithms, etc., in this session we will focus on PID algorithm. PID Algorithm 1.
Page 81
Integral (I) Control: Adjusts the output according to the accumulated value of the error. Used to eliminate stabilizing errors over long periods of time. Differential (D) Control: Adjusts the output according to the rate of change of the error. It is used to predict the future trend of the error, and is used to eliminate fluctuating errors.
Page 82
Command 4: Set the time interval for PID calculation. Command 5: Set the output range of the PID object. Command 6: Set the input value/output value/desired value of the PID object. Command 7: Perform PID calculation. Command 8: Obtain the value after PID calculation. PID Coefficient Setting In PID control, setting the PID coefficients is the most crucial step.
Page 83
modes of PID. Sometimes a system may only require P control, sometimes PD control, and at other times, complete PID control may be needed. This entirely depends on the specific performance requirements of the system. So how are the PID coefficients set? In the application of a conventional PID regulator, we usually use the trial - and - error method to configure the PID parameters.
Page 84
2. Adjust Kp From the above figure, we find that there is a large error between the actual speed of the left - hand motor and the target speed. First, gradually increase the value of Kp to make the motor speed closer to the target value. Adjustment method: (1) Gradually increase Kp (for example, 1.0, 1.5, 2.0).
Page 85
(3) If a large - amplitude oscillation situation as shown in the figure below occurs, it is necessary to decrease Kp until the oscillation disappears. 3. Adjust Ki If a steady-state error persists after increasing Kp, gradually increase the value of Ki until it reaches an appropriate level.
Page 86
3. Observe whether the speed can stabilize at the target value. 4. If overshooting occurs (speed exceeds the target and then drops back), it indicates that Ki is too large and should be reduced appropriately. The following figure shows the motor's actual speed curve when Ki = 2.0, which almost perfectly aligns with the target value.
Page 87
ITS Laboratory Straight line driving of smart cars Project Description The PID algorithm realizes the smart car to walk in a straight line, and observes its performance under different road conditions. Hardware solution 1. Hardware list Picture Name Quantity SharkBot Type-C Data Cable...
Page 89
2.Coding The program source files included in this course are located in the "English\ACECode(Beginner)\3.ACECode program" folder within the materials provided with this tutorial. Click here to access the program files for this project.
Section 8 Intelligent Voice Control Course Objective Understand the concept of speech recognition. Understand the applications of speech recognition. Master the usage of SharkBot speech recognition commands. Have you ever used a voice assistant on your cell phone? How can you make your smart car also have voice assistant function and control it by voice? With continuous...
Page 92
Now, let's delve deeper into the mysteries of voice recognition so that smart cars can understand and respond to our voice commands. Speech Recognition Speech Recognition is a technology that converts human speech signals into text or instructions. Its core goal is to enable machines to "understand" human language, and according to voice instructions to perform the corresponding operations, widely used in intelligent assistants, automated customer service, voice input, smart home and other fields.
Page 93
Noise reduction treatment: Filtering of ambient noise and extraction of effective sound waves. Feature Extraction:Converts sound waves into spectrograms or MFCC (Mel Frequency Cepstrum Coefficient) features. Keyword Matching: Compare with the preset instruction library and output the matching result A Library Of Speech Recognition SharkBot uses an offline speech recognition module to recognize speech, it will recognize some fixed speech content, and convert these speech content into corresponding hexadecimal data, and then transmit the hexadecimal data to...
Page 94
Turn on the red light Turn on the red light Turn off the red light Turn off the red light Turn on the green light Give the green light Turn off the green light Turn off the green light Turn on the blue light Turn on the blue light Turn off the blue light Turn off the blue light...
Page 95
ITS Laboratory Intelligent Voice Control Project Description Control the smart car by voice to move forward, backward, turn left, turn right, play songs. Hardware Scheme 1.Hardware List Picture Name Quantity SharkBot Type-C Data Cable...
Page 96
Programming 2.Coding The program source files included in this course are located in the "English\ACECode(Beginner)\3.ACECode program" folder within the materials provided with this tutorial. Click here to access the program files for this project.
Page 98
2.Command Explanation Used to complete the initialization operation of the voice recognition module. Use this command to obtain the return value from the voice recognition module. The return value will be "-1" when no command is detected.
Chapter 8 Internet of Things for Intelligent Transportation Have you ever wondered how to report the real-time location of buses in the city? How traffic signals are dynamically adjusted according to the traffic flow? How the roadside electronic screen shows the latest road conditions? Behind all these "Internet of Everything", the support of wireless communication technology is indispensable.
Section 1 Infrared Communications Technology Course Objective Understand the principle of infrared communication. Master the usage of the infrared receiver and infrared remote control. Program to realize the control of the car's movement by the remote control. In addition to controlling your smart car by voice, what other ways can you use to control your smart car remotely? In addition to voice control, infrared remote...
Page 101
Infrared communication technology Infrared communication is a wireless communication technology that utilizes infrared light waves for data transmission. Infrared light is located in the electromagnetic spectrum between microwaves and visible light, with a wavelength range of approximately 700 nanometers to 1 millimeter. The realization of infrared communication mainly depends on two parts: infrared transmitter and infrared receiver.
Page 102
corresponding infrared light pulses. 3. Signaling Infrared LEDs emit pulses of infrared light that travel through the air to the receiving device. Infrared communication is usually short-range and requires a straight path of propagation because infrared light cannot penetrate walls or other opaque objects.
Page 103
IR Remote Controller A commonly used infrared transmitter is the infrared remote control, which consists of several buttons and infrared light emitting diodes. Each button corresponds to a different infrared code value, after pressing the button, the infrared light emitting diode will emit the corresponding code of infrared light. Infrared remote control has various coding methods, the most common coding method is NEC code.
Page 104
Note: The infrared remote control needs to be facing the infrared receiver to send the signal, otherwise it is difficult for the infrared receiver to receive it. Infrared receive module In ACECode, we use the following command to determine whether a button on the infrared remote control is pressed.
Page 105
ITS Laboratory Infrared Remote Control Car Project Description Use the infrared remote control to remotely control the SharkBot smart car to move back and forth, left and right. Hardware Scheme 1.Hardware List Picture Name Quantity SharkBot IR Remote controller Type-C Data Cable...
Page 107
2.Coding The program source files included in this course are located in the "English\ACECode(Beginner)\3.ACECode program" folder within the materials provided with this tutorial. Click here to access the program files for this project.
Section 2 Bluetooth Communication Technology Course Objective Understand the principle of Bluetooth communication Master the usage of the ESP32 Bluetooth module Design the Bluetooth control function for the SharkBot car When there is something in front of the infrared remote control, can it still realize remote control? How to realize barrier-free remote communication? In the previous course, we used infrared...
Page 110
to control the car, we can use Bluetooth communication technology. Next, we will explore the wonders of Bluetooth technology. Bluetooth Communication Bluetooth Communication is a wireless technology standard for the exchange of data over short distances. It allows communication between different devices without the need for a physical connection.
Page 111
scenarios with small amount of data, such as data monitoring. Bluetooth Communication Steps In this lesson, we will use BLE Bluetooth to communicate, low-power Bluetooth devices communicate with each other using the broadcast mechanism, which has the following specific steps: 1.
Page 112
In ACECode, the core commands for Bluetooth control are as follows: Command 1: Create a BLE object and set the service UUID and characteristic UUID. Command 2: Enable BLE and set the Bluetooth name. Command 3: Monitor whether a Bluetooth device is connected. Command 4: Receive data.
Page 113
ITS Laboratory Bluetooth Communication Project Description Programming to achieve control of smart car movement using Bluetooth communication with cell phone. Hardware Scheme 1.Hardware List Picture Name Quantity SharkBot Type-C Data Cable...
Page 114
Programming 2.Coding The program source files included in this course are located in the "English\ACECode(Beginner)\3.ACECode program" folder within the materials provided with this tutorial. Click here to access the program files for this project.
Page 116
(3) Click the "Search" button to search for Bluetooth. (4) After the Bluetooth search is completed, the "Select" button will turn red, then click the "Select" button to enter the Bluetooth list page. (5) Select the Bluetooth that contains the text "SharkBot".
Page 117
(6) Click "Connect" button to connect Bluetooth. (7) After the Bluetooth connection is successful, the "Disconnect" button will turn red, and the "Staus:" at the bottom will change to "Connected". (8)After successful Bluetooth connection, you can control the SharkBot by using the arrow keys.
Understand the concept of the TCP protocol Design the WiFi control function for the smart car Use the ACEBOTT APP to control the smart car WiFi has been everywhere in our life, the most common products with WiFi function are cell phones and computers.
Page 119
the Internet. In fact, now more and more cars with WiFi function, through the WiFi communication technology, to realize the cell phone remote control smart car. How is it realized? Next we decipher it together. WIFI Communication WiFi Communication Technology is a wireless local area network (WLAN) technology that allows electronic devices such as smartphones, tablets, laptops, etc.
Page 120
2. Access Point Mode (also known as AP mode) In this mode, the ESP32 acts as a WiFi generator to create its own WiFi network signal for other devices to connect to. 3. Wireless Mode + Access Point Mode In this mode, ESP32 can either be used as a terminal to access other WiFi networks or as an access point to generate WiFi networks for other devices to access.
Page 121
WiFi communication is only for each device in the hardware level to open the communication channel, so far can not realize the data communication. Because there is no clear identification of the device under the network, the device can not know to whom to transmit data, and do not know where to get the data.
Page 122
192.168.10.136, this address consists of two parts, the first three numbers (192.168.10) is the address of the WiFi network that the device is connected to, and the last number (136) is the address number of the device under that WiFi network.
Page 123
TCP Protocol TCP is a connection-oriented, reliable protocol that ensures that packets arrive at the receiving end in the correct order, and if they are lost or corrupted, TCP will retransmit them. If packets are lost or corrupted, TCP retransmits them.TCP is widely used in applications that require high reliability, such as web browsing, e-mail, and file transfers.
Page 124
3. Disconnect When we don't need wireless communication, we can disconnect the TCP connection to save resources. In ACECode, the main commands for implementing WiFi communication are as follows: Command 1: Configure WiFi in AP mode and set the WiFi name (SSID) and password.
Page 125
ACEBOTT APP to control the smart car movement. The specific steps are as follows: If it is an IOS system phone, you need to search for the keyword: ACEBOTT in the APP Store, and then download; if it is an Android system phone, you need to search for the keyword: ACEBOTT in the Google Play Store, and then download.
ITS Laboratory WiFi Signal Control Smart Car Project Description Control the movement of an smart car through a mobile phone using WiFi communication technology. Hardware Scheme 1.Hardware List Picture Name Quantity SharkBot Type-C Data Cable...
Page 127
Programming 2.Coding The program source files included in this course are located in the "English\ACECode(Beginner)\3.ACECode program" folder within the materials provided with this tutorial. Click here to access the program files for this project.
Section 4 Internet of Vehicles Course Objective Understand the concept of Internet of Vehicles (IoV) Understand the key technologies of Internet of Vehicles Understand the principle of the ESP-NOW protocol Programmatically implement the interaction between smart cars and smart traffic lights In large cities with large numbers of people, there are often traffic jams during rush hour.
Page 134
The concept of Internet of Vehicles Internet Vehicles (IoV) refers connecting vehicles, road facilities, traffic management systems, etc. together through wireless communication technology form intelligent transportation network. In IoV, self-driving cars can not only sense the surrounding environment, but also communicate with Smart Traffic Lights, other vehicles and cloud platforms.
Page 135
ESP-NOW Protocol In the application scenarios of the Internet of Vehicles, it is often necessary to achieve communication between multiple devices. However, the TCP protocol introduced in the previous class only supports point-to-point communication, which does not meet our requirements. Therefore, in the following classes, we will use the ESP-NOW protocol to achieve communication between the SharkBot car and other devices.
Page 136
Wi-Fi. 2.Initialize ESP-NOW Initialize the ESP-NOW communication protocol and enable the associated internal functionalities. 3.Register a transmission callback function (optional) After the data is sent, the ESP32 will automatically invoke this function to provide feedback on whether the transmission was successful. 4.Configure Device Settings Before broadcasting data, you need to configure your device, including its address and other necessary parameters.
Page 137
3.Register a Reception Callback Function Register a callback function. When data is received, the received callback function will be automatically triggered, and the data will be processed within the received callback function. In ACECode, the core instructions for implementing the communication of the ESP-NOW protocol are as follows: Command 1: ESP-NOW...
Page 138
Interaction between smart vehicles and traffic lights In this lesson, we will explore the interaction between the SharkBot car and the smart traffic light in Smart Traffic Level 1. When the SharkBot car arrives at an intersection, the smart traffic light will transmit the traffic light status information to the car via wireless communication.
Page 139
When the SharkBot car arrives at the intersection while following a line, it will decide its movement behavior based on the received traffic light information. If the information indicates a red light, the car will stop; otherwise, it will continue moving forward.
ITS Laboratory Interaction Between SharkBot And Traffic Lights Project Description Programming to realize the interaction between SharkBot and Smart Traffic Light. When SharkBot arrives at a traffic light, if the light is red, it stops, if the light is green or yellow, it moves forward. Note: The experiment needs to use the map, the map print file in this tutorial comes with the information folder "English \ACECode(Beginner)
Page 141
2. Description of maps The SharkBot moves along the black line of the map, and the Smart Traffic Lights are placed as follows: Note: Place the car in the Start area to begin operation.
Page 142
Programming 1. SharkBot Code The program source files included in this course are located in the "English\ACECode(Beginner)\3.ACECode program" folder within the materials provided with this tutorial. Click here to access the program files for this project.
Page 144
2. Smart Traffic Light Code The program source files included in this course are located in the "English\ACECode(Beginner)\3.ACECode program" folder within the materials provided with this tutorial. Click here to access the program files for this project.
Section 5 Intelligent Transportation Integrated System Course Objective Principle of the Intelligent Transportation Integrated System Programmatically implement networking and communication between smart cars and Smart Traffic Lights, Smart Crossing, and Smart Parking Lots. In the previous class, we completed the network communication between SharkBot and the Smart Traffic Lights in Level 1 of intelligent transportation.
Page 147
comprehensive system, SharkBot needs to communicate with three other devices. To enable SharkBot to identify which device the data comes from, it is essential to ensure two-way communication between SharkBot and each device. The specific communication processes are as follows: 1.
Page 148
(3) When SharkBot arrives at the intersection of the Smart Crossing, according to the received traffic light information, it selects the next action. If it is a red light, it stops; otherwise, it continues to move forward. 3. Interaction between SharkBot and the Smart Parking Lot (1) After SharkBot passes through the Smart Crossing, it follows the line to the intersection of the Smart Parking Lot and turns right towards the...
Page 149
ITS Laboratory Intelligent Transportation Integrated System Project Description Programming to realize the comprehensive interaction between SharkBot and Smart Traffic Light and Smart Parking Lot, and complete the design of intelligent transportation system. Hardware Scheme 1.Hardware List Picture Name Quantity SharkBot Type-C Data Cable Smart Traffic Light Smart Parking Lot...
Page 150
2. Description of Map The SharkBot vehicle moves along the black line on the map. The positions of the Smart Traffic Light, the Smart Crossing, and the Smart Parking Lot are as shown below: Note: 1.After arranging the positions of the parking lot and the sidewalk, stick black tape according to this diagram.
Page 151
2.When sticking the tape, leave a certain gap at the connection between the map and the parking lot/sidewalk, which can effectively help the car climb the slope.
Page 152
Programming The program source files included in this course are in the "Englis h\ACECode(Beginner)\3.ACECode program\16ComprehensiveSystem " folder that comes with this tutorial. Click here to obtain the code for SharkBot. Click here to obtain the code for the smart traffic light. Click here to obtain the code for the smart crossing.
Need help?
Do you have a question about the Education Solution Series and is the answer not in the manual?
Questions and answers