Ultrasonic Sensors: How They Work (and How to Use Them with Arduino)

게시자

When you need input from the real world to your robot or data collection system, there are several options to choose from:

Light detection (infrared sensors, light-dependent resistors, and computer vision setups)

• Sensors based on magnetic fields

• Ultrasonic sensors

How Does an Ultrasonic Sensor Work?

Ultrasonic sensors work by emitting sound waves at a frequency too high for humans to hear. They then wait for the sound to be reflected back, calculating distance based on the time required. This is similar to how radar measures the time it takes a radio wave to return after hitting an object.

While some sensors use a separate sound emitter and receiver, it’s also possible to combine these into one package device, having an ultrasonic element alternate between emitting and receiving signals. This type of sensor can be manufactured in a smaller package than with separate elements, which is convenient for applications where size is at a premium.

While radar and ultrasonic sensors can be used for some of the same purposes, sound-based sensors are readily available—they can be had for just a couple dollars in some cases—and in certain situations, they may detect objects more effectively than radar.

For instance, while radar, or even light-based sensors, have a difficult time correctly processing clear plastic, ultrasonic sensors have no problem with this. In fact, they’re unaffected by the color of the material they are sensing.

On the other hand, if an object is made out of a material that absorbs sound or is shaped in such a way that it reflects the sound waves away from the receiver, readings will be unreliable.

If you need to measure the specific distance from your sensor, this can be calculated based on this formula:

Distance = ½ T x C

(T = Time and C = the speed of sound)

At 20°C (68°F), the speed of sound is 343 meters/second (1125 feet/second), but this varies depending on temperature and humidity.

Specially adapted ultrasonic sensors can also be used underwater. The speed of sound, however, is 4.3 times as fast in water as in air, so this calculation must be adjusted significantly.

What are Ultrasonic Sensors Used For?

So where can we use these sensors? Robot navigation comes to mind, as well as factory automation. Water-level sensing is another good use, and can be accomplished by positioning one sensor above a water surface. Another aquatic application is to use these sensors to “see” the bottom of a body of water, traveling through the water, but reflecting off the bottom surface below.

Though it might not be immediately obvious, if configured correctly ultrasonic sensors can even measure fluid flow rates. In the simplest case, an emitter and a receiver (separate in this configuration) are aligned with the flow of a fluid. Since sound is traveling through a moving medium, the speed of sound relative to these elements will be increased or decreased by the velocity of the fluid. This can be applied to flow inside pipes by aligning these two elements at an angle to each other, calculating the effective velocity increase based on the trigonometric relations between the two.

Flowrate accuracy can be increased by using data from multiple ultrasonic elements, giving results accurate to within a fraction of a percent.

Incorporating Ultrasonic Sensors into Arduino Projects

Arduino Ultrasonic Sensor

If this all sounds interesting, you can try it out yourself very easily using an Arduino and an HC-SR04 sensor. Shown above is the compact and inexpensive Arduino Nano, but any other development board should also work. Gather the components (Arduino, HC-SR04, wires, and breadboard) and go into the Arduino IDE and install the “NewPing” sensor library.

관련 상품 참조

Arduino Nano | A000005

Arduino Corporation Embedded System Development Boards and Kits 보기

Once installed, there will be a number of new example sketches you can choose from.

Open up the “NewPing3Sensors” sketch.

Attach pins from your Arduino to the HC-SR04, as defined in the program, adding ground and 5V from the Arduino.

Send the program to your dev board, and then open up a serial monitor at 115200 baud. You’ll see a distance reading when you put something in front of it. Note that it reads “0” when it doesn’t properly read a distance.

Try experimenting with different shapes and materials to see what works and what doesn’t. I was pleased to find that acoustic foam paneling does not return a signal, while flat smooth surfaces like a phone screen or piece of paper are sensed quite well.

 Click here for more Arduino information and ideas. 

Overstock AV Page Footer 560x140 2 1 1

최신 뉴스

Sorry, your filter selection returned no results.

개인정보 보호정책이 업데이트되었습니다. 잠시 시간을 내어 변경사항을 검토하시기 바랍니다. 동의를 클릭하면 Arrow Electronics 개인정보 보호정책 및 이용 조건에 동의하는 것입니다.

당사의 웹사이트에서는 사용자의 경험 향상과 사이트 개선을 위해 사용자의 기기에 쿠키를 저장합니다. 당사에서 사용하는 쿠키 및 쿠키 비활성화 방법에 대해 자세히 알아보십시오. 쿠키와 추적 기술은 마케팅 목적으로 사용될 수 있습니다. '동의'를 클릭하면 기기에 쿠키를 배치하고 추적 기술을 사용하는 데 동의하는 것입니다. 쿠키 및 추적 기술을 해제하는 방법에 대한 자세한 내용과 지침을 알아보려면 아래의 '자세히 알아보기'를 클릭하십시오. 쿠키 및 추적 기술 수락은 사용자의 자발적 선택이지만, 웹사이트가 제대로 작동하지 않을 수 있으며 사용자와 관련이 적은 광고가 표시될 수 있습니다. Arrow는 사용자의 개인정보를 존중합니다. 여기에서 당사의 개인정보 보호정책을 읽을 수 있습니다.