discord: / discord
In this video I show how to connect an HY-SRF05 ultrasonic distance sensor to an ESP8266 and read distance values using a simple Arduino sketch.
The HY-SRF05 has five pins: VCC, GND, TRIG, ECHO, and OUT.
For this setup we only use TRIG and ECHO, since that is enough to measure distance.
Wiring used in the video:
VCC → 5V
GND → GND
TRIG → D1
ECHO → D2
The sensor works better with 5V, so it is powered from the 5V pin instead of 3.3V.
The script sends a pulse from the TRIG pin, waits for the signal on ECHO, and calculates the distance using the speed of sound. The measured distance is printed to the Serial Monitor, updating in real time.
This setup is commonly used for:
• obstacle detection
• robotics projects
• distance measurement
• IoT automation
Full code is shown in the video.