A robot car is a type of autonomous vehicle that is equipped with sensors, software, and other technologies to enable it to navigate and drive itself without human intervention. These types of vehicles are also sometimes referred to as self-driving cars, autonomous cars, or driverless cars. They have the potential to transform the way we travel and could potentially revolutionize transportation as we know it.
A robot car that is equipped with Bluetooth technology would be able to connect to other devices via Bluetooth, allowing it to communicate and transfer data wirelessly. This could be used for a variety of purposes, such as receiving instructions or updates from a remote device, or sending sensor data back to a central computer.
The ESP32 is a microcontroller that is often used to build Internet of Things (IoT) devices, as it has built-in WiFi and Bluetooth capabilities. It could potentially be used to build a robot car that is controlled via Bluetooth from a remote device.
To do this, the ESP32 would need to be programmed to receive commands via Bluetooth and translate them into actions for the robot car. For example, the ESP32 could be programmed to move the car forward, backward, left, or right in response to certain commands received over Bluetooth.
The specific steps for building such a robot car would depend on the desired functionality and the available components. Some things to consider might include the type of motors to use for propulsion, how to integrate sensors for navigation and obstacle avoidance, and how to power the device.
Our objective of this project is to produce a robot car controlled by Bluetooth.
ESP32
An ESP32 card is a physical device that includes an ESP32 microcontroller and associated components, such as memory and input/output (I/O) pins. These cards are typically designed to be easily integrated into a project or prototype, and can be plugged into a breadboard or other prototyping platform.
ESP32 cards are often used in Internet of Things (IoT) projects, as the ESP32 microcontroller has built-in WiFi and Bluetooth capabilities, making it well suited for connecting to the internet and communicating with other devices wirelessly. These cards may also include additional features such as sensors, OLED displays, or other components that can be used in a project.
The L298N is a dual H-bridge motor driver IC that is commonly used to control the speed and direction of small DC motors, as well as to drive stepper motors. It can also be used to control the speed and direction of larger motors, such as those found in electric vehicles, by using external power MOSFETs.
The L298N has a number of input and output pins that can be used to control the motors and monitor their status. It can be driven by a microcontroller, such as an Arduino, or by other digital logic devices. The L298N can be used to drive motors in both forward and reverse directions, and the speed of the motors can be controlled by adjusting the duty cycle of the control signals.
A 3.3V/5V power supply module is a device that converts a higher voltage power source, such as a battery or wall adapter, into a regulated 3.3V or 5V output voltage. These modules are commonly used to provide power to electronic circuits and devices that require a stable, low-voltage power supply.
A 2-wheel car robot kit is a collection of components that can be used to build a small, autonomous robot that moves on two wheels. These kits typically include a microcontroller, such as a ESP32 card, to control the robot’s movements, as well as motors, wheels, and other hardware to enable the robot to move and navigate.
2-wheel car robots are often used as educational tools, as they can be used to teach basic principles of robotics, electronics, and programming. They can also be used as a platform for experimenting with different control algorithms, sensors, and other hardware.
This robot kit is composed of:
car chassis.
2 gear motors (1:48)
2 car tires
1 universal wheel
test plate
A test plate is a type of device used in robotics to test the functionality and performance of various components or systems. It is typically a physical platform or structure that is designed to hold and support various test items or devices, such as sensors, actuators, motors, or other types of mechanical or electrical components. Test plates can be used to simulate different environments or conditions, such as temperature, humidity, vibration, or other factors, in order to evaluate the performance of the components or systems being tested. They can also be used to perform a variety of diagnostic or diagnostic tests, such as stress testing, endurance testing, or other types of evaluations.
connecting wires
Wires are used to transmit electrical signals and power to various components such as motors, sensors, and microcontrollers. It’s important to properly route and secure the wires to prevent tangles and damage. There are several methods for doing this, including using cable ties, clamps, and wire looms. It’s also a good idea to use different colors or labeling to identify the different wires and their functions. When connecting wires in a robot, it’s important to follow proper safety procedures, such as using the correct wire stripper and connectors, and wearing protective equipment such as gloves and safety glasses.
To carry out the assembly it is necessary to connect:
Connect pin 23 of the ESP32 board to the ENA pin of the L298N module.
Connect pin 22 of the ESP32 board to pin IN1 of the L298N module.
Connect pin 21 of the ESP32 board to pin IN2 of the L298N module.
Connect pin 19 of the ESP32 board to pin IN3 of the L298N module.
Connect the 5V pin of the ESP32 board to the 5v pin of the power supply module
Connect the GND pin of the ESP32 board to the (-) terminal of the power supply module
Connect the 12V pin of the L298N module to the 5V pin of the power supply module
Connect the two motors of the car to the L298N board
Here is the micropython program which allows to control the car by the Smartphone
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
from machine import UART from DCMotor import DCMotor from machine import Pin, PWM from time import sleep import bluetooth from ble_uart_peripheral import BLEUART import time import utime frequency = 15000 pin1 = Pin(22, Pin.OUT) pin2 = Pin(21, Pin.OUT) pin3 = Pin(19, Pin.OUT) pin4 = Pin(18, Pin.OUT) enable = PWM(Pin(23), frequency) enable1 = PWM(Pin(5), frequency) dc_motor = DCMotor(pin1, pin2, enable) dc_motor = DCMotor(pin1, pin2, enable, 350, 1023) dc_motor1 = DCMotor(pin3, pin4, enable1) dc_motor1 = DCMotor(pin3, pin4, enable1, 350, 1023) # Create BLE object ble = bluetooth.BLE() # Open UART session for BLE uart = BLEUART(ble) # Define ISR for an UART input on BLE connection def on_rx(): # Read UART string, AppInventor sends raw bytes uart_in = uart.read() # lire le message recu du Smartphone via Bluetooth print("UART IN: ", uart_in.decode()) # afficher le message recu du Smartphone sur le console de Thonny if (uart_in.decode().find('forward')==0): dc_motor.forward(100) # the car moves forward dc_motor1.forward(100) if (uart_in.decode().find(right')==0): dc_motor.forward(100) # the car turns right dc_motor1.forward(10) if (uart_in.decode().find('left')==0): dc_motor.forward(10) # the car turns left dc_motor1.forward(100) if (uart_in.decode().find('backward')==0): dc_motor.backwards(100) # the car backs up dc_motor1.backwards(100) if (uart_in.decode().find('stop')==0): dc_motor.stop() # la voiture tourne a droite dc_motor1.stop() # Map ISR to UART read interrupt uart.irq(handler=on_rx) uart.close() |
– You have to import these libraries :ble_uart_peripheral.py et ble_advertising.py.
– You must use the following firmware : esp32-20210902-v1.17.bin
We will create a mobile application named ‘esp32_car_bluetooth’ with App Inventor which allows you to connect the smartphone to the ESP32 board and command the car.
We therefore suggest that you create the design of the application, with the following visual
To program the application, App Inventor offers us to use the Blocks space which allows you to create a program in the form of a block diagram. Very easy to use but requires some programming logic.
Here is the program of the application made in the Blocks space of the App Inventor:
Remarque:
After installing the mobile application on your Smartphone, you must follow these steps to connect to the ESP32 card you must:
Click on the ‘scan’ button
After finding the Micro:bit card, Click on the ‘Stop’ button
Press the name of the ESP32 board
Finally click on the ‘connect’ button
David 29-11-2222
Hello, sorry I don't know if you can tell me where I can find the DC motor library because it gives me an error when compiling it please