Introduction: 10 CM Accurate Ultra-wide Band (UWB) Positioning for Arduino, Python and Raspberry Pi Projects: the Easiest Way.

About: Robots and automation

Performance you can expect from this project:

The video below is slightly older. Since, Pozyx has managed to increase the update rate for two-way ranging to 140 hertz and for TDOA to 400 - 1000 hertz. But this is still one of my favorite videos as it really communicates the real world accuracy of the Pozyx uwb-only positioning well. No strange lab vids with simulated dots. Nono! Just a real arduino summer project we did and samba music to go along.

Step 1: Introduction and Background

Today I will show you how to use Pozyx hardware with arduino/raspberry pi and get 10 cm accurate tracking/positioning in your arduino and python projects really really fast. If you just want to get started, skip to the next step!

Full disclosure: I work as an account manager for Pozyx, you see me in the second video shooting a nerf gun at our CEO! I wrote this tutorial in my free time as I was doing a personal arduino robotics project. I wanted to help other people easily get started as the official documentation can be a bit daunting.

Pozyx ( www.pozyx.io/store ) offers ultra wide band (UWB) development kits that works with python, raspberry pi, processing, unity, has a full MQTT API and much more. The tags also shield on the arduino uno and mega and Pozyx has long since had a full arduino library with great examples (find it here) that lets you choose between dozens of settings, positioning algorithms, filters and more. With this you can really get 10 cm accuracy for your arduino projects in areas up to 1000m2 with just four anchors.


Step 2: ARDUINO: the 5 Min Set Up With the Pozyx Cloud App and Arduino Create

Using the full pozyx arduino library is great if you have intimate knowledge of arduino and know exactly what you are building. Today however, I am going to show you how you can use the new Pozyx cloud app together with arduino create to visualise your positioning and get real cm accurate coordinates in your arduino's serial monitor in under 5 minutes. Ready? Here we go!

WHAT YOU NEED:

1. An arduino uno or mega.
2. A Pozyx developer kit or a ready to localize kit with at least one extra tag.
3. Arduino create: https://create.arduino.cc/
4. The Pozyx cloud software installed on your computer.

STEPS:

1. Make sure you have the latest version of the Pozyx cloud app and firmware running.
Find these here: https://www.pozyx.io/Documentation/get_started_cl...

2. Set your anchors up, run the Pozyx cloud app.

3. Connect your tag, discover it and make sure you get good positioning coordinates.

4. Install arduino. We highly recommend the new arduino create cloud app: https://create.arduino.cc/editor

5. In arduino create web editor, go to librairies and search for Pozyx. Clicking this will guide you to the Pozyx github page. Navigate to the example sketch called "pozyx_check_new_position.ino" in the folder useful under examples. (Later you will just find this straight under "Pozyx>examples" in arduino create.

6. Plug your arduino Uno or mega into your computer and shield your Pozyx tag. Now hit upload.

7. Open the serial monitor at 115200 baud rate.

8. Go back to the arduino cloud app and discover the tag shielded to your arduino.

9. You now get a steady stream of positioning coordinates on your arduino and on the serial monitor. You access these as "position.x", "position.y" and "position.z".

Example:

if (position.x > 1000) {

digitalWrite(13, HIGH); // switches the motor connected to pin 13 on when the tag is 1m or more away from the Y-axis. Serial.println("MotorOn"); // print the motor status to the serial monitor. }

Step 3: RASPBERRY PI/ PYTHON: the 5 Min Set Up With the Pozyx Cloud App and Python/ Raspberry PI

Using Pozyx with raspberry pi is even easier than with arduino. All you need to do is setup the cloud app and subscribe via python to the cloud app's MQTT API. You can connect Pozyx tags via micro usb cable to your raspberry pi. No shielding or I2C required! Note that you do not even need a pi. You can do this on any pc that has python.


WHAT YOU NEED:

1. A rapsberry pi.
2. A Pozyx developer kit or a ready to localize kit with at least one extra tag.
3. The Pozyx cloud software installed on your computer.

STEPS:

1. Make sure you have the latest version of the Pozyx cloud app and firmware running. Find these here: https://www.pozyx.io/Documentation/get_started_cl...
2. Set your anchors up, run the Pozyx cloud app.
3. Connect your tag, discover it and make sure you get good positioning coordinates. (see the above video, but ignore the arduino part).
4. Go to the cloud app and find your API key (see attached picture).
5. Power the second tag that your raspberry Pi will position. You can do this via the PI's usb port but any powerbank or 3,3 to 9V battery will do. You do not need a direct connection between the slave tag and the pi.
6. Use the python code found here, to get the positioning coordinates to your pi.

Step 4: Conclusion

As you saw, using arduino create with the Pozyx developer kit and the new Pozyx cloud app makes for really rapid development. You just get instant results. Python and raspberry Pi are even easier. The MQTT API we used in the raspberry pi/python setup is also supported by libraries in java-script, c# and most popular programming languages.

Pozyx is really powerful. The beauty of the development hardware is that you can prototype really fast, and then on the same platform do setups of 100's of tags and anchors for commercial applications like you see in the attached image (which is a gif, click it if you want to see it move! real setup, no simulation!).

If you want to know more about indoor positioning, Pozyx, the capabilities of UWB and what other projects use, just check out some of the links below. For any direct questions, you can contact me at support@pozyx.io.

Good luck with your UWB positioning projects!


Microcontroller Contest

Participated in the
Microcontroller Contest