Skip to content

How to identify and select good Arduino distance sensors

Nowadays, we use measurement systems in our everyday life. They consist of objects that detect physical distances. Motor vehicles like cars, buses, and trucks have these devices. They include radars and cameras.

We use distance sensors as objects in our surroundings in various applications. For example, we use them in the medical field. They measure the distance to an organ or a part of the human body. They are also helpful for industrial purposes like inspection and quality control.

What is a distance sensor?

It is an electronic component that measures the distance from a physical object. The most common such sensors are photocells, light-level, and capacitance. Others include photo-resistive sensors and inductive and ultrasonic metal sensing elements. Still, there are also other types of these sensors.

Arduino can detect the distance of objects, light level, and tilt in your house. The sensors are suitable for use with Arduino.

Photocells

A photocell is an electronic sensor that converts the intensity of light falling on it into a voltage. For this type of sensor to work, you must shine a light through the lens at a specific angle. Therefore, its output is high when bright light falls on it and 0V when a dark object (such as your hand) blocks the light.

The photocells used with Arduino are of two types: digital and analog. The digital photocell outputs 5V if the light is on. Otherwise, it outputs 0V. Analog photocells output a value proportional to the intensity of light falling on them. So, you will have to use an ADC chip to read their value.

Digital photocells are very cheap, but they don’t respond well to changes in light. However, they are helpful when you want to measure different lighting levels.

Light level sensors

These sensors are also known as phototransistors. They can detect the amount of light falling on them. The output of these sensors is proportional to the intensity of light falling on them. So you can use it to find out if your home is lit or not. You can use it with or without an ADC chip.

Capacitance sensors

They can measure the distance between two objects. For example, they can measure the height of a wall or the distance between the floor and your hand.

Conductive capacitive sensors

These sensors are widely helpful in robotics. Their principle of operation depends on measuring the distance between objects. The closer the object, the more electricity it conducts.

Capacitive sensors are very accurate, and you can use them to measure small movements. They are also relatively cheap. The most common type of capacitive sensor is the “alligator clip.”

Digital capacitive sensors

These sensors can detect the distance between two objects (your hand and the floor). We can use them to play games or even create security systems in your home because they work on a principle like proximity detectors.

Photo-resistive resistors

Photo-resistive resistors are very sensitive devices that measure objects’ distance. They measure the resistance offered by an object to light. They work in the same way as a photocell, with the only difference being that they don’t respond to light at all. 

There are two types of photo-resistive resistors: surface and printed. The surface ones are only suitable for industrial applications. However, you can use the printed ones in your home.

To use the surface photo-resistive resistors with Arduino, you will need to use an ADC chip.

The printed photo-resistive resistors can be more accurate than a digital camera because they don’t rely on analog circuits. They also have a better range.

How to identify a good Arduino distance sensor

Photocells, light-level sensors, capacitance sensors are not suitable for use with Arduino. They require a power source to operate.

Another group of distance sensors does not require a power source. They are helpful in robotics, and we call them digital distance sensors. All of them have an internal analog-digital converter (ADC). The ADC is a device that performs the analog-to-digital conversion. We connect it to two analog inputs, where the difference between them represents the digital value of the value that it produces. In simple cases, after reading an analog input, we can use the ADC for digital input to decide what action to take concerning the object that detected it.

There are many different types of digital distance sensors available from RayMing PCB & Assembly. They differ in their accuracy, maximum range, and price. Also, they function differently from one another. Therefore, it is essential to select the appropriate one for your application.

We can classify the digital distance sensors into two main groups: active and passive.

Active sensors measure distances with infrared or visible light beams, which they emit themselves. We use them for measurement with up to 100 meters of distance, and their price is about $10 or more. They also consume a lot of power (you will need a 9V battery for each sensor). You will need an additional Arduino library to read the signal from these sensors.

We only use active sensors in robotics applications. The light beams can cause problems detecting objects in your house or workshop. For example, mirrors and other shiny objects could reflect the beams.

Difference between an analog and a digital type of distance sensors

Arduino distance sensor Design

Analog types of sensors work by measuring the amount of light that falls on them. They have a resistive layer (photo-resistive). It produces a variable voltage proportional to the intensity of light falling on it. We perform the analog-digital conversion using an ADC chip.

In contrast, digital sensors have no resistive layer. Instead, they measure the time required for a pulse to go from one point to another. They use circuitry that generates square pulses of very high voltage for a short time. It also measures the time between two such pulses using an ADC chip.

In simple terms, the active digital sensor is a small light source that sends out a light pulse. It also measures the time taken for the reflection of this pulse to come back. A passive digital sensor measures the time required for an external light source to reach it.

How to select an appropriate type of Arduino distance sensor for your application

When you are selecting a distance sensor for a robot, you need to consider several things:

Visibility:

You will need a distance sensor that can detect objects, not in the range of visible light. For example, you can use opaque windows, doors, and mirrors. But you don’t want to use an infrared sensor. It could start working when someone enters the room. Also, it could even cause damage to the person’s retina.

Accuracy:

Suppose you need to track the distance of something moving, e.g., a car or a robot. You need an accurate sensor because its target could be moving at different speeds. Therefore, the sensor cannot measure each time that the distance changes. Instead, select an analog type of sensor (for example, photocell). You will have to recalibrate it each time the target moves further ahead or backward. But this method is unreliable.

Range:

You also need to consider the sensor range if you buy one for your robot. For example, you will need to make sure that it can detect your target object at 100 meters.

Easy installation:

Suppose it is easy to install and configure the distance sensor in your application. This will be easier for the users who need to operate the robot.

Price:

The price of the sensor is also important. If you are keen on a particular type of sensor, Google it and compare the prices.

You should know that many other distance sensors aren’t suitable for use with Arduino. For example, proximity sensors, radar sensors, and ultrasonic sensors.

Types of sensors that we can use with an AVR microcontroller like Arduino

There are many different types of sensors that we can use with Arduino. They are active and passive digital distance sensors, like those discussed above. There are also analog and digital magnetic, infrared and ultrasonic distance sensors.

The sensor you need to choose depends on the application you want it to perform.

1. Ultrasonic Sensor

An ultrasonic sensor is a sensor that generates high-frequency sound waves and uses them to determine the distance of objects. It is the most popular type of sensor among hobbyists because it is inexpensive to use and works reliably.

How Does An Ultrasonic Sensor Work?

Ultrasonic sensors work on the concept that all objects have a specific, characteristic frequency. For example, walking on water creates waves that are very different from those created by throwing a rock into the same water. The ultrasonic sensor looks at the two different waves, compares them, and determines their distance.

An ultrasonic sensor measures distance with a few tones sent out by the sensor. They then detect how long it takes for the sound wave to return. The time depends on the distance of an object from the sensor. Each wave travels at a speed proportional to its wavelength, i.e., it is proportional to its length. Thus, the time required for each wave to return is proportional to its distance from the sensor.

It is important to note that an ultrasonic sensor measures the time for each wave to return. The same applies to all sensors based on distance. For example, infrared sensors measure an object’s time from reaching a certain point to returning.

Ultrasonic sensors generate another tone and detect its frequency when they find an object in their field of view.

Key applications of Ultrasonic Sensors

The main application of an ultrasonic sensor is in robotics. We can use it for a wide range of applications:

a. Distance Measurement:

The most common application of ultrasonic sensors is measuring distance, especially in robotics. For example, they can count the number of people entering a door or calculate how a car moves. They can also measure the volume of liquid or the number of bugs or animals contained in a container.

b. Robotic Sensors:

We can use Ultrasonic sensors as the basis for many different robotic sensors. For example, an ultrasonic sensor can measure the distance from a tank, function as a knock sensor, or create a virtual wall.

c. Smart cars:

There are ultrasonic sensors onboard a smart car to detect distance in the form of vibration. They can look out for objects that block the car’s path or obstacles surrounding it.

d. Unmanned Aerial Vehicles (UAV) / Drones:

UAVs are more commonly known as unmanned aerial vehicles (UAVs) or drones. We can use them for various applications like aerial photography and rescue operations. Infrared and ultrasonic sensors are the most common sensors on UAVs.

Ultrasonic sensors are becoming increasingly popular in robotics. We can use them to sense distance without the need for sight. They work even when it is dark outside or when a material blocks their view (for example, an opaque wall).

Advantages of Ultrasonic Sensors

1. Multiple interface options for pairing with a microcontroller

Since we can wire ultrasonic sensors directly onto a microcontroller’s pins, you can connect them to the I/O lines of an AVR. You can use either the built-in interface of the chip or you can use one of the many open-source libraries. They enable you to interface with distance sensors Arduino in UART and SPI serial formats.

2. Tend to consume lower current/power

As they work on the principle of distance measurement, ultrasonic sensors run very little. Thus, they tend to consume lower current and power than other sensors. The lower power consumption makes it possible for the ultrasonic sensor to work in numerous applications.

3. Works well in dim places

Ultrasonic sensors work well even in low-light conditions. For example, they can keep track of a door in a house that doesn’t have proper lighting in its surroundings. Thus, ultrasonic sensors are ideal for applications that require operations even when it is dark or where there is a lot of smoke or dust.

4. Not affected by object color and transparency

Ultrasonic sensors are not affected by the color and transparency of objects. As a result, they can detect distance from water and liquids and an opaque material like a wall.

Disadvantages of Ultrasonic Sensors

1. Limited detection range

Ultrasonic sensors are not suitable for applications that need a long detection range. They have limited capabilities. For example, we cannot detect objects beyond 16 ft away.

2. Low resolution and slow refresh rate

The resolution of an ultrasonic sensor is very low. As a result, it is impossible to detect very small objects like insects or particles.

3. Unable to measure the distance of objects that have extreme textures

Ultrasonic sensors cannot detect the distance of objects that have an extreme texture. For example, it is impossible to determine a brick wall’s distance with a high-pitched brick texture.

2. Infrared Distance Sensors

Infrared distance sensors are also popular among hobbyists. They can sense distance and temperature.

How Does An Infrared Distance Sensor Work?


high accuracy
 distance sensor

An infrared distance sensor is a light emitter and a light detector. It sends out invisible lightwave signals and detects the wavelength reflected. This process is similar to how sound travels. The infrared sensors work on a wide range of wavelengths. It is unlike ultrasonic sensors, which use tone-based sensing.

A common setup of an infrared sensor involves two LEDs and one phototransistor. A fixed distance separates the two LEDs on the sensor. The first LED is the transmitter, i.e., it emits invisible light, and the second LED is the receiver or detector. It reflects the light received from the transmitter.

We can best explain the way that infrared sensors work as follows:

1. It generates Infrared waves from the transmitter LED and travels towards the receiver LED.

2. The Receiver LED hits the infrared waves, which bounce back and hit another phototransistor.

3. The second phototransistor generates an electrical signal. The signal corresponds to the amount of reflected light by the receiver LED.

4. We connected the second phototransistor to the receiver LED and switched. It turns on when the sensor receives light.

5. The 4th line of the sensor’s circuit is a 0-5V analog signal. Depending on the type of sensor you are using, you can rad the signal using the VCC and GND pins of the microcontroller.

6. The voltage of this signal helps control the transmit LED or readout distance measurements using another method.

Applications of Infrared Distance sensors:

a. Monitoring and control applications: Infrared distance sensors can control automatic doors and machinery. They are suitable for home automation applications. They monitor household appliances such as air conditioners, fans, water heaters, etc.

Extensive use of infrared sensors in security systems is also common.

b. Security systems: Infrared distance sensors can detect a moving object and signal to an alarm or motion detection system.

c. Distance measurement: They can measure the Arduino distance between two sensors and the temperature of an object. Infrared sensors can help determine the position of a moving object.

d. TVs, computers, laptops: We use them in TVs and computers to track the position of remote controls. They also play a role in detecting a person’s finger movement on laptops’ touchpads or keyboards to help navigate the cursor.

What Are The Advantages Of Infrared Distance Sensors

1. Small form factor

Infrared distance sensors are small and compact, making them ideal for use in robotics. We can also use them in toys like toy helicopters to determine the position of an object or two blocks.

2. Applicable for daytime and nighttime usages

We can use infrared distance sensors in the daytime and nighttime usages. They can control toys and other applications involving light, sound, or touch.

3. Secured communication through a line of sight

Since infrared distance sensors work through light, they are secure. Therefore, we can use them to communicate over a distance. This is unlike ultrasonic sensors, which can hack into a system.

4. Can measure the distance of objects that have complex surfaces

Infrared distance sensors can detect the distance of objects that have complex surfaces. This is because infrared waves can easily pass through certain materials like water, glass, and wood. The ultrasonic sensors are not as capable in this respect. We cannot use them to detect the distance of these materials.

Disadvantages Of Infrared Distance Sensors:

1. Limited range of measurement

Infrared distance sensors have a limited range of measurement. They can’t measure the distance from an object far away.

2. Affected by environmental conditions and hard objects

The infrared distance sensors are non-destructive. Environmental conditions and hard objects can affect them. These sensors will not work well in places with smoke or dust.

3. Laser Distance Sensors: LIDAR

LIDAR, an acronym for LIGHT DEPTH ARRAYS, stands for light detection and ranging. Essentially, it entails sending out a series of radiant waves and measuring the time these waves have to come back to the emitter. The speed at which the waves travel depends on their wavelength. We can consider this wavelength a ray reflected off an object for detection by the LIDAR system.

How Do Laser Distance Sensors Operate?

Laser distance sensors work on the principle of triangulation. As per this principle, if we know three points or three angles, we can arrive at another point using trigonometry rules. The three points are the emitter, the receiver, and the object or area of interest. The method of triangulation used by Arduino short distance laser sensors involves sending out a laser beam. It sends them in different directions at different angles. Then, it waits for the sensor to measure back its position using a device known as a pair of mirrors. This device acts as a light meter. Afterward, it is possible to calculate the distance between these three points.

Where Do Laser Distance Sensors Work?

Laser distance sensors work in many areas like:

a. Environmental Monitoring

We can use laser distance sensors to monitor the condition of the environment. They can also monitor pollution levels, especially in polluted cities like Delhi.

b. Distance Measurement

We can use laser distance sensors to measure the distance between a point and an object. For example, a car manufacturer can use this technology to perform quality control of its vehicles. In this case, we can measure the distance between two parts of the car using lasers.

c. Machine Control and Safety

We can use laser distance sensors to control machines and machinery. It can also measure the distance between two objects. This case sends a laser beam at a particular angle. We measure the return signal using a pair of mirrors. This information allows it to calculate the distance between the emitter and receiver objects.

d. Robotics Imaging & Environmental Detection

Laser distance sensors can monitor machinery or machinery. It then identifies objects in the environment like animals or people. For example, they can improve the safety of robots by tracking their positions.

Advantages of Laser distance sensors

Laser distance sensors have some advantages like:

a. Applicable for usage in the day and night

Laser distance sensors can measure the distance accurately, even day and night. They can control machinery and machinery.

b. Small wavelengths as compared to sonar and radar

Laser distance sensors have a small wavelength. They are effective in water, air, and even minerals.

c. Fast update rate

Laser distance sensors can measure the distance between two objects. It has a high and fast update rate. They are suitable for fast-moving objects.

d. Ability to measure 3D structures

Laser distance sensors can measure the distance between two objects from different angles. It can also measure 3D structures. For example, they can measure the distance of an object from three to four different angles. This means that they can determine the shape of an object by using these measurements.

d. High measurement range and accuracy

Laser distance sensors can measure the distance between two objects from a high range. They have a high degree of accuracy in measuring the distance between an object and a point. It is ideal in determining what distance do Arduino sensors start seeing signal degradation.

Disadvantages of Laser distance sensors

a. Higher cost of operation

Laser distance sensors are more expensive than other sensors in the market. They are also more expensive to maintain and throw out errors when their components get old.

b. Harmful to the naked eye

The laser beams from laser distance sensors can harm the eye’s indirect exposure. The eyes have to blink or close shut if exposed to these beams.

4. LED Time-Of-Flight Distance Sensors

Time-of-flight sensors are available in the form of an LED. They measure the time taken for the light to return to its emitter. This method involves sending out a long-wavelength pulsed laser at a known distance. It then measures the time taken for this light to come back. The speed at which this light travel depends on its wavelength. Devices that use Time-of-flight sensors are time-of-flight sensors or TOF sensors. These sensors are helpful in imaging, machine control, robotics, and environmental monitoring.

When Do We Use Time-Of-Flight Sensors?

Time-of-flight sensors are helpful for many purposes like:

a. Drones

A drone is a small unmanned aircraft that can create aerial images. A Time-of-Flight sensor can send a laser beam and measure back the time taken for this beam to come back. We refer to this type of sensor as a Time-of-flight sensor or TOF sensor. It can also work in machine control and robotics.

b. People counting in large areas

Time-of-flight sensors can count the number of people in a particular area. They operate on the same principle as surveillance cameras. They send out a laser beam reflected after hitting an object. The sensor then measures back the time taken for this beam to return to its initial position. Then it calculates the length of this distance using trigonometry.

c. Robotics

Time-of-flight sensors can track the presence of people in a particular area. They can also help robots identify objects like animals or people. It can then help them avoid crashing into these objects.

d. Machine vision

Time-of-flight sensors can identify the lines of a machine. For example, they can detect cracks on a machine, which makes it unsafe for use.

e. Environmental monitoring

Time-of-flight sensors can measure the distance between two points. They can also monitor the pollution level in places like polluted cities like Delhi.

f. Industrial applications

Time-of-flight sensors can work in industrial applications like hazardous material sensors. It can detect the presence of toxic gases or dust in air streams. They are also used in agricultural applications like crops or soil moisture to track their levels. Finally, they can measure the distance between two objects.

Benefits of Time-of-Flight Sensors

Time-of-flight sensors can measure the distance between two objects from a high range like 0.2meter to 50 meters. They also have a high degree of accuracy in measuring the distance between an object and a point. Their resolution is good. They can effectively differentiate between one object and another. They use different frequencies to operate them.

Disadvantages of Time-of-Flight Sensors

Time-of-flight sensors cost more than other sensors in the market. They fail to work when used in places with no line of sight. It makes them unsuitable for certain applications like tracking objects in the water.

Conclusion

Arduino distance sensors have been a part of many remote home automation systems. But they are also helpful in various other applications. If you have found this article helpful, share it with your friends to let them know about it.

Connecting Arduino to distance sensors is very simple, like connecting Arduino to the other components. Arduino libraries also include different distance sensors. They include ultrasonic, u-blox, and Opto distance sensors. So these sensors are suitable for communicating with other devices using Bluetooth and Wi-Fi.