TWR using SPI on Raspberry Pi

I am trying to use the DWM1001 to do two way ranging (TWR).
I have the DWM1001 connected to a Raspberry Pi 3 (compute module), using SPI.
I am able to run the examples: tag_cfg, anchor_cfg, and ext_api_fulltest. As such, I believe that my physical connection between the DWM1001 and RPi is correct.
I am using the factory image (DWM1001_R1_default.hex) on the DWM1001.
I have the DWM1001 developer kit, with 16 modules.

I am not sure how to get TWR working so that I can see distances between the modules. I thought one of the examples in ex1_TWR_2Hosts would do this, but those examples are so poorly documented that it’s difficult to tell what those scripts are actually trying to do.

I thought there might be something in HAL that would allow me to do this, but I have not found documentation that sufficiently explains how I would do this.

I know it must be possible, and imagine that I’m missing something fairly straighforward.

Thanks for any help anyone might be able to offer!


Hi James,

Have you connected two raspberry pi to two different dwm1001 ?

When using the default firmware on dwm1001, TWR will automatically be performed if you configure one device as initiator, and another one as active tag. Then you can observe the distance between devices on the tag, setting up a serial connection from the raspberry pi for example.

Have you had a look at the firmware user guide document ?


Hi James,

Sorry the on-board examples are not well documented. The Firmware API guide may also help you better understand the API examples.


I neglected to reply that I did get this working.

– the module connected to the Raspberry Pi via SPI, and is set up as a tag
– the other module is powered on, not connected to anything, and is set up as an anchor
– the tag needs to have Location Engine LE turned off
– the anchor needs to be both ACTIVE and INITIATOR

With that setup, running dwm_loc_get() as shown in the tag_cfg.c example will return an array of distances.

NOTE: This will work with as few as a single anchor, whereas with LE turned on, a minimum of 3 anchor are required. With LE turned on, a location for the tag is returned, but no distances between the tag and anchors.

Hi James,

I’m trying to connect the dwm1001 to the Raspberry Pi via SPI. I have followed the steps in the firmware guide but I nothing happens when I run ./tag_cfg. I have 4 anchors set up (one is also an initiator) and one tag connected to the pins on the Pi. Could you explain how you set yours up or link any other documentation you found?

Thank you in advance!