DIY Speed Radar Using ESP32 and HC-SR04 Sensor

ESP32 10-04-26
11 0

Tutorial plan

1- Objective of the project

2- Required Components

3- Circuit Connections of system

4- Micropython program of ESP32

 

 

Objective of the project

The objective of this project is to design and implement a DIY speed radar system using an ESP32 board, two HC-SR04 ultrasonic sensors, an I2C LCD display, and a buzzer.

The system is designed to measure the speed of a moving object by calculating the time it takes to travel between two fixed points. This project helps demonstrate how embedded systems can be used for real-time measurement and monitoring applications.

It also reinforces concepts such as sensor integration, time measurement, distance-based speed calculation, and human-machine interaction through visual and audio outputs.

Functioning of the Project:

The system works by placing two HC-SR04 ultrasonic sensors at a known fixed distance from each other. When an object passes in front of the first sensor, the ESP32 records the starting time. As the object moves forward and is detected by the second sensor, the ending time is recorded.

The ESP32 then calculates the time difference and uses the distance between the sensors to compute the speed of the object. The calculated speed is displayed on the I2C LCD screen in real time.

If the measured speed exceeds a predefined limit, the buzzer is activated to produce an audible alert, warning that the speed is too high. If the speed is within the acceptable range, a normal status is displayed. The system operates continuously, allowing real-time monitoring of moving objects.

 

Required Components

1. ESP32 board

The ESP32 is the main controller of the project. It processes the signals from the sensors, performs the speed calculations, and manages the output devices such as the LCD display and the buzzer.

2. HC-SR04 sensor

HC-SR04

Two HC-SR04 ultrasonic sensors are used to detect the presence of a moving object at two different points. Each sensor measures distance by emitting ultrasonic waves and receiving the reflected signal. By detecting when an object passes in front of each sensor, the system can calculate the time difference needed to compute speed.

4. LCD Display with I2C Module

The I2C LCD screen is used to display real-time information such as the measured speed, system status, and warning messages.

5. Breadboard 

Breadboard

A breadboard is used to assemble the circuit without soldering. It makes it easy to connect and modify the components during testing and development.

6. Jumper Wires

Jumper wires

Jumper wires are used to connect the ESP32 board, HC-SR04 sensors, and LCD display together. They ensure proper electrical connections between all components.

 

Circuit Connections of system

 

1- Connecting the first HC-SR04 sensor to the ESP32 board

HC-SR04 ESP32 board
VCC 3 V
Trig GPIO 19
Echo GPIO 18
GND GND

 

2- Connecting the second HC-SR04 sensor to the ESP32 board

HC-SR04 ESP32 board
VCC 3 V
Trig GPIO 17
Echo GPIO 16
GND GND

 

3- Connecting the Buzzer to the ESP32 board

Buzzer ESP32 board
 (+) Terminal GPIO 23
(-) Terminal GND

 

4- Connection of LCD I2C display to ESP32 board

LCD I2C display ESP32 board
VCC 5V of GPIO card
GND GND
SDA GPIO 21
SCL GPIO 22

 

Micropython program of ESP32

This Micropython program implements a DIY speed radar system using an ESP32 microcontroller, two HC-SR04 ultrasonic sensors, an I2C LCD display, and a buzzer. The main purpose of the system is to measure the speed of a moving object by calculating the time it takes to travel between two fixed points.

You need to install this libraries : i2c_lcd et lcd_api for I2C LCD screen

At the beginning, the program initializes all components, including the ultrasonic sensors, LCD screen, and buzzer. It then enters an infinite loop where it continuously monitors for the presence of an object. When an object is detected by the first ultrasonic sensor, the system records the starting time. As the object continues moving and is detected by the second sensor, the ending time is recorded.

The ESP32 then calculates the time difference between the two detections and uses the known distance between the sensors to compute the object’s speed in km/h. This speed value is displayed in real time on the LCD screen along with a status message.

If the measured speed exceeds a predefined limit, the buzzer is activated to produce a warning sound, indicating an overspeed condition. If the speed is within the allowed limit, a normal status message is shown. The system repeats this process continuously, allowing real-time speed monitoring of passing objects.

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