Smart Robot Car Based on Two ESP32 Boards with Bluetooth Communication

ESP32 29-11-26
197 0

Tutorial plan

1- Objective of the project

2- Required Components

3- Circuit Connections of system

4- Micropython programs for ESP32 boards

 

 

Objective of the project

This project involves designing and building a smart four-wheel robot car controlled remotely using two ESP32 development boards communicating via Bluetooth.

The system uses a joystick module connected to the first ESP32 board (transmitter), allowing the user to control the robot's movements intuitively.

The joystick movements are processed by the transmitter ESP32, which sends control commands wirelessly via Bluetooth to the second ESP32 board (receiver) mounted on the robot car.

The receiver ESP32 interprets the received commands and controls the four DC motors through an L298N motor driver module. This allows the robot car to move forward, backward, turn left, turn right, and stop.

The Bluetooth communication eliminates the need for a physical connection between the joystick controller and the robot car, providing convenient wireless control.

This project demonstrates practical applications of embedded systems, wireless communication, and robotics. It helps students understand how two ESP32 boards can exchange data via Bluetooth, how joystick signals can be processed, and how a motor driver controls DC motors to achieve robot movement.

Required Components

1. ESP32 Boards

The system uses two ESP32 development boards. The first ESP32 acts as a transmitter, receiving analog signals from the joystick module and processing them to determine the desired movement of the robot car. It then sends control commands via Bluetooth to the second ESP32, which acts as a receiver. The receiver processes these commands and controls the motors through the L298N motor driver.

2. L298N Motor Driver Module

The L298N is a dual H-bridge motor driver used to control the four DC motors of the robot car. It receives control signals from the receiver ESP32 and regulates the direction and speed of the motors. Its two output channels allow the motors on the left side and right side of the car to be controlled independently.

3. Joystick Module

The joystick module is used to control the direction and movement of the robot car. It contains two potentiometers that detect movements along the X and Y axes, as well as a push button. It sends analog signals to the transmitter ESP32, allowing the user to move the robot forward, backward, left, or right.

4. 5V/3.3V Power Supply

Module d'alimentation

The 5V/3.3V power supply module provides the appropriate regulated voltage to power the receiver ESP32 board and its associated electronic components

5. Four-Wheeled Car Chassis

The four-wheeled car chassis provides the mechanical structure of the robot. It consists of four DC motors, four wheels, and a supporting frame. The motors allow the car to move forward, backward, turn left, and turn right.

6. Connecting wires

Jumper wires

Connecting wires are used to establish electrical connections between the ESP32 boards, joystick, L298N motor driver, motors, and power supply. They ensure the transmission of electrical signals and power throughout the system.

7. Two 3.7V Rechargeable Batteries

The two 3.7V rechargeable batteries provide the electrical power required to operate the robotic car. They supply energy to the L298N Motor Driver Module and the four DC motors, allowing the car to move autonomously according to the commands received from the sender ESP32.

8. Breadboard

plaque d'essai

The breadboard is used to connect and assemble electronic components without soldering. It facilitates the connection of the receiver ESP32 board to the 5V/3.3V power supply module and other electronic components. It allows students to build, test, and modify electronic circuits easily.

9- 9V Battery:


The 9V battery serves as the electrical power source for the system. It supplies power to the 3.3V/5V power supply module, which converts the 9V input voltage into two regulated output voltages: 5V and 3.3V. These voltages are used to power the various electronic components of the system.

 

Circuit Connections of system

1. Transmitter System Assembly (Joystick Controller)

The joystick module is connected to the first ESP32 board to allow the user to control the movements of the robot car.

Joystick Module ESP32 Board Function
VCC 3V3 Powers the joystick module
GND GND Ground connection
VRx GPIO 34 Detects horizontal joystick movements
VRy GPIO 32 Detects vertical joystick movements
SW GPIO 33 Detects joystick button presses

The proposed pins are examples of wiring configurations for a standard ESP32 development board.

2. Receiver System Assembly (Robot Car)

The second ESP32 board receives Bluetooth commands from the transmitter and controls the motors through the L298N motor driver module.

L298N Module ESP32 Board Function
IN1 GPIO 22 Controls the first motor rotation direction
IN2 GPIO 21 Controls the opposite rotation direction
IN3 GPIO 19 Controls the third motor control input
IN4 GPIO 18 Controls the fourth motor control input
ENA GPIO 23 (PWM) Controls the speed of the left-side motors
ENB GPIO 5 (PWM) Controls the speed of the right-side motors
GND GND Common ground connection

Connecting the Motors to the L298N Module

L298N Outputs Connected Components
OUT1 – OUT2 Two motors on the left side
OUT3 – OUT4 Two motors on the right side

The two motors on each side are connected together to operate simultaneously. This configuration allows the robot car to move in different directions by changing the motors' rotation direction and speed.

3. Power Supply Connections

Component Connection Function
9V Battery Power supply module input Main energy source
Power Supply Module 5V output Supplies power to the ESP32 board
Two 3.7V Batteries L298N motor power input Supplies power to the motors
GND of the different modules Common ground Provides a common electrical reference

 

Micropython Programs for the ESP32 Boards

1. Preparation and Configuration of the Two ESP32 Boards

First, both ESP32 boards must be prepared and configured to run MicroPython programs using the Thonny Integrated Development Environment (IDE).

To do this, each ESP32 board is connected individually to the computer using a USB cable. The MicroPython firmware is then installed on each board, and communication with the Thonny programming environment is checked to ensure that the boards are working correctly.

Next, the necessary libraries must be installed and transferred to the memory of both ESP32 boards:

- DCMotor: This library allows the control of DC motors through the L298N motor driver module.

- ble_uart_peripheral.py: This library enables BLE UART (Bluetooth Low Energy Universal Asynchronous Receiver-Transmitter) communication.

- ble_advertising.py: This library handles the broadcasting of the information required for another Bluetooth device to detect the ESP32 board.

Once this configuration is complete, both ESP32 boards are ready to receive their respective programs to transmit and receive the robot car movement commands via Bluetooth.

 

2. Transmitter ESP32 Board Program:

This Micropython program transforms the first ESP32 board into a wireless joystick controller that sends movement commands via Bluetooth to the second ESP32 board, enabling remote control of the four-wheel robot car.

 

3. Receiver ESP32 Board Program:

This MicroPython program configures the second ESP32 board as a Bluetooth Low Energy (BLE) receiver to control the movements of the four-wheel robot car. It receives movement commands from the transmitter ESP32 board and controls the DC motors through the L298N motor driver module.

0 comment

Leave a comment

Veuillez noter s'il vous plaît*

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Purpose of this website

Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.

Contact details

Zaouiet Kontech-Jemmel-Monastir-Tunisia

Pictures of the articles

Robotic site created by Mohamed Ali Haj Salah - Teacher info