Ultrasonic sensing is one of the best ways to sense proximity and detect levels with high reliability. Our technical support gets emails all of the time about how our ultrasonic sensors work and what environments our sensors work (or don’t work) in. This guide was created as an introduction to ultrasonic sensing, its principles, and how ultrasonic sensors work in your applications. At the top level, you need to know what an sensor is.
What is an Ultrasonic Sensor?
An ultrasonic sensor is an instrument that measures the distance to an object using ultrasonic sound waves. What is an ultrasonic sensor? It is a device that uses a transducer to send and receive ultrasonic pulses that relay back information about an object’s proximity. High-frequency sound waves reflect across boundaries to produce distinct echo patterns.
How Ultrasonic Sensors Work
Ultrasonic sensors work by sending out a sound wave at a frequency above the range of human hearing. The transducer of the sensor acts as a microphone to receive and send the ultrasonic sound. Our sensors, like many others, use a single transducer to send a pulse and to receive the echo. The sensor determines the distance to a target by measuring time lapses between the sending and receiving of the ultrasonic pulse. This process is a key aspect of ultrasonic sensor working.
The working principle of this module is simple. It sends an ultrasonic pulse out at 40 kHz, which travels through the air, and if there is an obstacle or object, it will bounce back to the ultrasonic sensor. By calculating the travel time and the speed of sound, the distance can be calculated. Ultrasonic sensors are a great solution for the detection of clear objects. For liquid level measurement, applications that use infrared sensors, for instance, struggle with this particular use case because of target translucence. For presence detection, ultrasonic sensors detect objects regardless of color, surface, or material (unless the material is very soft, like wool, as it would absorb sound). To detect transparent and other items where optical technologies may fail, ultrasonic sensors are a reliable choice.
Using Multiple Sensors & Avoiding Disruption
To prevent the disruption of the ultrasonic signals coming from your sensor, it’s important to keep the face of the ultrasonic transducer clear of any obstructions.
Common obstructions include:
- Dirt
- Snow
- Ice
- Other Condensation
They are intended specifically for applications requiring the resistance of condensation in high-moisture environments. Our self-cleaning function is designed to run continuously in order for the self-cleaning feature to be active.
Note: The Self Cleaning function is not intended to clean dirt off of the transducer’s surface. Its intent is to clear the transducer’s face of moisture to operate normally.
Using Your Ultrasonic Sensor in Your Project
We used an Arduino in this example, but you can use another controller and program of your choice.
2. INSTALL SOFTWARE
Install Arduino Sketch coding software on your PC. This is where you type the code you want to compile and send it to the Arduino board.
3. SET UP YOUR SENSOR WITH ARDUINO
Plug your Arduino into the USB cable and into your computer. Once you upload Arduino, you can then compile and activate the code.
4. COMPILE AND RUN CODE
The code below will allow you to read distances in centimeters. Compile and run this code to obtain real-time distance measurements to the closest object. (Please note: this code is not only for Arduino and will run on most controllers.)
const int anPin = 0;
long anVolt, cm;
void setup() {
Serial.begin(9600);
}
void read_sensor(){
anVolt = analogRead(anPin);
cm = anVolt/2;
}
void print_range(){
Serial.print(“Range = ”);
Serial.print(cm);
Serial.print(” cm “);
Serial.print('\n');
}
void loop() {
read_sensor();
print_range();
delay(100);
}
Why use an Ultrasonic Sensor?
Ultrasonics are so widely used that they can be reliably implemented in grain bin sensing applications, water level sensing, drone applications, and sensing cars at your local drive-thru restaurant or bank.
Ultrasonic rangefinders are commonly used as devices to detect collisions.
Ultrasonic Sensors are best used in the non-contact detection of:
- Presence
- Level
- Position
- Distance
- Light
- Smoke
- Dust
- Color
- Material (except for soft surfaces, i.e. wool, because the surface absorbs the ultrasonic sound wave and doesn’t reflect sound.)
- Long-range detection of targets with varied surface properties.
Applications Involving Ultrasonic Detection:
Ultrasonic Distance Measuring
Distance measurement is based on the measurement of time-of-flight. The time between sending and receiving the reflected sound signal is calculated by the sensor. An ultrasonic distance sensor, like the MB7360 HRXL-MaxSonar-WR, is used as height monitors, in bin-level measurement and proximity zone detection applications.
- Ex. Distance measurement would be applied in a parking application, sensing when a vehicle is pulled completely into a garage.
- The MB7360 has been used as a bin level sensor to detect the presence or absence of grain and other materials in bins.
People Detection with Ultrasonic Sensors
One detailed use case is this interactive art installation covered in detail on Makezine.com.
We’ve written an article that covers key questions and concerns about the use of our sensors in these types of solutions.
- Why people are traditionally a challenging target for an ultrasonic sensor
- The target types that are ideal
- The benefits of an ultrasonic proximity sensor
Take a look at the following video. nuMedia Innovations developed a solution for a Microsoft Store in Seattle WA to detect human presence on a store display.
Ultrasonic Level Sensors
- Tank level measurement, Fuel gauging, irrigation control.
- This project for a Low Power Water Level Sensor, from Hackster.io developer Amedee, uses a weather resistant sensor from our WR line. In combination with a LoraWan node and The Things IoT open source network, this project was developed to measure the water level in a rainwater tank. Although, it can be used in many applications.
Choosing a Level Sensor
You can read this article to Choose an Ultrasonic Tank Level Sensor which details steps you can take to choose the right ultrasonic sensor for your level sensing application. We cover:
- The important factors to consider when mounting your sensor
- How to handle using the sensor in an environment with harsh chemicals
- Which sensor lines work best for environments where frost on the sensor might be an issue
Using the sensor in harsh environments
If you’re using the sensor in a harsh environment, we suggest the added protection in order for you to successfully use the sensor in your project.
As a brief guide to inform you of the compatibility of our sensors in a few environments, we’ve created the Chemical Compatibility Chart.
A few of the most popular chemical and environment queries are covered here.
Ordering a Fully Sealed Sensor
When you use a ultrasonic sensor from our WR line, the sensor pinout is left exposed, allowing you to attach wires and equipment to the sensor.
The reason we leave it open is that it provides you more flexibility in how you choose to connect to the sensors.
In some applications, it can leave the sensor exposed to the weather.
If your mounting requires you to protect the back of the sensor from damage, you must seal the sensor pinout.
For this, we offer our wire attach option as a solution…
The wire attach option will fully cover the sensor pinout by adding a small cap filled with an epoxy mixture and attached cable.
By adding the additional potting on the back of the sensor, it will seal it against the effects of weather, dust, and water…
This isn’t just for people that just want to protect their sensor, it’s for people with limited soldering experience.
If you don’t want to risk your new sensor with the first attempt soldering it, we highly suggest working with our professional, in-house soldered sensors with wire attachments.