Beijing Ultrasonic

  • Products
  • Contact Us
  • No products in cart.
  • EnglishEnglish
    • Español Español
    • Français Français
    • Deutsch Deutsch
    • Italiano Italiano
    • Português Português
    • Українська Українська
    • Русский Русский
    • Türkçe Türkçe
    • Polski Polski
    • Nederlands Nederlands
    • Čeština Čeština
    • Svenska Svenska
    • עברית עברית
    • العربية العربية
    • فارسی فارسی
    • 简体中文 简体中文
    • 日本語 日本語
    • 한국어 한국어
    • हिन्दी हिन्दी
    • Melayu Melayu
    • Indonesia Indonesia
    • Tiếng Việt Tiếng Việt
  • Home
  • Blog
  • Ultrasonic Technology
  • How to Use Ultrasonic Sensor for Proximity or Distance Measurement

How to Use Ultrasonic Sensor for Proximity or Distance Measurement

by Jessie Wong / Friday, 05 August 2022 / Published in Ultrasonic Technology
Ultrasonic transducers or ultrasonic sensors

Ultrasonic sensors are widely used for proximity detection and distance measurement in various applications, ranging from robotics and industrial automation to smart home devices. These sensors are reliable, cost-effective, and highly accurate, making them a popular choice for engineers and developers. This article offers a comprehensive guide on how to use an ultrasonic sensor, such as those from Beijing Ultrasonic, for measuring distance or detecting proximity with precision.

1. Understanding the Working Principle of Ultrasonic Sensors

Ultrasonic sensors operate on the principle of sound wave propagation and echo reflection. The sensor emits ultrasonic sound waves, typically in the range of 20 kHz to 40 kHz, which are inaudible to humans. When these sound waves encounter an object, they bounce back toward the sensor. The sensor then calculates the time it takes for the sound wave to travel to the object and back, using the formula:

Distance = (Speed of Sound × Time Taken) / 2

Here, the factor of 2 accounts for the round trip of the sound wave. The speed of sound in air is approximately 343 m/s at room temperature, but it can vary with temperature and humidity.

2. Components of an Ultrasonic Sensor

A typical ultrasonic sensor consists of two main components:

  • Transmitter: Emits ultrasonic sound waves.
  • Receiver: Detects the reflected sound waves (echo).

Some sensors also include a microcontroller or integrated circuit to process the time-of-flight data and output the distance directly. Sensors like those from Beijing Ultrasonic are known for their high sensitivity and precision.

3. Setting Up an Ultrasonic Sensor

To use an ultrasonic sensor for distance measurement, follow these steps:

  1. Choose the Right Sensor:

    • Consider factors such as the detection range, resolution, and environmental conditions.
    • Beijing Ultrasonic offers a variety of sensors suitable for different applications.
  2. Connect the Sensor to a Microcontroller:

    • Most ultrasonic sensors have four pins: VCC, GND, Trigger, and Echo.
    • Connect VCC to the power supply (usually 5V or 3.3V) and GND to the ground.
    • Connect the Trigger and Echo pins to the appropriate digital input/output pins on the microcontroller.
  3. Write the Control Code:

    • Use a programming language like C, Python, or Arduino code to control the sensor.
    • Send a signal to the Trigger pin to emit a short ultrasonic pulse (typically 10 µs).
    • Measure the time interval between sending the pulse and receiving the echo on the Echo pin.

4. Example Code for Distance Measurement Using Arduino

Below is a simple Arduino code snippet to measure distance using an ultrasonic sensor:

const int trigPin = 9;
const int echoPin = 10;

void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  Serial.begin(9600);
}

void loop() {
  // Send a short 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
  float distance = (duration * 0.034) / 2; // Speed of sound is ~0.034 cm/µs

  // Display the distance in the Serial Monitor
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");

  delay(500);
}

This code initializes the Trigger and Echo pins, sends a pulse, and calculates the distance based on the echo duration. The result is displayed in centimeters on the Serial Monitor.

5. Optimizing Sensor Performance

To ensure accurate and reliable measurements, consider these best practices:

  • Minimize Interference:
    Ultrasonic sensors can be affected by environmental noise and obstacles. Use signal processing techniques or filters to reduce interference.

  • Calibrate the Sensor:
    Calibrate the sensor for optimal performance in your specific environment. For example, account for differences in the speed of sound due to temperature or humidity.

  • Angle and Positioning:
    Position the sensor perpendicular to the target surface to maximize the reflected signal. Angled objects may cause weak or no echo.

6. Applications of Ultrasonic Sensors

Ultrasonic sensors are versatile and can be used in numerous applications, including:

Application Description
Robotics Detect obstacles and navigate environments.
Industrial Automation Monitor liquid levels, detect objects on conveyor belts, and ensure safety.
Automotive Assist with parking by detecting nearby objects or vehicles.
Smart Homes Automate lighting, control room occupancy, or measure tank levels.

Sensors from Beijing Ultrasonic are especially popular in industrial and automotive applications due to their durability and high accuracy.

7. Troubleshooting Common Issues

If the sensor does not work as expected, consider the following solutions:

  • No Output:
    Check the wiring and ensure the power supply matches the sensor’s specifications.

  • Inaccurate Measurements:
    Ensure no obstructions block the sound waves and recalibrate the sensor for the environment.

  • Short Detection Range:
    Verify the sensor’s specifications and ensure it’s suitable for the desired range.

Ultrasonic sensors, such as those manufactured by Beijing Ultrasonic, are essential tools for proximity and distance measurement. By understanding their working principles, setting them up correctly, and optimizing their performance, you can integrate these sensors into a wide range of applications. Whether in robotics, industrial automation, or smart homes, ultrasonic sensors provide a reliable and efficient solution for detecting objects and measuring distances. With proper implementation, you can fully harness their capabilities to meet your project requirements.

What you can read next

Use-Of-Ultrasonic-Cleaners-In-Healthcare-Industry
Use of Ultrasonic Cleaners in Healthcare Industry
How to activate humidifier
How long can biodiesel be stored

Product categories

  • Piezoceramics
    • Piezoceramic Ball/Hemisphere
    • Piezoceramic Cylinder
    • Piezoceramic Discs
    • Piezoceramic Rings
    • Piezoceramic Square/Rectangular
    • Piezoceramic Tube
  • Ultrasonic Cleaner
    • 120kHz Digital Ultrasonic Cleaner
    • 40kHz Digital Ultrasonic Cleaner
    • 80kHz Digital Ultrasonic Cleaner
    • Dual Frequency Digital Ultrasonic Cleaner
    • Immersible Ultrasonic Transducer
    • Industrial Ultrasonic Cleaner
    • Mechanical Ultrasonic Cleaner
    • Power Adjustable Digital Ultrasonic Cleaner
  • Ultrasonic Generator
    • [100-120V] Ultrasonic Transducer Driver Circuit & Transducer Bundles
    • [100-120V/200-240V] Ultrasonic Transducer Driver Circuit & Transducer Bundles
    • [200-240V] Ultrasonic Transducer Driver Circuit & Transducer Bundles
    • Digital Ultrasonic Generator
    • Digital Ultrasonic Transducer Driver Circuit & Transducer Bundles
    • Ultrasonic Transducer Driver Circuit
  • Ultrasonic Humidifier
  • Ultrasonic Meter
  • Ultrasonic Processor
    • Ultrasonic Biodiesel Reactor
    • Ultrasonic Homogenizer
  • Ultrasonic Transducer
  • Ultrasonic Welder

Recent Posts

  • 2L Mechanical Ultrasonic Cleaner Time Temperature-05

    A Comprehensive Guide to Wholesale Ultrasonic Cleaners

    Ultrasonic cleaning technology has revolutioniz...
  • The Benefits of Combining Disruption and Homogenization in a Single Instrument

    Combining disruption and homogenization capabil...
  • Ensuring Cleanroom Compatibility: Ultrasonic Welding in Electronics Manufacturing

    The electronics industry demands manufacturing ...
  • Ultrasonic Welding: A Boon for Innovation in Consumer Goods

    Ultrasonic welding has emerged as a pivotal tec...
  • 5000ML Fog Water Fountain Ultrasonic Cool Mist Humidifier (2)

    The Science of Moisture: How Ultrasonic Humidifiers Add Humidity to Your Air

    Ultrasonic humidifiers have become a popular ch...
  • Beyond Heat and Glue: The Science Behind Ultrasonic Bonds

    The realm of manufacturing and assembly is cons...
  • Ultrasonic Sensors

    From Bumpers to Brakes: Piezoceramic Sensors in Automotive Applications

    Piezoceramic sensors have become indispensable ...
  • From Tough Tissues to Delicate Cells: The Power of Ultrasonic Homogenization for Diverse Samples

    Ultrasonic homogenization, a technique employin...
  • Ultrasonic Cell Disruptor Homogenizer Transducer (4)

    Streamlining Workflows in Microbiology: Ultrasonic Homogenization for Faster Sample Prep

    In the fast-paced world of microbiology, effici...
  • The Future of Sound: How Ultrasonic Generators are Shaping Diverse Industries

    The world of sound extends far beyond what the ...

Customer Care

  • My Account
  • About Us
  • Return Policy
  • Privacy Policy
  • Terms & Conditions
  • Resource Center
  • Blog & News
  • China Public Holiday
  • Sitemap

Technical Info

  • Ultrasonic Cleaner Overview
  • Ultrasonic Cleaner FAQs
  • Ultrasonic Generator Overview
  • Ultrasonic Generator FAQs
  • Ultrasonic Transducer Overview
  • Ultrasonic Transducer FAQs
  • Piezoceramics Overview
  • Piezoceramic FAQs

Product Catalog

Beijing-Ultrasonic-Product-Catalog

Secure Payment

Buy now with PayPal
  • GET SOCIAL

© 2011 - 2026 Beijing Ultrasonic. All Rights Reserved.

TOP