ESP32 Bluetooth-controlled smart robot car

ESP32 01-12-26
159 0

Tutorial plan

1- Objective of the project

2- Required Components

3- Circuit Connections of system

4- Micropython program for ESP32 board

5- Mobile Application Developed with MIT App Inventor

 

 

Objective of the project

This project aims to design and build a smart robotic car based on an ESP32 development board, controlled remotely via Bluetooth using a mobile application developed with MIT App Inventor. The robot car uses a four-wheel chassis equipped with DC motors and an L298N motor driver module to control its movement. The ESP32 acts as the main control unit, receiving commands from the smartphone and processing them to drive the motors in the desired direction.

The operating principle is based on wireless Bluetooth communication between the smartphone and the ESP32 board. The user interacts with a mobile application developed using MIT App Inventor, which provides control buttons for moving the robot car forward, backward, turning left, turning right, and stopping. When a button is pressed, the application sends a corresponding command to the ESP32 via Bluetooth.

The ESP32 receives and interprets these commands using a MicroPython program. According to the received instruction, it controls the input and enable pins of the L298N motor driver. This module acts as an interface between the ESP32 and the DC motors, allowing the motors to rotate in different directions and controlling the car's movement. The four motors are arranged in two groups: the left-side motors and the right-side motors, enabling coordinated movement and steering.

The mobile application, developed with MIT App Inventor, provides a simple and user-friendly graphical interface. It allows the user to establish a Bluetooth connection with the ESP32 and control the robotic car in real time. This makes the project an excellent practical example of combining mobile application development, wireless communication, programming, and robotics.

Required Components

1. ESP32 Boards

The ESP32 board acts as the main control unit of the robotic car. It receives commands from the smartphone via Bluetooth, processes them using a MicroPython program, and sends control signals to the L298N module.

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. 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

4. 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.

5. 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.

6. 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.

7. 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.

8- 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- Connecting the ESP32 to the L298N Module

The  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

2- 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 Program for the ESP32 board

1. ESP32 Board Preparation and Setup

The first step consists of preparing the ESP32 development board and configuring it to execute MicroPython programs using the Thonny IDE (Integrated Development Environment).

To begin, connect the ESP32 board to the computer using a USB cable. Install the appropriate MicroPython firmware on the board, then configure Thonny to communicate with the ESP32. Test the connection to make sure that the board is correctly recognized and ready for programming.

After installing the firmware, the required MicroPython libraries must be uploaded to the ESP32 board's internal memory. These libraries provide the functions needed to control the DC motors and establish Bluetooth communication:

- DCMotor.py: Provides functions for controlling the DC motors connected to the L298N motor driver, including their rotation direction and speed.

- ble_uart_peripheral.py : Implements Bluetooth Low Energy (BLE) UART communication, allowing the ESP32 to receive commands sent by the mobile application.

- ble_advertising.py: Handles BLE advertising, enabling the ESP32 to announce its availability and be detected by compatible Bluetooth devices.

2. ESP32 Board Program:

This MicroPython program allows an ESP32 development board to control a four-wheel robotic car remotely via Bluetooth using a mobile application developed with MIT App Inventor.

The ESP32 receives movement commands from the smartphone through Bluetooth Low Energy (BLE) communication and controls the DC motors through an L298N motor driver module.

 

Mobile Application Developed with MIT App Inventor

The mobile application was developed using MIT App Inventor, a visual programming environment that makes it easy to create Android applications using graphical blocks. It serves as the remote control interface for the robot car and communicates with the ESP32 board via Bluetooth.

Download application

 

The application features a user-friendly interface consisting of two groups of control buttons:

- Bluetooth connection controls: Four buttons located at the top of the interface allow users to search for nearby Bluetooth devices (Scanner), stop the robot car (Stop), connect to the ESP32 board (Connect), and terminate the Bluetooth connection (Disconnect).

- Movement controls: Four directional arrow buttons enable the user to drive the robot car in four directions: forward, backward, left, and right.

This intuitive interface makes it easy to establish a Bluetooth connection with the ESP32 board and control the robot car remotely using a smartphone.

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