These are ultra-wideband modules, and they work almost like magic. If I have two of them, I can measure the distance between them fairly accurately. Now, you might be saying, oh, I can do something similar like that with my laser or ultrasonic distance sensor. Well, what if I told you that it doesn't matter what orientation the boards are in, they'll still get their distance measurement?
What if I also told you that you can have furniture or people in between them blocking line of sight? Or what if I told you that you can have a network of these all working together to get multiple distance measurements at once? That suddenly opens up the possibility of adding 3D spatial tracking to your projects. If this hasn't activated your making neurons, I don't know what will.
Welcome back to Core Electronics. Today, we're going to be looking at ultra-wideband, how it's becoming accessible to makers, and how you can add it to your next project. Let's get into it. This is an AI Thinker UBO3 ultra-wideband module, what a name, and it's a wickedly cool piece of hardware. AI Thinker has been going ham pretty recently, making quite high-end technologies accessible on modules like this.
They do a lot of other cool things like their millimeter wave human radar, which we also have a video on. Go and check it out. At the time of making this video, this ultra-wideband board is one of the cheapest ways to add ultra-wideband to your projects, by quite a margin as well. Yes, you can definitely go and buy just the chip itself, which is the little fellow on the top here, but you need to go and design your own carrier board to actually use it.
Regardless, ultra-wideband has now reached a point where it's reasonably affordable and easy enough for use in maker projects at home. But how does it work? Well, these boards operate using time-of-flight measurements of radio waves sent between them, somewhere between 6.25 and 8.25 gigahertz. One sends out the message, the other receives it, and then repeats that message back.
The first board then uses the time that it took for that signal to come back to figure out how far apart they are. But that message is traveling at the speed of light. If these boards were about 30 centimeters or a foot apart, it takes only a billionth of a second to move from point A to point B. So there are some crazy timings involved to make this measurement and make it accurate.
That's a really oversimplified explanation, but it's enough to understand the gist of how these work. There's a whole heap of advanced signal processing going under the hood to make this whole system work. Speaking of working, let's fire one up and take a look at how to actually use it. Now, all this distance data is going to be output through UART, so you're going to need something to read and process all of that data.
We're just going to be using a Raspberry Pi Pico with MicroPython as our demo. But in the written version of this guide linked below, you will also find instructions and code of how to do this in C++ with a device like an Arduino or ESP32. And of course, you'll find the MicroPython code we'll look at in this video down there as well. You're of course going to need some of these UBO3 boards as well and a way to power them.
The easiest way is probably through their USB-C ports. As always, you can find everything you need in the written guide linked below. The first thing we need to do is configure our boards. They actually have two UART channels, one for configuring it and another for data output. There are two USB ports on these and two sets of TX and RX pins to access these two different UART channels.
The pins to configure the board are labeled TX1 and RX1. So go ahead and connect those to the RX and TX pins of your microcontroller. I'm just going to use pin 0 and pin 1 here. And of course, we need to power it, which can be done through ground and either the 3.3 or 5 volt pins on the board. I'm going to go ahead and plug my Pico into my computer, open up Thonny and paste in the configuration code from the written guide.
Configuring the board is pretty straightforward. The code is just going to send a whole bunch of AT commands with this one up here being our main one. It's got four numbers up here that we're going to need to select. The first is the ID of the board. The second is the mode, whether we want it to run as a base station or a tag. Then the frequency that we want it to run at. And finally, the data rate.
We tested the last two settings and found that 1.1 works the best, which is the lower frequency at the higher data rate. So we recommend leaving these as 1 and 1. And these two last numbers need to be the same across all of your boards. So just keep whatever you chose the same. Don't change it. Alrighty, let's first configure the important board known as the tag.
The tag can be thought of as the module that will be tracked. Every distance measurement will be made in reference to this. So how far away each board is from this tag. This tag needs an ID of 0. So I'm going to go ahead and give it an ID of 0. And we're going to set the mode to 0, which is going to tell it to configure it as a tag. 0 is a tag, 1 is a base station.
Run that code and our Pico is going to send that command. And this might take a few seconds. It's also going to send a reboot command, which I think it's doing right now. Yep. And then it's going to send this AT get configuration command, which is just basically asking it, hey, give us the config information that you're currently running on, just so we can double check it. And down here, you can see it printed out ID 0, role 0, channel 1, rate 1, which is what we put in. Brilliant, it's set up.
Now let's set up a base station. The base station is going to measure how far away the tag is from it. So if you had two base stations, you would be reading the distance from the tag to each of those base stations. Not between the base stations, tag to base station is the only measurement you're going to get. Now, very importantly, this is going to be my primary base station, which is an important one.
So it's going to have an ID of zero. However, I'm going to want to set it up as a base station. So I'll set it as one. And then I'm going to ensure I keep the frequency and data rate exactly the same. Let's run that. And it's going to send the command. It's going to send the reboot command. It usually takes two or three seconds for it to reboot. Come on. Sweet. Get command, ID zero, roll one, channel one, rate one. Beautiful.
The absolute minimum you need to run this system is a tag with an ID of zero and a base station with an ID of zero as well. Alrighty. I'm going to go ahead and just because I have a plethora of these available, I am going to set up a second base station. But instead of the ID being zero, it needs to be an ID of one. Every single base station needs its own ID. You can't share an ID.
If it does share an ID, you're going to randomly measure the distance between those two boards of the same ID. I'm just confirming we have a base station with an ID of one. If I went ahead and for the fun of it, set up a third base station, it would have an ID of two. A fourth base station would have an ID of three and so on and so on. In the mode we're using, you can have up to eight base stations.
So you would just keep going through those unique ID numbers till you reach seven, which is the maximum because we started counting at zero. So with a system, you can have a maximum of nine boards, one tag, eight base stations, each measuring the distance to the tag. Now this might seem like a bit of an overkill setup, but in a future video, we'll be looking at how to use this for full spatial 3D tracking. It's really damn cool.
And that is all we need to do with the AT commands. Before we move on though, these boards do actually have a three axis accelerometer on them. So you can actually access that data through these AT commands. All you need to send is AT plus get sensor. And if I run it here, you can see we're getting up X, Y, Z, and then an estimated angle of the board. We aren't really going to be using this.
It's just a handy thing to note if your project calls for it because you have access to an IMU already. Now that the boards are configured, we are ready to get that distance data, which is going to come out of the second UART channel. By the way, those AT commands will not work on this second channel. It only outputs distance data. This UART is going to be accessible through pins PA2 and PA3. PA2 is the TX and PA3 is the RX.
Why are they not labeled like this? No idea. I've gone ahead and connected base station zero to my Pico here. That's because only devices with an ID of zero are going to output data. So tag zero and base station zero are the only ones that you're going to be able to actually get data out from this UART channel. Any other device, you're just probably going to see nothing.
I'm then going to go ahead and run this super simple UART code that just prints out anything it sees. And finally, I'm going to plug in my tag to USB power. And after a brief second, you can see that there are two blue lights flashing on these on each side now. That means that they've paired to each other and you are now receiving UART data. As you can see in our shell, I'm just going to stop it here so we can see what's going on.
This is a pretty stock standard UART message, a header and a tail with all the distance data in the middle here. And it's in 16-bit little endian format. You can see here we have some values and then a whole bunch of just zeros because we've only got one base station connected at the moment. The rest of where these eight base station data distance points will be is just currently empty.
What's that? You can't read 16-bit little endian format with your naked eyeballs? Well, if only there was like a written guide or something linked below that contained code to make all of this nice and human readable. Here's that code. I'm just going to go ahead and run it. And without changing anything, you can see we now have our nice human readable distance measure out in meters.
I'm going to hold it about half a meter away and we're getting half a meter. I'm going to try and move this as far away as it can. And as you can see, I move it around. We're changing the measurement distance. I'm going to go ahead and look for a battery pack. I just got a USB battery bank here that I'm going to plug it into. It's automatically going to boot up and start getting those measurements.
And if I move backwards, you can see our distance is increasing. I don't really know what more to explain about this. It's pretty self-evident what's going on here. And just for the fun of it, I'm going to go ahead and fire up all eight of my base stations here just to show you what this can do when it's fully pumping. And this is eight base stations measuring the distance to the tag.
And all of these measurements are being made at pretty much the exact same time. Look at that. You just turn on a board and it automatically starts sending data to our primary base station within two to three seconds as soon as it boots up. All right, we've got it going. How does it perform though? Well, pretty good all things considered. If you held two of these boards a certain distance apart, you can expect that distance measurement to be accurate within 10 centimeters, which is pretty standard for ultra wideband.
At small distances like a meter or less, this can be quite a significant margin of error, but at larger distances of like 10 meters, it becomes less of an issue. Speaking of range, after some extensive testing, we found that these can read up to 10 meters through some minor obstacles, maybe a table or chair or a person in the way, maybe something like warehouse shelvings, through a doorway, you know, minor obstacles that might block the line of sight.
If you have direct line of sight though, you can get even more range. When the boards are facing each other like this, you get optimal antenna position. And after some quick tests, we got measurements of up to 25, sometimes maybe even 30 meters. It is a bit hit and miss at those ranges, especially if the boards are not aligned. When the boards are instead like this, the antennas are at less of an optimal angle, but we were still able to get about 15 meters without many issues.
Your mileage is definitely going to vary, but you can expect a pretty reliable 10 meters, maybe not through a solid brick wall, but a few pieces of furniture in the way. And if you have clear line of sight with the boards, we would say 15 meters, maybe more depends on your environment and setup. One of the things that blew us away with this is how it all just works. You can turn off a base station and within two to three seconds of plugging it back in, it's already connected to the network and beaming out its distance data.
It's a system that just works. Once in a while, a board might struggle to connect when you power it on, but just quickly power cycling it and fix that. And once it's connected, it really likes to stay connected. We ran a full system of nine of these for hours and hours on end, and there's almost zero dropouts. Now I did tell a little lie earlier. These boards will be accurate to about 10 centimeters if their offsets are calibrated.
Every board will likely read higher or lower a little bit. Some boards might read five centimeters too high, some might read 30 centimeters too low. But because the boards are consistently incorrect, we can calibrate out that error. This is just kind of a quirk with dealing with ultra wideband modules. There is an AT command that sets something called the antenna delay. With a bit of trial and error, you could definitely fix this offset through that.
And it's probably actually the proper way of doing it all. But personally, I found it was way easier to just account for it in any code. If I wanted to calibrate base station two, I would put the tag exactly a meter away. And if it reads 1.2 meters, I'll take 0.2 meters away from any distance measurements in any code that I write for it. You can just fix that error in the code. It's not as elegant, but it's definitely easier and gets the same outcome of having accurate distance measurement.
And this leads us to our final thing. These boards are a very deep rabbit hole of things that you can actually do. We are just using the simple caveman mode on these, which can do quite a lot. In the next video, we're going to show you how to add 3D spatial tracking to your project with it. So it's kind of enough for most projects. But if you have one of these boards and you want to dig deeper, there are other operational modes, other settings, ways to configure these, ways to manually bind modules together.
I think there is a way to create a setup with multiple tags being tracked instead of just one. We'll have some resources to get started if you want to dig deeper. Well, that about wraps us up for this video. You now have a jump off point to apply ultra wideband in your next project. And really, your kind of imagination is the limit here. This is just a technology you have access to, to measure the distance between two points in a project.
Like we said, we'll be showing you how to do some spatial tracking probably in the next video with a few of these base stations. But you can use this for simpler things like knowing if your robot vacuum or mower is close to a gate so it can automatically open. This is a niche example, but we have seen this exact problem on our community forums. And this is kind of the perfect solution.
If you do make something cool with this or you need a hand with anything from this video, you should also head on over to our forums and post about it. We're all makers over there and we're happy to help. Until next time though, happy making.
Makers love reviews as much as you do, please follow this link to review the products you have purchased.