The HY-SRF05 is an ultrasonic distance sensor manufactured by Raspberry Pi 4, with the part ID "Ultrasonic distance sensor." This sensor uses sonar technology to measure the distance to an object by emitting ultrasonic waves and calculating the time it takes for the echo to return. The HY-SRF05 is widely used in robotics, automation, and obstacle detection systems due to its accuracy, reliability, and ease of use.
Explore Projects Built with HY-SRF05
Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
This circuit is designed for environmental monitoring and response, featuring sensors for temperature, humidity, distance, and soil moisture, with actuation through a servomotor and audio feedback. It is powered by a solar-charged battery system, indicating outdoor or remote deployment with renewable energy utilization.
This circuit features an Arduino Mega 2560 microcontroller interfaced with an HC-05 Bluetooth Module and an HC-SR04 Ultrasonic Sensor. The HC-05 is powered by the Arduino's VIN pin and is grounded to the Arduino's GND, enabling wireless communication capabilities. The HC-SR04 is powered by the Arduino's 5V output and uses two digital PWM pins (D7 for TRIG and D6 for ECHO) to measure distances via ultrasonic waves.
This circuit is a microcontroller-based control and monitoring system. It uses an Arduino UNO to read from a DHT22 temperature and humidity sensor and an HC-SR501 motion sensor, display data on an LCD, and control a water pump and an LED through a relay. The HC-05 Bluetooth module allows for wireless communication.
This circuit is a wireless communication system powered by a 18650 Li-ion battery, featuring an nRF52840 ProMicro microcontroller and an HT-RA62 transceiver module. The nRF52840 handles the control logic and interfaces with the HT-RA62 for data transmission, while the battery provides the necessary power for the entire setup.
The HY-SRF05 is designed to provide accurate distance measurements with minimal power consumption. Below are its key technical details:
Parameter
Value
Operating Voltage
5V DC
Operating Current
15 mA
Measuring Range
2 cm to 400 cm
Measuring Angle
15°
Frequency
40 kHz
Resolution
0.3 cm
Trigger Input Signal
10 µs TTL pulse
Echo Output Signal
Pulse width proportional to distance
Dimensions
45 mm x 20 mm x 15 mm
Pin Configuration
The HY-SRF05 has a 5-pin interface. Below is the pinout and description:
Pin
Name
Description
1
VCC
Power supply pin (5V DC)
2
Trig
Trigger pin: Input a 10 µs TTL pulse to initiate distance measurement
3
Echo
Echo pin: Outputs a pulse width proportional to the measured distance
4
GND
Ground pin
5
OUT (NC)
Optional pin for mode selection (not commonly used; leave unconnected if unused)
Usage Instructions
The HY-SRF05 is simple to use in a circuit. Follow the steps below to integrate it into your project:
Connecting the HY-SRF05
Power the Sensor: Connect the VCC pin to a 5V power source and the GND pin to ground.
Trigger Signal: Connect the Trig pin to a digital output pin of your microcontroller (e.g., Arduino UNO).
Echo Signal: Connect the Echo pin to a digital input pin of your microcontroller.
Optional Pin: Leave the OUT pin unconnected unless you need to use it for specific configurations.
Important Considerations
Ensure the sensor is mounted securely and aligned properly for accurate measurements.
Avoid placing the sensor near ultrasonic noise sources, as this may interfere with its operation.
Use a resistor divider or level shifter if interfacing with a 3.3V microcontroller to avoid damaging the Echo pin.
Example Code for Arduino UNO
Below is an example Arduino sketch to measure distance using the HY-SRF05:
// Define pins for the HY-SRF05 sensor
const int trigPin = 9; // Trigger pin connected to digital pin 9
const int echoPin = 10; // Echo pin connected to digital pin 10
void setup() {
// Initialize serial communication for debugging
Serial.begin(9600);
// Set pin modes
pinMode(trigPin, OUTPUT); // Set trigger pin as output
pinMode(echoPin, INPUT); // Set echo pin as input
}
void loop() {
// Send a 10 µs pulse to the trigger pin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Measure the duration of the echo pulse
long duration = pulseIn(echoPin, HIGH);
// Calculate the distance in centimeters
// Speed of sound = 343 m/s or 0.0343 cm/µs
// Distance = (duration / 2) * 0.0343
float distance = (duration / 2.0) * 0.0343;
// Print the distance to the Serial Monitor
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
// Wait before the next measurement
delay(100);
}
Notes on the Code
The pulseIn() function measures the time (in microseconds) for which the Echo pin remains HIGH.
The distance is calculated by dividing the duration by 2 (to account for the round trip of the sound wave) and multiplying by the speed of sound in cm/µs.
Troubleshooting and FAQs
Common Issues
No Output or Incorrect Distance
Cause: Improper wiring or loose connections.
Solution: Double-check all connections and ensure the sensor is powered correctly.
Unstable or Fluctuating Readings
Cause: Electrical noise or interference.
Solution: Use decoupling capacitors near the power pins and ensure the sensor is not near ultrasonic noise sources.
Distance Always Reads Maximum (400 cm)
Cause: No object within range or incorrect trigger signal.
Solution: Ensure an object is within the sensor's range and verify the trigger signal timing.
Sensor Not Responding
Cause: Faulty sensor or incorrect pin configuration.
Solution: Test the sensor with a different microcontroller and verify the pin connections.
FAQs
Can the HY-SRF05 work with a 3.3V microcontroller?
Yes, but you need a level shifter or resistor divider for the Echo pin to avoid damaging the microcontroller.
What is the maximum range of the HY-SRF05?
The sensor can measure distances up to 400 cm (4 meters).
Can the HY-SRF05 detect transparent objects?
No, the sensor may struggle to detect transparent or very small objects due to poor ultrasonic wave reflection.
How accurate is the HY-SRF05?
The sensor has a resolution of 0.3 cm, but environmental factors may slightly affect accuracy.
By following this documentation, you can effectively integrate the HY-SRF05 ultrasonic distance sensor into your projects and troubleshoot common issues.