5482+ reviews
Order by 16:00 for same day shipping
14 days return
DE
EN
Individual
Business

12/04/2026
Measuring distance seems simple. You point a sensor at an object and get a number back. In practice, however, things often go wrong. One sensor works perfectly on your workbench but fails as soon as you place it in a housing. Or it measures fine on a white surface but not on black plastic. Therefore, the most important question is not “which sensor is the best?”, but: which distance sensor suits your application?
In this article, I compare the most commonly used techniques for hobbies, prototyping, and small R&D projects: ultrasonic, IR (infrared), ToF (Time-of-Flight), and LiDAR. You will receive a quick selection guide, practical applications, pitfalls, and examples from our range.

Use this as a starting point. Consider it a rule of thumb, not a promise. The actual outcome depends on your target surface, mounting, and environment.

There are roughly four families that you encounter most often in Arduino, Raspberry Pi , and ESP projects. The difference lies not only in “how they measure,” but primarily in what they are sensitive to. Sound reacts differently to material and shape than light. And light, in turn, reacts differently to sunlight, glare, and transparency. Once you understand that, choosing suddenly becomes logical.
Ultrasound measures using sound waves. The sensor sends a short “ping” and listens for the echo. This is often the cheapest all-round option.
IR (infrared) works with light. Many IR distance sensors are ideal for short distances and simple detection.
ToF (Time-of-Flight) measures the time it takes for light to travel there and back. This often results in a cleaner, more stable measurement at short distances.
LiDAR is basically also “ranging with light”, but is often chosen when you want to measure further, sample faster, or simply need tighter data.
When prototyping, you primarily want something working quickly. These examples help link the technology to real projects.
Ultrasound is commonly seen in robotic cars and obstacle detection. You quickly get a distance value that allows you to steer: brake, swerve, or stop. It also often works well for water levels or "how full is this bin?", as long as the surface is reasonably flat.
IR is often chosen for hand detection (something comes close) or as a simple limit switch without mechanical contact. It is compact and can be quickly deployed in small enclosures.
ToF is ideal for positioning and measurement setups. Think of a component that you move slowly and whose distance you want to log, or a mechanism that you want to stop precisely at a position.
LiDAR is found in projects where you want to measure faster or see further. For example, with faster robots, or in simple mapping/scan-like applications where you want many measurements per second.
Ultrasonics are popular because they are simple to understand and often work well enough for prototypes. You get a direct distance value without complex optical effects that you have to take into account immediately. In practice, this means: you can test quickly, iterate quickly, and keep your code simple.
A typical application is a robot that does not need to drive into a wall. In that case, it doesn't matter if your measurement fluctuates a bit. You primarily want a reliable indication: “something is getting closer”. Ultrasound is often perfectly adequate for that.

Ultrasound becomes more difficult if your target does not reflect sound well. Soft materials (fabric, foam) absorb sound. An angled surface bounces the echo away. And you can sometimes miss narrow objects because the beam does not receive enough reflection. Mounting also plays a role: if you place the sensor in a tight housing, edges and cutouts can cause extra reflections. This results in measurements that sometimes suddenly overshoot.
Ultrasonic is usually intended for medium distances and is often “good enough” for prototyping. The exact accuracy depends heavily on temperature, airflow, mounting, and the target surface.

Ultrasonic distance sensor HC-SR04: choose this one if you are looking for a classic, fast entry-level model for Arduino/ESP projects. Suitable for hobbyists and quick proof-of-concepts.
Grove – Ultrasonic Distance Sensor: choose this one if you want to build modularly quickly and prefer not to have everything wired separately. Suitable for prototyping and educational setups.

As soon as you take measurements outdoors, the game changes. Rain, condensation, dust, and dirt are no longer borderline cases. In that case, a waterproof ultrasonic sensor is often the most pragmatic choice.
Outdoor projects often start as a hobby (“I want to measure the water level”), but quickly end up as something that needs to keep working for weeks or months. In that case, you don't want your sensor to give up due to moisture or corrosion. Waterproof doesn't just mean “can withstand rain,” but above all: you remove a major source of unpredictability from your prototype.
If your project is outdoors, hangs in a damp room, or if you expect it to get dirty and splashes, waterproof is often the safest choice.
Waterproof ultrasonic distance sensor A02YYUW: choose this one if practical reliability is more important to you than the lowest price. Suitable for outdoor installations, level measurements, and long-term testing.
IR distance sensors are attractive because they are compact and often fall precisely within that practical range where you build many prototypes: hand distance, small mechanics, simple detection. Think of a small flap that needs to open when something comes close, or a mechanism that needs to recognize an end position.
IR is also often convenient when space is limited. You don't need to mount a large “two-eye” module like with many ultrasonic sensors. This makes IR handy in small housings or in prototypes where you want to quickly hide something neatly.

IR is optical. Bright sunlight can disrupt your measurement. The surface of your target also plays a role. Shiny, very dark, or even transparent material can confuse an IR sensor. Indoors, this is usually easy to manage. Outdoors, it can become frustrating more quickly.
IR sensors are often used for short distances. The measured distance can vary depending on the surface and lighting conditions. Therefore, view it more as a practical detection solution than as a “measuring stick”.
IR distance sensor 10–80 cm: choose this one if you want to quickly detect or position at a short distance. Suitable for compact prototypes and simple mechanics.
ToF sensors are often the step you take when you notice your prototype is becoming more serious. You don't just want to detect, but truly measure. And you want the value to be stable.
A good example is a test setup where you move a component slowly and want to log the distance. Or a project where you control a motor and want to stop at an exact position. In that case, a smooth, consistent measurement is more important than “cheap and fast”.

ToF is not magic. If your target is transparent, highly reflective, or positioned at an awkward angle, you can get strange results. Mounting and shielding remain important.
ToF is often chosen for accurate measurements at short distances. In many applications, it feels more stable than simple IR solutions, but the actual performance depends on your setup.
GY-530 VL53L0X Time-of-Flight Laser Distance Sensor: choose this one if you want a compact, neat distance measurement for prototyping, measurement setups, or positioning.
LiDAR is interesting as soon as you want to measure further or sample faster. Think of a robot that drives faster, a measurement setup that is dynamic, or a prototype where you are less tolerant of noise.
In small R&D projects, you also see LiDAR when you are already a few iterations in. By then, you have often already learned what your project is sensitive to. If you notice that you keep running into the same limitations with ultrasound or IR, LiDAR can be a logical step.

LiDAR remains dependent on line of sight. If you do not have a clear view of your target, or if your target is at an awkward angle, you may encounter measurement problems. Here too, mounting and environment play a major role.
LiDAR is often chosen if you want to measure over a greater distance or collect data faster. The exact distance and accuracy vary by model and situation.
TFmini‑I Industrial Lidar Proximity Sensor: choose this one if you are looking for a robust LiDAR solution for prototyping and small R&D.
TFmini Plus Laser Ranging Distance Sensor: choose this one if you want LiDAR, but with a model that is often chosen for faster, more precise measurements in projects.
Many prototypes work indoors. There you have control. Outside, you don't.
Indoors, IR and ToF can often be used perfectly well, especially if you shield the sensor and your target surface is predictable. Outdoors, you have to deal with sunlight, reflections, moisture, and dirt. In that case, a waterproof solution quickly becomes the most reliable choice.
Your housing is also important. A sensor “behind a window” sounds neat, but transparent material can affect optical sensors. And a tight mounting can cause reflections during ultrasonic testing. If your readings are strange, the housing is often the first suspect.
Most problems are not caused by the sensor itself, but by the situation. If your prototype works “sometimes, sometimes not,” the issue often lies in one of these points.
The sensor is not perpendicular to the target. Position it as straight as possible. Angled targets result in more misses.
The target is soft or absorbent. Ultrasound prefers hard surfaces. Dust and foam are tricky.
The target is transparent or glossy. Optical sensors can detect strange reflections.
Insufficient free space in the housing. Provide the sensor with visibility and prevent reflections from edges.
You are expecting too much from a single measurement. Take multiple measurements and filter/average. That makes your data immediately calmer.
Sometimes one sensor is not enough. Especially in R&D, it is normal to build in redundancy.
Ultrasound + ToF is a powerful combination if you want to measure both “roughly” and “precisely”. Ultrasound can be your quick all-round check, while ToF can be your precise short-distance measurement.
IR + a physical switch works well if you want to recognize an end position. IR can detect early, and the switch is your hard certainty.
LiDAR + encoder is interesting if you measure motion and want to correlate distance with speed/position. That is typically the kind of step you take when growing from a hobby to serious prototyping.
What is the best distance sensor for Arduino?
That depends on your goal. For quick prototypes, ultrasound is often the easiest starting point. If you want to measure short distances accurately, ToF is often more convenient. If you mainly work at short distances and want simple detection, IR is often sufficient.
Does a distance sensor also work outdoors?
Sometimes yes, but outdoors it is more difficult due to sunlight, moisture, and dirt. In many outdoor projects, a waterproof ultrasonic sensor is the most pragmatic choice.
What is the difference between ToF and LiDAR
Both measure with light, but LiDAR is often chosen if you want to measure over a longer distance or obtain data faster. ToF, on the other hand, is frequently seen for compact, clean measurements at short distances.
Does this work on a black or glossy surface?
That can be tricky, especially with optical sensors (IR/ToF/LiDAR). Glossy, black, and transparent materials can cause reflections or absorption. Therefore, always test with your actual target material.
If you keep one thing in mind: choose your proximity sensor based on the environment (indoor/outdoor, light, humidity) and the purpose (material, angle, size). For quick prototypes, ultrasound is often the starting point. For short, precise measurements, ToF is a significant step up. For outdoor use, waterproof is often the smartest choice. And if you need to go further or faster: look at LiDAR.
Would you like us to take a look? Send your project details (distance, indoor/outdoor, target material, and mounting) and we will advise on the most logical sensor to start with.