ESP32

Indoor Positioning System with MaUWB ESP32S3 DW3000

Indoor Positioning System:

Indoor Positioning System with MaUWB ESP32S3 DW3000- In my last article, I showed how two MaUWB_ESP32S3 UWB modules can communicate with each other. I used one module as an Anchor and the other as a Tag. On the Anchor’s OLED display, I was able to successfully monitor the Tag’s distance. Although this worked really well, but still there was something missing; we could only see how far the Tag was, but we didn’t know its exact position; like which side of the Anchor it was on. To track the Tag’s exact position and to build a complete Indoor Positioning system; we need at least 3 or more Anchors.

Indoor Positioning System

After reading this article, you will not only be able to track the position of a tag on a computer application designed in Python; but you will also be able to wirelessly monitor the Tag’s position on your system and smart phone.

allpcb circuit

So, without any further delay, let’s get started!!!




Amazon Links:

MaUWB ESP32S3 UWB Modules “Product Official page”

SSD1306 Oled display

ESP32 WiFi + Bluetooth Module (Recommended)

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Initial Setup:

Indoor Positioning System

Right now, I only have these two modules. For my initial experiments, I am going to use these two modules as Anchors A0 and A1. And I am going to create a tag myself using the MakerFabs MaUWB DW3000 chipset and my newly created ESP32S3 based development board.

To interface the MaUWB DW3000 chipset with the ESP32S3, first; we need to solder the wires.

You can follow these connections.

Indoor Positioning System



Tracking the Position on Straight Line:

Indoor Positioning System

The MaUWB DW3000 chipset has been connected to the ESP32S3, and now I can use it as either a Tag or an Anchor. This is how you can create multiple Tags and Anchors.

Before building the complete Indoor Positioning System, first; you need to understand how it actually works. For this, first I am going to explain, how to track the position of a Tag on a straight line “on X Co-ordinate”.

Since I already have two MaUWB ESP32S3 modules, which I am going to use as Anchors, I will use the one I created as the Tag.

Tip: order yourself at least 5 of these MaUWB ESP32S3 modules, this way you won’t need to make your own tags and anchors.

Connect the Tag-side ESP32S3 controller board to the laptop.

Open the following program in the Arduino IDE. For Tag 0 (“T0”), make sure the UWB_INDEX is set to 0; for Tag T1, set it to 1, and so on.

I have already explained how to install these libraries In my previous tutorial.

Adafruit_GFX

Adafruit_SSD1306

I also changed the SDA and SCL pins to GPIOs 01 and 02 because, on my ESP32S3 development board, the SSD1306 OLED display module is connected to GPIOs 01 and 02. You don’t need to change anything else.



Tag0 Code:

Next, connect one of the MaUWB ESP32S3 UWB boards to the laptop that you want to use as Anchor A0, and then open the following program. On the MakerFabs MaUWB_ESP32S3 UWB module, the SSD1306 OLED display is connected to GPIOs 39 and 38.

If I were using my ESP32S3 development board, I would change it to GPIOs 01 and 02. If you are using different I2C pins, just go ahead and change these pins. If you scroll down, you will see that it’s already defined as A0, so no further changes are needed in the code. Let me also mention that this code is specifically for Anchor A0. For all the other anchors, we will use a different code, which I will show you in a few seconds.

Additionally, Anchor A0 will remain connected to the laptop because it directly communicates with the computer application designed for real-time Tag tracking. I know it sounds unprofessional but this is how it’s done by the company. But, don’t worry; later I will make it completely wireless. Then you won’t need to physically connect any board to the Laptop.

Anyway, just go ahead and upload this program to the Anchor A0.



Get Range, Anchor “A0” Code:

Now, let’s connect another MaUWB_ESP32S3 UWB Module to the laptop. Open this program.




Anchor A1 Code:

Since we are using this as Anchor A1, the UWB_INDEX is set to 1. For Anchor A2, you would change it to 2, and so on. This way, you can create multiple Anchors. There is no need to change anything else except the I2C pins if you are using your own controller board. Anyway, you can ahead and upload the program.



Now, the Tag and two Anchors are ready.

Indoor Positioning System

Next, for the real-time Tag monitoring on the computer application, you will need to install the latest versions of

  • PyCharm and
  • Python

Let’s start with Python; for this, open the official python website, scroll down, and download the latest version.

Indoor Positioning System

I have already downloaded Python 3.13.0, so let’s proceed with the installation.



Python Installation:

  • Right click on the file and select “Run as Administrator”.

Indoor Positioning System

  • Make sure you check these Boxes, Add, python.exe to PATH is must be checked. Finally, click on the Install Now.

Once the Python is successfully installed! To double-check, open the command prompt and type Python.

Indoor Positioning System

If you see Python and its version displayed, congratulations; you have installed it correctly.

Next, we will install PyCharm.

Indoor Positioning System

Go to the JetBrains website and download the latest version of PyCharm. I have already downloaded it, so let’s proceed with the installation.



The installation process is straightforward:

Indoor Positioning System

Make sure to check all the necessary boxes during setup.

Click the Next button and wait for the installation to complete.

Indoor Positioning System

Once installed, you will see a prompt indicating that your computer needs to restart to complete the PyCharm installation. Select Reboot now and click Finish.




After rebooting your system, you will see the Pycharm Icon on the Desktop.

Indoor Positioning System

This is my PyCharm project file, but before opening this file, first; let’s define the positions of the Anchors.

Indoor Positioning System

Anchor A0, as you can see, is connected to the laptop, and its position is (0,0), meaning X = 0 cm and Y = 0 cm.

Indoor Positioning System

Similarly, the position of Anchor A1 is (114,0), meaning X = 114 cm and Y = 0 cm. The two Anchors should be horizontally aligned.

I have powered the Anchor A1 using my 5V 3A power supply and 4S lithium-Ion Battery pack. I could connect a small lipo battery to that while port on the UWB module, but unfortunately I don’t have one at the moment. Anyway, you can see it has no physical connection to the laptop.

Once the Anchor positions are set, then we can go ahead and open the PyCharm project file. copy and paste the following code.



Python application Code for two Anchors:

After opening the position project file, you will need to configure some settings. Here’s how:

  1. Go to the File menu and click on Settings.
  2. Navigate to Project: position.py and select Python Interpreter.
  3. Click on Add Interpreter.
  4. Next, choose Add Local Interpreter.
  5. Next, choose Select existing.
  6. Under Python path, choose Python 3.13.0, which we installed earlier.
  7. Finally, click the OK button.

Next, we have to install some packages;

  • numpy
  • pygame and
  • pyserial

If you will like you are stuck, you can watch the video tutorial given at the end of this article.



About the code:

I actually downloaded this code from MakerFab’s product official page. They had designed it for four anchors, but I modified it for two anchors. Anyway, to specify the anchors positions, you need to scroll down.

A0X, A0Y = 0, 0

A1X, A1Y = 146, 0  # 114cm + 32 centimeters

Set the A0X and A0Y to 0,0 and also set the position of Anchor A1; And let me tell you, no matter what the actual value is, you need to add 32 cm from your side. Because I practically tested it, the tag position was a little bit off. So, after adding 32 cm to the actual distance value, the tag position accuracy greatly improved. Instead of writing 114, you should write 146. So, you need to add 32 cm to all the anchors, in case you want to use more anchors. Apart from setting the anchor positions, you don’t need to make any other changes to the code.

Before you click on the Play button, you need to make sure that Anchor A0 is connected to the laptop, Tag T0 is ON, and Anchor A1 is also ON.

Indoor Positioning System

You can see that the distance between Anchor A0 and A1 is 114 cm. Everything looks good, so let’s go ahead and click the Play button.

Indoor Positioning System

As you can see, it can impressively track the position of Tag T0 in real time between the two anchors. You can see how accurately it tracks the position as I move the tag left and right.

The problem with using only two anchors is that we only have the X-coordinate; the Y-coordinate is missing. That’s why, if I move the tag forward or backward, it will still show the position of the tag on a straight line.

So, if you are working on a project where you need to track the position of something on a straight line or, let’s say, only on the X-coordinate, then you can use two anchors. But if you want to precisely measure the position of an object or human in an area, you will need to use at least 3 to 4 anchors. You can increase the number of anchors if you want to track the position within an irregular area. But initially, you can start with 3 to 4 anchors.



Creating the Indoor Positioning System:

Indoor Positioning System

To explain this, I created two more anchors, A2 and A3. This time, I am using simple ESP32 Dev Modules. For the connections, you can follow this circuit diagram.

Indoor Positioning System

Anchor A2 Code:

This is the modified code for Anchor A2. I set the UWB_INDEX to 2, and I also changed the pin numbers. This time, I am using GPIOs 4 and 2. On the ESP32 Dev Module, the SDA and SCL pins are 21 and 22.

Similarly, for Anchor A3, set the UWB_INDEX to 3.

These are the only changes you need to make. After that, you can go ahead and upload the programs. Make sure you remove the wires connected to the Tx and Rx pins of the ESP32 Dev Module before uploading.

Indoor Positioning System

The Tag T0 and all four anchors, A0, A1, A2, and A3, are ready. Now, let’s go ahead and take a look at the Python code.




Python application Code for 4 Anchors:

This is the original code written for four anchors. For this application, you should have at least three anchors but the recommended number of Anchors are 4, if you want to build a highly accurate indoor positioning system. In this code, I only changed the XY values of the anchors, as I already explained in the previous example. Anyway, let’s go ahead and click the Play button.

Indoor Positioning System

Now, you can see that I can track the position of Tag T0 in the XY plane. You can change the coordinates in the code, and then you will be able to track the position of this tag within a larger area let’s say a house or office, ground etc. I am sure you got the idea of how to make a real-time human/object/pet indoor positioning system.

Indoor Positioning System

Although this application is simply fantastic, the only thing I don’t like is that Anchor A0 is connected to the system, which makes the entire setup feel quite unprofessional. Every time you want to track the position of a human, pet, or any object, you have to connect Anchor A0 to your laptop/PC. So, I decided to make it completely wireless.



Wireless Indoor Positioning System:

For the wireless indoor positioning system, you need to upload the following code into the Anchor A0.

Modified Code for the Anchor A0:

This is the modified code for Anchor A0. You can see the WiFi credentials. Now, it will send the data of all four anchors to the webpage through WiFi. There is no need to modify the code for Tag T0 or the anchors A1, A2, and A3. Anyway, I have already uploaded this program. Now, let’s take a look at the Python and HTML code.

Make sure to keep the Python project file and the templates folder in the same directory.

Indoor Positioning System



Inside the templates folder, we have an HTML file named index.

Indoor Positioning System

If you want to make any changes to the code, simply right-click on the index file and select “Edit in Notepad.”

HTML Code:



Python Code for Wireless indoor Positioning System:

This is the Python code for wirelessly tracking the position of a tag in an area. Make sure to install all the required packages as explained earlier. This time, you will also need to install the Flask package.

All four anchors are powered up, and Anchor A0 is connected to the WiFi. So, let’s click the Play button.

Indoor Positioning System




You can see that we are receiving data from all four anchors. To open the webpage, we can click on this IP address.

Indoor Positioning System

After clicking on the IP address, it will open a web page for you; as you can see in the image below.

Indoor Positioning System

Now, I can precisely track the position of a human, object, or pet wirelessly; not only on my laptop but also on my cell phone. I no longer need to sit in front of my laptop.

Indoor Positioning System

In upcoming articles, I will use this setup for load automation, security, car, and bike control. So, consider subscribing if you don’t want to miss those videos and articles.



Watch Video Tutorial:

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button