https://github.com/saeed-dev2/distance-measurement-with-esp32
https://github.com/saeed-dev2/distance-measurement-with-esp32
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/saeed-dev2/distance-measurement-with-esp32
- Owner: Saeed-dev2
- Created: 2024-07-16T07:06:22.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-10T14:20:13.000Z (almost 2 years ago)
- Last Synced: 2024-12-16T17:54:31.985Z (over 1 year ago)
- Language: Assembly
- Size: 41.2 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Distance Measurement
This project demonstrates how to Measure the distance and how to interface the HC-SR04 ultrasonic sensor with an ESP32 using the ESP-IDF framework. The implementation includes initialization of GPIO pins, sending trigger pulses, measuring echo pulses, and calculating distances.
## Prerequisites
- ESP32 development board
- HC-SR04 Ultrasonic Sensor
- ESP-IDF environment set up
- Connection wires
## Hardware Connections
- Connect the VCC of the HC-SR04 sensor to the 3.3
V of the ESP32.
- Connect the GND of the HC-SR04 sensor to the GND of the ESP32.
- Connect the TRIG pin of the HC-SR04 sensor to GPIO 4 of the ESP32.
- Connect the ECHO pin of the HC-SR04 sensor to GPIO 5 of the ESP32.
## Project Structure
```plaintext
ultrasonic_sensor
├── main
│ ├── CMakeLists.txt
│ └── ultrasonic_sensor.c
├── CMakeLists.txt
└── sdkconfig
```
## Getting Started
1. Create a New ESP-IDF Project
Create a new directory for your project and navigate to it:
```
idf.py create-project my_project
```
2. Build and Flash the Project
Set the target to ESP32, build the project, and flash it to your ESP32 board:
```
idf.py set-target esp32
idf.py build
idf.py flash
```
3. Monitor the Output
Start the serial monitor to see the output:
```
idf.py monitor
```
To exit the serial monitor, press `Ctrl + ]`