In this video, we are taking a look at effective ways of measuring distances in your maker projects. We are going to be looking at extremely common ones like ultrasonic and laser distance sensors, and work our way to less obvious ones like GPS, and using Wi-Fi signal strengths. The key point of this video is that you will ideally walk away knowing the limitations of each method, so you know which one is most applicable for your next project.

Transcript

Measuring a certain distance is quite a common task in maker projects, and just like picking the perfect YouTube video to watch while you eat dinner, there are so many different options. Hello James, I hope you're enjoying your dinner right now. Welcome back to Core Electronics. Today we're going to be exploring effective methods of measuring distances with maker-level hardware. We're going to start with the more common ways, but work our way into the more obscure or out-of-the-box solutions you might not think of.

You should ideally be able to watch this video and walk away with a good solution for 99% of projects. This video is also going to be a bit of an overview video, we're not going to get into the weeds of it all, but if there is something here that piques your interest, you will find some instructions to get started with them in the written guide linked below. Alright, we're going to start with the classic, the OG, the ultrasonic sensor. You all know how it works, it releases an ultrasonic burst of sound, which hits a target, it reflects back, you measure how much time it took for that sound to come back, and you use the speed of sound to calculate distance. Super easy.

But these things tend to suck, and here is why. First of all, they need a relatively flat surface to bounce back. If it's angled or curved, it can reflect the sound away so it doesn't bounce back. Second of all, these actually produce a cone of sound. It isn't a laser beam that shoots out very precisely, but instead a cone of noise about 30 degrees. It's close to something you would expect from shining a flashlight around, so when you use these, you are actually measuring the distance of the closest thing in this flashlight 30 degree cone.

There are other issues like air temperature affecting the accuracy, and even a bit of wind being able to throw off your measurements by a few percent. However, given all these shortcomings, there are upsides. They are just, you know, fantastically cheap and super available. They are easy to use, there's a billion guides on them, and for how budget they are, they can be reasonably accurate. And this is sort of the crux of this whole video. There are downsides and limitations to every way that you can measure distance, but as long as you are aware of them, you can make the right call as to whether they are an appropriate solution or not.

An upgrade to the ultrasonic sensor is the laser distance sensor. There are quite a few varieties, but they're largely the same idea as an ultrasonic sensor, but they just use an infrared laser instead of sound. They can be a bit more expensive, their light also shines in a cone, so they've got the same issues, and they can be affected by the color of the object. If you painted something, you know, Vantablack, no light would reflect back, and you wouldn't be able to, you know, use your laser to get a distance read.

Most of the time, color isn't a major issue, but something matte black might reduce the effective range of this a bit. The maximum range of these sensors, by the way, is usually about 4 meters as well. Sometimes you can find more expensive ones that increase that, though. If you can put up with these limitations, though, then you will have a way, way more accurate sensor. Ultrasonic sensors can be accurate to maybe, you know, a centimeter or so. These can be accurate down to the millimeter if you dial them in.

They can also shine through glass or clear things because it's a laser and light. Meanwhile, an ultrasonic sensor is just going to bounce off a glass panel. That might be a good or bad thing, though, depending on what your project actually is, and if you're looking to measure like a water level or something, that's going to go straight through the surface of the water. That's going to bounce off the top of the water. If you want to go even one step more further up, you can find something called a multi-zone laser ranging sensor.

Imagine if you got a whole heap of these laser distance sensors, but pointed them at slightly different angles to create kind of a grid of distance sensors. With this, you could start to get some basic kind of 3D mapping as you can scan, you know, a whole bunch of distances at once. It's starting to get really cool here. If you pointed it at something like a wall with a door open, you could probably see where the door is based on the distance readings. Now, these aren't super high resolution. They usually come in an 8x8 grid like this one.

That is still 64 lasers to use, though, and enough resolution to do some cool stuff. In terms of downsides, again, a bit more expensive, and this is where we start to get a little, you know, data intensive. You have 64 distance measurements being reported many times a second. It gets a little bit difficult to juggle all of this data and actually effectively use it in a project. The ultrasonic and laser sensor, though, you know, a single data point, super easy, you know, my first project level of ease.

By the way, if you want to go all out, you can get a camera version of this sensor, which instead of 8x8, has something close to 240x180 distance measurements. This is where things start to get a bit tricky, though. You can no longer use a simple microcontroller, but will instead probably need an actual computer like a Raspberry Pi to process everything. You are also getting, you know, over a million distance measurements a second, so it starts to get a bit difficult to actually use it and, you know, effectively apply it into your project.

Nothing impossible, but expect there to be a bit of a learning curve if you start to get to, you know, this level of, you know, distance measurements. There's also probably going to be a little bit of math involved, and we're starting to get into the territory of LiDAR and 3D mapping more than distance measurements here. And we could keep going up in levels here into, you know, full 360 LiDAR scanning, which would need probably a whole video of itself, but we are going to cut it there and move on. All right, all those methods share something in common.

They release some kind of a signal and observe how it bounces back and how long it actually takes to measure distance. What if instead we had two devices? One releases a radio signal and the second one hears that radio signal and repeats it back. The first one then measures how long it took for that whole process to take and uses that to figure out the distance between them. We are of course talking about something called ultra wideband here, a really cool technology that uses this idea.

So why would you do this instead of just, you know, letting the signal bounce back like the laser distance sensor or anything we've looked at so far? Well, first of all, it doesn't matter what orientation the boards are in. If I had my laser sensor and I rotated it 90 degrees, I'd go from measuring the distance to the wall to the distance to the roof. You have to be pointing it at what, you know, the distance, the thing that you actually want to measure. Ultra wideband though, doesn't really care about angle. It just gets the distance between the two regardless of the rotation.

This also allows signals to bounce around objects. You could have, you know, a person in the way or a couch in the way, and it will still work because the signals can, you know, often find some, you know, short paths to navigate around those objects. You can also have lots of these in a network together. And with that, you can use all the distance measurements that are being reported and a little bit of math to figure out the three dimensional positioning of one of these boards in, you know, 3D space.

Ultra wideband is kind of just trickled down now into something that would be considered the maker tier. It's exploding right now. You find it in air tags and range wise, it really depends on your board, but you can get up to probably 30 meters in the right environment with these ones. So what are the downsides? Well, they can be a little bit more pricey and, you know, every single measurement point needs its own board and that, you know, that's an extra cost and they aren't as accurate as laser sensors.

They are usually good to within, you know, maybe 10 centimeters of accuracy for small measurements under a meter. That might be pretty significant, but when you're measuring, you know, over 10, 20 meters, that's, you know, less of a concern. But again, if that is not a problem for your project and you're looking to measure the distance between two points that might be moving around, these are a fantastically reliable way to measure that distance. All right, let's start thinking out of the box here.

Let's go through some ideas that might not be, you know, a very obvious solution, but could be a good fit for your project. First of all, GPS. GPS modules are pretty darn cheap nowadays. They're quite easy to get going and they give you a full three positional, you know, reading, including height. In good operating conditions with clear skies above, you can get within a meter or two of accuracy. That sounds like a large margin of error, but if you have a project that's maybe, you know, trying to measure distance on the scale of hundreds of meters, that is, you know, not that bad.

However, that is under ideal conditions, bad weather or, you know, being between large buildings or, you know, just things in the way can decrease that accuracy a bit. But they are fairly easy to use and are quite flexible. You could use a single GPS, you know, receiver to figure out how far away you are from a point on the earth, or you could have multiple devices with GPS all talking to each other to figure out the distances between them. If you are looking to measure distance in terms of height only, there is an easy solution.

Barometers, that's the higher up you are, the less air pressure there is, and this sensor can detect those differences in pressure. They're pretty cheap and they're surprisingly accurate at measuring changes in height. It really depends on your sensor, but usually somewhere around 10 centimeters of a change in height is detectable. So if you wanted to measure a vertical distance over a few meters or even a hundred meters, this is not a bad option. Not, you know, incredibly precise, but a bit of an out of the box solution.

However, you got to remember that ambient air pressure does change a bit throughout the day, just a side effect of living on planet earth and all, you know, so you got to account for that. Here's a bit of a curve ball for you. If you have a microcontroller or some dev board with a wireless chip on it, you might already have access to a distance sensor. A really terrible one though. If you have a device that can connect to wireless things like maybe wifi, Bluetooth, maybe even LoRa or ZigBee, you can measure the received signal strength indicator or RSSI of it.

This is essentially a measurement of how strong that signal is, and it can be a quick and dirty way to estimate distance. However, it's very, very inaccurate. Here I have a Pico W scanning for the wifi hotspot on my phone. And as you can see, phone close, number small, phone move away, number get larger, and if phone is very far away, number a lot bigger. I would not expect to get, you know, a solid value or a number, you know, measuring distance from this. The best you could reliably hope for is to tell whether the thing transmitting the signal is really close, like almost next to it, on the other side of the room, or maybe in another room altogether.

It's really, you know, not accurate. However, your home probably has quite a few signals already existing that you can read the distance to, things like, you know, your home router. And most microcontrollers that you're already probably using have the ability to do this. You know, you've already got all the infrastructure to use. The code to set this up is also really straightforward. So just have a think about it, it might be good enough for your project. And also remember that most microcontrollers that have a wireless chip can create their own Wi-Fi signal.

So you can, you know, track between two ESP32s or something like that. If the distance you're looking to measure is on the smaller end and can have something attached to it, maybe it slides along a rail or something like that, a linear potentiometer might be a good pick. The change in resistance as this moves is pretty consistent with how far it actually is. This is a tiny one, but you can get larger ones. It's just, you know, worth considering. It's a pretty easy and low tech solution you might not think about.

If you're looking to measure the distance to humans specifically, you might want to check out millimeter wave radar sensors. Essentially, they're a low power radar that sends out radio waves and they're tuned to detect to see what human reflections look like. I mean, that's pretty cool. This is a radar that, you know, pretty much only detects humans or maybe, you know, like a big dog or something like that. However, one very, very, very big downside to these, they have to remain still. They're kind of designed to be mounted somewhere and not move.

And, you know, they can't be put on a robot or, you know, a piece of arm wear or something like that. However, they are cheap. They have a range of usually about eight meters and can give you not only the distance away from the sensor a person is, but also what angle they are standing at. All right, let's change gears here and take a look at some of the ways you can measure distances with cameras. If you look at the world around you, you can probably use the power of your brain and your eyes and look at a wall and go, that's probably about two meters away.

Maybe that's, you know, 30 centimeters away just by looking at it and thinking, well, you can do this on something like a Raspberry Pi with a dual camera setup. There exists prebuilt solutions like an OakD, which can do a lot of other computer related tasks, or you can even just connect two cameras on your own and build your own system. With this, you can measure distances pretty accurately up to maybe 10 or so meters. Now, this is quite involved and may need some expensive gear and a bit of, you know, trial and error to get right.

But if you are running your project on a Pi, it's maybe something worth thinking about. It's something you can just tack on. There are also ways to estimate distance with only one camera, but it isn't nearly as accurate. Let's end here with something worth keeping in mind. You can also estimate distance by measuring how fast something is moving. For example, if a part of our project starts somewhere and moves at a speed of one meter per second for 10 seconds, we can measure that it has moved 10 meters.

This is a bit of a different method of measuring distance than something like an ultrasonic sensor. But again, something just worth keeping in mind. There are also a lot of ways to do this as well. A really simple way is with an encoder on a wheel. You just count how many times it rotates and use a bit of math to figure out how far you've moved. For something a little bit more advanced, you might want to use an IMU to figure out how fast your project is moving around and use that to figure out how far you've moved.

But one of the best ways to do this is with something called an optical flow sensor. Essentially, it's a little camera on a board and it watches the ground move beneath it and you use that movement to figure out how fast you're moving. They're often used by drones for navigation. Now, there is a bit of math involved in all of these methods and little tiny inaccuracies in your speed. You're never going to perfectly read your speed. These add up to cause your measurements to drift off a little bit.

But again, like everything we've covered, it's just worth keeping in mind that this is a method of measuring distances. Well, that about wraps us up here. Hopefully, you're now equipped with an appropriate distance measuring solution for your next Make It project. By the way, if we missed anything or you found a really novel way of measuring distance in a project before, comment it below. No, seriously, please do it. And again, if you want to get started with anything we covered here, there is a written guide linked below with some resources and maybe guides to get you started. Until next time, happy making.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.