Robotics learning

How ultrasonic sensors Work – and all other questions answered

Last Updated on 16/08/24 0
ultrasonic-sensors.jpg

ultrasonic sensor

“Hey there, have you ever wondered how the robot I have made can ‘see’ without eyes?” ~ Mitthu asked Rajjo with a teasing voice.

“LOL, your robots can’t ‘see’, they just hear.” ~ Rajjo replied and now it was time for Mitthu to take a chill pill.

Imagine a robot that can zoom around your room without bumping into anything… pretty cool, right? The secret behind this robotic magic is something called an ultrasonic sensor. In this blog post, we’ll learn how ultrasonic sensors work, how to use them and what the applications of ultrasonic sensors are.

And yes, we will know who was right out of Mitthu and Rajjo. 🙂

What is ultrasound or ultrasonic?

Let’s first know what makes the ultrasonic sensors so unique — ultrasound!

Ultrasound refers to sound waves that have a frequency higher than what humans can hear. Sound waves are vibrations that travel through the air, water, or even solid objects, and frequency is how fast these vibrations happen. Frequency is measured in hertz (Hz), which tells us how many times something vibrates per second.

Human ears can hear sounds ranging from about 20 Hz to 20,000 Hz (20 kHz). So, next time your friend is not listening to your advice, you can ask if they have a different hearing range altogether. 🙂

Any sound above 20 kHz is called ultrasound or ultrasonic. These sounds are so high-pitched that we can’t hear them at all. But animals like dogs and bats can! For example, dog whistles emit ultrasound, so your dog can hear them, but you can’t. Most ultrasonic sensors use frequencies around 40 kHz—way above what our ears can pick up.

What is an Ultrasonic Sensor?

An ultrasonic sensor is a sensor that uses ultrasonic waves to detect an object, measure the distance and determine if it is in motion.

Ultrasonic sensors are also known as distance sensors, ultrasound sensors, sonar, proximity sensors and level sensors.

You might have seen ultrasonic sensors in action without even knowing it. Ever noticed those beeping sounds when a car is reversing? That’s the car using ultrasonic sensors to avoid hitting anything. They’re also in robotic vacuum cleaners, helping them navigate your house without getting stuck.

How Does an Ultrasonic Sensor Work?

Alright, here’s the science of sound, but don’t worry—it’s fun and simple!

1. The ultrasonic sensor has a transmitter and a receiver.

ultrasonic sensor transmitter receiver

2. The transmitter chirps ultrasound waves that travel through the air.

how transmitter works in ultrasonic sensor

3. If something comes between these waves like a wall or a toy, they bounce back to the sensor. We call that the echo.

how receiver works in ultrasonic sensors

4. The receiver of the sensor then listens for the echo and measures how long it took for the waves to come back.

5. By calculating how much time it took for the sound wave to come back , the sensor can figure out how far away the object is.

This process is called echolocation and is very similar to how bats and dolphins use to spot their prey, or anything else.

Let’s understand the distance calculation by an example.

An ultrasonic sensor sends a sound wave which returns in 0.02 seconds.

At 20°C the sound travels at a speed of 343 meters per second.

Distance = speed * time

So the distance = 343 * 0.02
= 6.86 meters

BUT this 0.02 seconds is a combination of sending and receiving the signal- to and fro. So we will have to divide the distance by two in order to get the actual distance between the sensor and the object.

6.86 / 2 = 3.43 meters

That’s the answer.

And our formula to calculate the distance between sensor and the object becomes 343 * time / 2.
We will get the answer in meters which can further be converted into other units.

distance calculation in ultrasonic sensor

Remember that speed of sound changes with temperature. For example at 0°C it’s 331.4 m/s and at 25°C it’s 246 m/s.

There are ultrasonic sensors with just one unit for transmitter and receiver, known as transceiver. This makes the sensor very compact.

Applications of Ultrasonic Sensors

Ultrasonic sensors aren’t just for robots! They’re used in all sorts of cool ways:

  • In Robotics: These sensors help robots avoid obstacles, just like how we use our eyes to see where we’re going.

ultrasonic in robotics

  • In Everyday Life: Automatic doors, parking sensors, and even some video game controllers use ultrasonic sensors.
  • Creative Projects: Imagine building a gadget that shows how far the ball went from the stumps. Several other projects in the domains of smart city, smart home, automation, smart vehicles, robots, sports and others can be built using ultrasonic sensors. These can be either realistic applications or prototypes which can further be converted into a professional system.

How do submarines spot distant submarines, torpedoes and other objects under the water? They use Sonar and it’s very much the same as ultrasonic sensors when it comes to principles. They are much more powerful and accurate than ours, though.

ultrasonic sensor in submarines

How to use ultrasonic sensors

We have built so many projects using IR and Light sensors in the Havi Elements DIY Robotics starter kit. Unlike IR and light sensors, ultrasonic needs a controller to process the data received from the sensor.

We can use Arduino, ESP32, RaspberryPi or Havi’s controller element to process the ultrasonic data and measure the distance.

Though fundamentals, process and programming are similar, connecting the ultrasonic element with controller element is much easier and faster compared to Arduino.

How to Connect an Ultrasonic Sensor to Controller element

1. What You’ll Need:

  • Havi controller element
  • Ultrasonic element
  • Power banks and USB cables – 2

2. Making the Connections:

When you connect an ultrasonic sensor with Arduino, you will need jumper wires, breadboard and will have to take care of VCC pin, GND pin, Trigger ping and Echo pin.

But with the Havi controller element you just snap the ultrasonic into one of the input ports and you are done.

havi controller with ultrasonic sensor

3. Writing the Code:

Here is a simple code snippet written in Python. This code sends out a sound wave, measures how long it takes to bounce back, and then calculates the distance to the object.

from havi import ports
import machine
import time
from time import sleep
ultrasonic = ports.input1('us')
distance = int(ultrasonic.distance_cm() + 2.00000)
sleep(0.3)

Frequently asked questions about ultrasonic sensors

Following are some of the common questions kids do ask while making DIY Robotic projects with ultrasonic sensors. These would be handy for kids, teachers and parents.

Q: What’s the working principle of an ultrasonic sensor?
A: It sends out sound waves and listens for the echoes to measure the distance—echolocation!

Q: How does ultrasonic sensor detect motion?
A: The sensor can detect the distance. If the distance is changing, the sensor can determine that the object is in motion.

Q: What’s the range of an ultrasonic sensor?
A: Most sensors can measure distances up to about 4 meters.

Q: How do I know if my ultrasonic sensor is working?
A: You can test it by connecting it to a controller element and seeing if it correctly measures the distance to an object.

Q. Where does ultrasonic sensors don’t work?
A: Sound waves can’t travel in vacuum, hence ultrasonic sensors can’t work in vacuum.

Q. What is blind zone of ultrasonic sensor?
A: If the object is too close for the receiver to detect the echo, the sensor won’t detect the object. That area in which the sensor won’t work is known as blind zone. (Which movie scene comes to mind here? :D)

What are the advantages and disadvantages of ultrasonic?

Just like everything else in the world of technology, ultrasonic sensors come with their own set of strengths and weaknesses. Let’s break it down in a way that’s easy to understand!

Advantages of Ultrasonic Sensors

  • Works accurately in any Light Condition, any colors and shapes.
  • Works very well with liquids.
  • Ultrasonic sensors can measure distance or detect objects without touching them.
  • These sensors are very precise, especially at short ranges. They can detect even small objects and provide accurate measurements, which is why they’re popular in robotics and automation.
  • Ultrasonic sensors can detect objects made of different materials, including metal, plastic, and wood.

Disadvantages of Ultrasonic Sensors

  • While ultrasonic sensors are great at detecting objects up to a certain distance, they don’t work well over long distances.
  • Some materials, like foam, sponge, wool and cotton, can absorb sound waves rather than reflecting them. This can make it harder for the sensor to detect these objects or measure their distance accurately. Got the idea to make “Mr. India”? 😀
  • Ultrasonic sensors can be affected by changes in temperature, humidity, and air pressure.
  • Even though ultrasonic sensor chirps unique sound frequency every time and waits to listen for only the one it has sent, but still there is a possibility of interference from other ultrasound waves present around it.

And there you have it Rajjo! Yes with ultrasonics, the robots do “listen”.

We’ve explored the fascinating world of ultrasonic sensors and learned how they work. Keep experimenting, keep building, and most importantly—have fun with technology!

And there you have it Rajjo! Yes with ultrasonics, the robots do “listen”.
We’ve explored the fascinating world of ultrasonic sensors and learned how they work. Keep experimenting, keep building, and most importantly—have fun with technology!

Liked this article? Share with your friends

0
0
Your Cart
Your cart is empty
Calculate Shipping
Apply Coupon