ESP32-Controlled Dual HC-SR04 Ultrasonic Distance Measurement System
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary of the Circuit
This circuit integrates two HC-SR04 Ultrasonic Sensors with an ESP32 microcontroller. The purpose of this setup is to utilize the ultrasonic sensors for distance measurement, with the ESP32 processing the sensor data. The ESP32 is responsible for triggering the sensors and reading the echo signals to calculate the distance to an object. The circuit is powered through the ESP32, which distributes power to the sensors.
Component List
ESP32
- Description: A powerful microcontroller with Wi-Fi and Bluetooth capabilities, suitable for a wide range of applications, including IoT devices.
- Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, VIN, 3V3, D15, D2, D4, RX2, TX2, D5, D18, D19, D21, RX0, TX0, D22, D23, BOOT
HC-SR04 Ultrasonic Sensor
- Description: A popular ultrasonic distance sensor that provides 2cm to 400cm non-contact measurement functionality with a ranging accuracy of up to 3mm.
- Pins: VCC, TRIG, ECHO, GND
Wiring Details
ESP32
- D27: Connected to ECHO pin of the second HC-SR04 Ultrasonic Sensor.
- D14: Connected to TRIG pin of the second HC-SR04 Ultrasonic Sensor.
- D12: Connected to TRIG pin of the first HC-SR04 Ultrasonic Sensor.
- D13: Connected to ECHO pin of the first HC-SR04 Ultrasonic Sensor.
- GND: Common ground with both HC-SR04 Ultrasonic Sensors.
- VIN: Power supply to both HC-SR04 Ultrasonic Sensors' VCC pins.
HC-SR04 Ultrasonic Sensor (First Sensor)
- VCC: Powered by the VIN pin of the ESP32.
- TRIG: Connected to D12 pin of the ESP32.
- ECHO: Connected to D13 pin of the ESP32.
- GND: Common ground with the ESP32.
HC-SR04 Ultrasonic Sensor (Second Sensor)
- VCC: Powered by the VIN pin of the ESP32.
- TRIG: Connected to D14 pin of the ESP32.
- ECHO: Connected to D27 pin of the ESP32.
- GND: Common ground with the ESP32.
Documented Code
No code has been provided for the microcontroller. To operate this circuit, code must be written and uploaded to the ESP32 to handle the triggering of the HC-SR04 Ultrasonic Sensors and to read the duration of the returned echo signals. The code should calculate the distance based on the time interval between sending the trigger signal and receiving the echo signal. The speed of sound is typically used in this calculation, considering the temperature and atmospheric conditions for accuracy.