types of ultrasonic sensors for arduino

Ultrasonic Sensors for Arduino: Top Types & Comparison

By Melissa Johnson
AD

Ultrasonic sensors, which measure distance using sound waves, have become increasingly popular in Arduino projects due to their affordability, ease of use, and high precision. When selecting an ultrasonic sensor for your Arduino project, it's essential to understand the different types available to choose the most suitable one for your needs. This article explores the various types of ultrasonic sensors compatible with Arduino.

Before diving into the types, let's briefly understand how ultrasonic sensors work. These sensors emit a sound wave at a specific frequency, typically between 20 kHz and 40 kHz, and measure the time it takes for the sound to bounce back from an object. The time difference, combined with the speed of sound, helps determine the distance to the object.

Passive Buzzer Ultrasonic Sensors

Passive buzzer ultrasonic sensors, also known as active-passive sensors, rely on an external oscillator IC to generate the sound waves. They are compact and lightweight, making them ideal for small-scale projects. Some popular examples include the HC-SR04 and to a lesser extent, the FC-51.

AD
the arduino guide to program sensor
the arduino guide to program sensor
5 Arduino Ultrasonic Sensor Projects to Build
5 Arduino Ultrasonic Sensor Projects to Build
Ultrasonic Sensor Arduino Interfacing
Ultrasonic Sensor Arduino Interfacing

The HC-SR04 is a widely-used sensor due to its low cost and simplicity. It provides a straightforward interface with four pins: VCC, GND, TRIG, and ECHO. A trigger pulse of at least 10 µs duration is required to initiate the distance measurement. The sensor then emits eight sound waves and listens for the echo. The time difference between the sound emission and reception is used to calculate the distance.

HC-SR04 Compatibility and Limitations

The HC-SR04 is compatible with virtually all Arduino boards due to its 5V tolerance and straightforward interface. However, it has limitations. The maximum detectable distance is around 2 to 5 meters, and the maximum ranging frequency is approximately 40 Hz, which may not be suitable for high-speed applications. Additionally, its accuracy is affected by temperature changes and the presence of multiple objects within its 30x15° field of view.

Types of Sensors Used in Arduino Projects | Arduino Sensors
Types of Sensors Used in Arduino Projects | Arduino Sensors
an image of the cover of easy way to code ultrasonics for arduino robots
an image of the cover of easy way to code ultrasonics for arduino robots
Ultrasonic Sensor HC-SR04 and Arduino - Complete Guide
Ultrasonic Sensor HC-SR04 and Arduino - Complete Guide

Another passive buzzer sensor is the FC-51, which is smaller and lighter than the HC-SR04. It offers similar performance and is also compatible with most Arduino boards. However, it shares the same limitations as the HC-SR04, including the detection range and frequency.

страныhiribactivation of Passive Buzzer Sensors

Passive buzzer sensors require an external Arduino pin to trigger the sound emission. In the case of the HC-SR04, setting the TRIG pin to a high state (5V) for at least 10 µs activates the sensor. Once it receives the trigger signal, the sensor emits an 8-cycle burst of sound waves and waits for the echo. If an echo is detected within the specified time window, the sensor sets its ECHO pin to a high state while the Arduino reads the pulse width to calculate the distance.

AD

Here's a simple Arduino sketch to demonstrate the usage of the HC-SR04:

HC-SR04 Ultrasonic Sensor Pinout
HC-SR04 Ultrasonic Sensor Pinout
Complete Guide for Ultrasonic Sensor HC-SR04 with Arduino | Random Nerd Tutorials
Complete Guide for Ultrasonic Sensor HC-SR04 with Arduino | Random Nerd Tutorials
the electronic components are connected to each other
the electronic components are connected to each other
Ultrasonic Sensor Without Arduino using 555 timer » Hackatronic
Ultrasonic Sensor Without Arduino using 555 timer » Hackatronic
Arduino - Ultrasonic Sensor | Arduino Tutorial
Arduino - Ultrasonic Sensor | Arduino Tutorial
Mapping A Room Wh Ultrasonic Distance Sensors
Mapping A Room Wh Ultrasonic Distance Sensors

const int TRIG_PIN = 12; // Trigger pin connected to digital pin 12 const int ECHO_PIN = 13; // Echo pin connected to digital pin 13 void setup() { pinMode(TRIG_PIN, OUTPUT); pinMode(ECHO_PIN, INPUT); Serial.begin(9600); } void loop() { long duration, distance; digitalWrite(TRIG_PIN, LOW); delayMicroseconds(2); digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIG_PIN, LOW); duration = pulseIn(ECHO_PIN, HIGH); distance = (duration / 2) / 29.1; // Distance calculation in cm if (distance >= 2 && distance <= 400) { Serial.print(distance); Serial.println(" cm"); } }

Active Ultrasonic Sensors

Active ultrasonic sensors have an onboard oscillator IC, which generates the sound waves. They are more accurate and reliable than passive sensors but are also more expensive. One popular example is the SRF05.

AD

The SRF05 offers a simple TTL-level interface with four pins: VCC, GND, TRIG, and ECHO. It provides a higher accuracy of ±3 cm compared to the HC-SR04's ±5 cm. The maximum detectable distance is approximately 6 meters, and the maximum ranging frequency is around 80 Hz. The SRF05 also operates on lower power, with a typical current draw of 150 mA during transmission and 15 mA at idle.

50 Arduino Sensors Every Maker Should Know
50 Arduino Sensors Every Maker Should Know
THIRD EYE FOR THE BLIND USING ARDUINO NANO AND ULTRASONIC SENSORS
THIRD EYE FOR THE BLIND USING ARDUINO NANO AND ULTRASONIC SENSORS
Ultrasound Sensor: 2D Tracking With Arduino
Ultrasound Sensor: 2D Tracking With Arduino
How HC-SR04 Ultrasonic Sensor Works & How to Interface It With Arduino
How HC-SR04 Ultrasonic Sensor Works & How to Interface It With Arduino
HC-SR04 Ultrasonic Sensor with BBC micro:bit – KS3 & KS4 Guide | TeachWithICT
HC-SR04 Ultrasonic Sensor with BBC micro:bit – KS3 & KS4 Guide | TeachWithICT
Cool Arduino Ultrasonic Transducer HC-SR04 Distance Measurement With Tinkercad
Cool Arduino Ultrasonic Transducer HC-SR04 Distance Measurement With Tinkercad
different types of sensor components displayed on a green background
different types of sensor components displayed on a green background
Ultrasonic HC-SR04 Sensor Interfacing Arduino - Distance Measurement
Ultrasonic HC-SR04 Sensor Interfacing Arduino - Distance Measurement
Arduino Ultrasonic Sensor Distance Meter | Arduino Distance Meter with LEDs | Arduino LED Meter
Arduino Ultrasonic Sensor Distance Meter | Arduino Distance Meter with LEDs | Arduino LED Meter
Distance Measurement Using Arduino and Ultrasonic Sensor
Distance Measurement Using Arduino and Ultrasonic Sensor
Waterproof JSN-SR04T Ultrasonic Distance Sensor with Arduino Tutorial
Waterproof JSN-SR04T Ultrasonic Distance Sensor with Arduino Tutorial
Robotics Challenge: Ultrasonic Sensor - Learn Robotics
Robotics Challenge: Ultrasonic Sensor - Learn Robotics

Activation and Compatibility of Active Ultrasonic Sensors

Activating an active ultrasonic sensor, such as the SRF05, is similar to its passive counterparts. A trigger pulse of at least 10 µs is required to initiate the distance measurement. The SRF05 has a built-in oscillator, so no external IC is needed. Due to its TTL-level output, it can directly interface with most Arduino boards without the need for level shifters or voltage divider circuits.

Here's an Arduino sketch similar to the previous one, demonstrating the usage of the SRF05:

AD

const int TRIG_PIN = 12; // Trigger pin connected to digital pin 12 const int ECHO_PIN = 13; // Echo pin connected to digital pin 13 void setup() { pinMode(TRIG_PIN, OUTPUT); pinMode(ECHO_PIN, INPUT); Serial.begin(9600); } void loop() { long duration, distance; digitalWrite(TRIG_PIN, LOW); delayMicroseconds(2); digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIG_PIN, LOW); duration = pulseIn(ECHO_PIN, HIGH); distance = (duration / 2) / 29.41; // Distance calculation in cm (Speed of sound in air at 20°C) if (distance >= 2 && distance <= 400) { Serial.print(distance); Serial.println(" cm"); } }

In contrast to passive sensors, active ultrasonic sensors like the SRF05 offer better performance and versatility. However, they also tend to be more expensive and may require additional power management for battery-operated projects.

When selecting an ultrasonic sensor for your Arduino project, consider factors such as accuracy, detection range, power consumption, and compatibility with your project's requirements. Understanding the types of ultrasonic sensors available will help you make an informed decision and choose the best sensor for your specific needs.

The world of Arduino-compatible ultrasonic sensors offers a wide range of options to explore. As the community continues to grow and innovate, new sensors and technological advancements are continuously being developed. Embrace this exciting field, and let your passion for electronics and creativity guide you as you delve deeper into the fascinating realm of ultrasonic sensing.

AD