An ultrasonic sensor is a device that uses ultrasonic waves to measure distance or detect objects. It emits a sound wave at a frequency above the audible range and measures the time it takes for the echo to return, allowing it to calculate the distance to the object.
Explore Projects Built with ultrasonic sensor
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 features an Arduino UNO microcontroller interfaced with an HC-SR04 Ultrasonic Sensor and an HC-05 Bluetooth module. The Arduino is configured to trigger the ultrasonic sensor to measure distance and communicate the data wirelessly via the HC-05 module. Power is supplied to both the sensor and the Bluetooth module from the Arduino's 5V output, and ground connections are shared among all components.
This circuit is designed to function as an ultrasonic radar system, utilizing an Arduino UNO microcontroller, an HC-SR04 ultrasonic sensor, and an SG90 servo motor. The Arduino controls the servo to sweep the ultrasonic sensor through a range of angles, while the sensor measures the distance to any objects in its path. The system outputs the angle and distance measurements to the serial monitor and provides an indication when an obstacle is detected within 20 cm.
This circuit features an Arduino UNO microcontroller interfaced with an HC-SR04 ultrasonic sensor, a red LED with a series resistor, a buzzer, an I2C LCD 16x2 screen, and an HC-05 Bluetooth module. The ultrasonic sensor is likely used for distance measurement, with the Arduino controlling the LED and buzzer as indicators, displaying information on the LCD screen, and potentially communicating data wirelessly via the HC-05 Bluetooth module. The provided code skeleton suggests that the specific functionalities are yet to be implemented.
This circuit features an Arduino UNO microcontroller interfaced with an HC-SR04 Ultrasonic Sensor, two IR sensors, a servo motor, two DC motors, and an L298N motor driver. The Arduino controls the motors using the L298N driver, with the ability to move them forward or backward at variable speeds as defined in the embedded code. The ultrasonic sensor is used for distance measurement, the IR sensors likely for obstacle detection, and the servo for precise angular movement, all powered by 12V batteries.
Below are the general technical specifications for a commonly used ultrasonic sensor, such as the HC-SR04:
Parameter
Value
Operating Voltage
5V DC
Operating Current
15 mA
Operating Frequency
40 kHz
Measuring Range
2 cm to 400 cm
Accuracy
±3 mm
Trigger Input Signal
10 µs TTL pulse
Echo Output Signal
TTL pulse proportional to distance
Dimensions
45 mm x 20 mm x 15 mm
Pin Configuration and Descriptions
Pin Name
Pin Number
Description
VCC
1
Power supply pin (5V DC)
Trig
2
Trigger pin: Sends the ultrasonic pulse
Echo
3
Echo pin: Receives the reflected pulse
GND
4
Ground pin
Usage Instructions
How to Use the Component in a Circuit
Power the Sensor: Connect the VCC pin to a 5V power source and the GND pin to ground.
Trigger the Sensor: Send a 10 µs HIGH pulse to the Trig pin to initiate the ultrasonic burst.
Read the Echo: Measure the duration of the HIGH signal on the Echo pin. This duration corresponds to the time taken for the ultrasonic wave to travel to the object and back.
Calculate Distance: Use the formula below to calculate the distance:
[
\text{Distance (cm)} = \frac{\text{Time (µs)} \times 0.034}{2}
]
The factor 0.034 is derived from the speed of sound (343 m/s), and the division by 2 accounts for the round trip of the wave.
Important Considerations and Best Practices
Ensure the sensor is mounted securely and aligned properly for accurate measurements.
Avoid placing the sensor near ultrasonic noise sources, as this can interfere with readings.
Use a capacitor (e.g., 10 µF) across the VCC and GND pins to stabilize the power supply.
The sensor may not work reliably with soft or highly absorbent surfaces, as they may not reflect sound waves effectively.
Example Code for Arduino UNO
Below is an example of how to use the HC-SR04 ultrasonic sensor with an Arduino UNO:
// Define pins for the ultrasonic 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 the trigPin as an output and echoPin as an input
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
// Send a 10 µs HIGH pulse to the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2); // Ensure a clean LOW pulse
digitalWrite(trigPin, HIGH);
delayMicroseconds(10); // Send the 10 µs HIGH pulse
digitalWrite(trigPin, LOW);
// Measure the duration of the HIGH pulse on the echoPin
long duration = pulseIn(echoPin, HIGH);
// Calculate the distance in cm
float distance = (duration * 0.034) / 2;
// Print the distance to the Serial Monitor
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
// Wait for a short period before the next measurement
delay(500);
}
Troubleshooting and FAQs
Common Issues and Solutions
No Output or Incorrect Readings:
Ensure the sensor is powered with 5V and properly grounded.
Verify the connections to the Trig and Echo pins.
Check for loose wires or poor soldering.
Unstable or Fluctuating Measurements:
Add a capacitor (e.g., 10 µF) across the VCC and GND pins to filter noise.
Ensure there are no obstructions or reflective surfaces near the sensor.
Sensor Not Detecting Objects:
Ensure the object is within the sensor's range (2 cm to 400 cm).
Check if the object is made of a material that reflects sound waves effectively.
FAQs
Q1: Can the ultrasonic sensor measure through transparent materials like glass?
A1: No, ultrasonic sensors typically cannot measure through transparent materials like glass, as sound waves are either absorbed or refracted.
Q2: What is the maximum angle of detection for the sensor?
A2: The HC-SR04 has a detection angle of approximately 15 degrees. Ensure objects are within this cone for accurate readings.
Q3: Can I use the sensor with a 3.3V microcontroller?
A3: The HC-SR04 is designed for 5V operation. If using a 3.3V microcontroller, a level shifter is recommended for safe operation.
Q4: Why is the distance always showing as zero?
A4: This could happen if the Echo pin is not receiving a reflected signal. Check the alignment and ensure the object is within range.