How to connect 3 Anchors to a single esp32 microcontroller

Hello I am confused that how can I write the code which has all 3 anchors data and showing 3 distances from each anchor to the tag on serial monitor. Actually I have a single anchor code for each of 3 anchors and a tag code for each anchor and I want a combined code in which all 3 anchors data can be fixed so by opening serial monitor I can see 3 distances from each anchor to tag with a single microcontroller. The codes for all anchors and tag are given below:

Anchor 1 Code:
#include <SPI.h>
#include “DW1000Ranging.h”
#include “DW1000.h”

// leftmost two bytes below will become the “short address”
char anchor_addr = “02:00:00:00:00:00:00:01”; //#4

//calibrated Antenna Delay setting for this anchor
uint16_t Adelay = 16430;

// previously determined calibration results for antenna delay
// #1 16630
// #2 16610
// #3 16607
// #4 16580

// calibration distance
float dist_m = 1; //meters

#define SPI_SCK 18
#define SPI_MISO 19
#define SPI_MOSI 23
#define DW_CS 33

// connection pins
const uint8_t PIN_RST = 32; // reset pin
const uint8_t PIN_IRQ = 36; // irq pin
const uint8_t PIN_SS = 33; // spi select pin

void setup()
{
Serial.begin(115200);
delay(1000); //wait for serial monitor to connect
Serial.println(“Anchor config and start”);
Serial.print("Antenna delay ");
Serial.println(Adelay);
Serial.print("Calibration distance ");
Serial.println(dist_m);

//init the configuration
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
DW1000Ranging.initCommunication(PIN_RST, PIN_SS, PIN_IRQ); //Reset, CS, IRQ pin

// set antenna delay for anchors only. Tag is default (16384)
DW1000.setAntennaDelay(Adelay);

DW1000Ranging.attachNewRange(newRange);
DW1000Ranging.attachNewDevice(newDevice);
DW1000Ranging.attachInactiveDevice(inactiveDevice);

//start the module as an anchor, do not assign random short address
DW1000Ranging.startAsAnchor(anchor_addr, DW1000.MODE_LONGDATA_FAST_ACCURACY, false);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_SHORTDATA_FAST_LOWPOWER);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_LONGDATA_FAST_LOWPOWER);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_SHORTDATA_FAST_ACCURACY);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_LONGDATA_FAST_ACCURACY);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_LONGDATA_RANGE_ACCURACY);
}

void loop()
{
DW1000Ranging.loop();
// newRange();
}

void newRange()
{
// Serial.print("from: “);
Serial.print(DW1000Ranging.getDistantDevice()->getShortAddress(), HEX);
Serial.print(”, ");

#define NUMBER_OF_DISTANCES 1
float dist = 0.0;
for (int i = 0; i < NUMBER_OF_DISTANCES; i++) {
dist += DW1000Ranging.getDistantDevice()->getRange();
}
dist = dist/NUMBER_OF_DISTANCES;
Serial.println(dist);
}

void newDevice(DW1000Device *device)
{
Serial.print("Device added: ");
Serial.println(device->getShortAddress(), HEX);
}

void inactiveDevice(DW1000Device *device)
{
Serial.print("Delete inactive device: ");
Serial.println(device->getShortAddress(), HEX);
}

Anchor 2 Code:
#include <SPI.h>
#include “DW1000Ranging.h”
#include “DW1000.h”

// leftmost two bytes below will become the “short address”
char anchor_addr = “02:00:00:00:00:00:00:02”; //#4

//calibrated Antenna Delay setting for this anchor
uint16_t Adelay = 16467;

// previously determined calibration results for antenna delay
// #1 16630
// #2 16610
// #3 16607
// #4 16580

// calibration distance
float dist_m = 1; //meters

#define SPI_SCK 18
#define SPI_MISO 19
#define SPI_MOSI 23
#define DW_CS 4

// connection pins
const uint8_t PIN_RST = 25; // reset pin
const uint8_t PIN_IRQ = 27; // irq pin
const uint8_t PIN_SS = 4; // spi select pin

void setup()
{
Serial.begin(115200);
delay(1000); //wait for serial monitor to connect
Serial.println(“Anchor config and start”);
Serial.print("Antenna delay ");
Serial.println(Adelay);
Serial.print("Calibration distance ");
Serial.println(dist_m);

//init the configuration
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
DW1000Ranging.initCommunication(PIN_RST, PIN_SS, PIN_IRQ); //Reset, CS, IRQ pin

// set antenna delay for anchors only. Tag is default (16384)
DW1000.setAntennaDelay(Adelay);

DW1000Ranging.attachNewRange(newRange);
DW1000Ranging.attachNewDevice(newDevice);
DW1000Ranging.attachInactiveDevice(inactiveDevice);

//start the module as an anchor, do not assign random short address
DW1000Ranging.startAsAnchor(anchor_addr, DW1000.MODE_LONGDATA_FAST_ACCURACY, false);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_SHORTDATA_FAST_LOWPOWER);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_LONGDATA_FAST_LOWPOWER);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_SHORTDATA_FAST_ACCURACY);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_LONGDATA_FAST_ACCURACY);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_LONGDATA_RANGE_ACCURACY);
}

void loop()
{
DW1000Ranging.loop();
}

void newRange()
{
// Serial.print("from: “);
Serial.print(DW1000Ranging.getDistantDevice()->getShortAddress(), HEX);
Serial.print(”, ");

#define NUMBER_OF_DISTANCES 1
float dist = 0.0;
for (int i = 0; i < NUMBER_OF_DISTANCES; i++) {
dist += DW1000Ranging.getDistantDevice()->getRange();
}
dist = dist/NUMBER_OF_DISTANCES;
Serial.println(dist);
}

void newDevice(DW1000Device *device)
{
Serial.print("Device added: ");
Serial.println(device->getShortAddress(), HEX);
}

void inactiveDevice(DW1000Device *device)
{
Serial.print("Delete inactive device: ");
Serial.println(device->getShortAddress(), HEX);
}

Anchor 3 Code:
#include <SPI.h>
#include “DW1000Ranging.h”
#include “DW1000.h”

// leftmost two bytes below will become the “short address”
char anchor_addr = “02:00:00:00:00:00:00:03”; //#4

//calibrated Antenna Delay setting for this anchor
uint16_t Adelay = 16458;

// previously determined calibration results for antenna delay
// #1 16630
// #2 16610
// #3 16607
// #4 16580

// calibration distance
float dist_m = 1; //meters

#define SPI_SCK 18
#define SPI_MISO 19
#define SPI_MOSI 23
#define DW_CS 15

// connection pins
const uint8_t PIN_RST = 26; // reset pin
const uint8_t PIN_IRQ = 14; // irq pin
const uint8_t PIN_SS = 15; // spi select pin

void setup()
{
Serial.begin(115200);
delay(1000); //wait for serial monitor to connect
Serial.println(“Anchor config and start”);
Serial.print("Antenna delay ");
Serial.println(Adelay);
Serial.print("Calibration distance ");
Serial.println(dist_m);

//init the configuration
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
DW1000Ranging.initCommunication(PIN_RST, PIN_SS, PIN_IRQ); //Reset, CS, IRQ pin

// set antenna delay for anchors only. Tag is default (16384)
DW1000.setAntennaDelay(Adelay);

DW1000Ranging.attachNewRange(newRange);
DW1000Ranging.attachNewDevice(newDevice);
DW1000Ranging.attachInactiveDevice(inactiveDevice);

//start the module as an anchor, do not assign random short address
DW1000Ranging.startAsAnchor(anchor_addr, DW1000.MODE_LONGDATA_FAST_ACCURACY, false);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_SHORTDATA_FAST_LOWPOWER);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_LONGDATA_FAST_LOWPOWER);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_SHORTDATA_FAST_ACCURACY);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_LONGDATA_FAST_ACCURACY);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_LONGDATA_RANGE_ACCURACY);
}

void loop()
{
DW1000Ranging.loop();
}

void newRange()
{
// Serial.print("from: “);
Serial.print(DW1000Ranging.getDistantDevice()->getShortAddress(), HEX);
Serial.print(”, ");

#define NUMBER_OF_DISTANCES 1
float dist = 0.0;
for (int i = 0; i < NUMBER_OF_DISTANCES; i++) {
dist += DW1000Ranging.getDistantDevice()->getRange();
}
dist = dist/NUMBER_OF_DISTANCES;
Serial.println(dist);
}

void newDevice(DW1000Device *device)
{
Serial.print("Device added: ");
Serial.println(device->getShortAddress(), HEX);
}

void inactiveDevice(DW1000Device *device)
{
Serial.print("Delete inactive device: ");
Serial.println(device->getShortAddress(), HEX);
}

Tag Code:
#include <SPI.h>
#include “DW1000Ranging.h”
#include “DW1000.h”

#define SPI_SCK 18
#define SPI_MISO 19
#define SPI_MOSI 23
#define DW_CS 5

// connection pins
const uint8_t PIN_RST = 16; // reset pin
const uint8_t PIN_IRQ = 17; // irq pin
const uint8_t PIN_SS = 5; // spi select pin

// TAG antenna delay defaults to 16384
// leftmost two bytes below will become the “short address”
char tag_addr = “02:00:00:00:00:00:10:01”;

void setup()
{
Serial.begin(115200);
delay(1000);

//init the configuration
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
DW1000Ranging.initCommunication(PIN_RST, PIN_SS, PIN_IRQ); //Reset, CS, IRQ pin

DW1000Ranging.attachNewRange(newRange);
DW1000Ranging.attachNewDevice(newDevice);
DW1000Ranging.attachInactiveDevice(inactiveDevice);

// start as tag, do not assign random short address

// DW1000Ranging.startAsTag(tag_addr, DW1000.MODE_LONGDATA_RANGE_LOWPOWER, false);
DW1000Ranging.startAsTag(tag_addr, DW1000.MODE_LONGDATA_FAST_ACCURACY, false);

}

void loop()
{
DW1000Ranging.loop();
// newRange();
}

void newRange()
{
Serial.print(DW1000Ranging.getDistantDevice()->getShortAddress(), HEX);
Serial.print(“,”);
Serial.println(DW1000Ranging.getDistantDevice()->getRange());
}

void newDevice(DW1000Device *device)
{
Serial.print("Device added: ");
Serial.println(device->getShortAddress(), HEX);
}

void inactiveDevice(DW1000Device *device)
{
Serial.print("delete inactive device: ");
Serial.println(device->getShortAddress(), HEX);
}

So please help me to give a combined code for anchors. And another question is there any need tp change the tag code?

Short answer - not easily.

The longer answer is by learning how the ranging library you are currently using actually works and then either making lots of changes or creating your own from scratch that does what you need.

I’m assuming the code you are using is either this arduino-dw1000/src/DW1000Ranging.h at master · thotro/arduino-dw1000 · GitHub or something based off of that.

That library defines everything as being static, a horrible coding style that means that in effect you can only every have one instance of it. If you need to control 3 devices from one processor you’re either going to need to create a version that can handle multiple DW1000 devices or stick to one device per instance of DW1000Ranging and have three instances of that class. Either way you’re looking at significant changes to the library.

In terms of making the changes to the library:
Step 1 - change it so things aren’t static, remove the extern reference at the end. Get that to build for a single instance.
Step 2 - assuming they aren’t all on independent SPI busses change it so that all SPI access go through a middle layer that allows the bus to be shared without causing any resource starvation / locking issues.
Step 3 - Once that all works for a single instance create multiple instances but only try to use one of them at a time. Once that works try them all at the same time.

So you mean my removing static keyword from some code files inside DW1000 library and furthermore doing all three steps which you mentioned above will I be able to run and operate all three anchors on on microcontroller? Actually as you mentioned above there is a lot more changes has to be done in the library which is a hactic task. However I am still trying it. If you have or anyone have such DW1000 library which can handle multiple anchors on one microcontroller so then please share with me.

Technically you don’t need to remove the static keyword from all of the lines, just some. But which ones depends on the code so it gets complicated, removing them all should be safe but may cost you some extra RAM.
The other big issue is if you have to share the SPI bus between multiple devices. You need to ensure that things play nicely if say you get an interrupt from device 2 while in the middle of uploading data to device 1.

What I listed was the bare minimum that would be needed to be done. How much more and exactly what depends on the underlying code. If everything is wrapped within that c++ class then creating multiple instances should be safe. If under the covers it talks to a c based driver that has a fundamental assumption of only one device baked into it then more work may be needed.

Its seems to be very confusing and difficult to modify the library. I am trying but there is alot of compilation errors after library modifications. Is someone implemented this library modification? The other option is to use seperate microcontroller for each achor and that’s what I don’t want. I removed all static keyword from all codes file inside library but still alot of error some of one error is below:

Arduino: 1.8.7 (Windows 10), Board: “ESP32 Dev Module, Disabled, Default, 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 115200, None”

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Device.cpp: In member function ‘void DW1000Device::setAddress(char*)’:

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Device.cpp:58:55: error: ‘DW1000’ was not declared in this scope

void DW1000Device::setAddress(char deviceAddress) { DW1000.convertToByte(deviceAddress, _ownAddress); }

                                                   ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp: In static member function ‘static void DW1000RangingClass::initCommunication(uint8_t, uint8_t, uint8_t)’:

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp:103:2: error: ‘DW1000’ was not declared in this scope

DW1000.begin(myIRQ, myRST);

^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp: In static member function ‘static void DW1000RangingClass::configureNetwork(uint16_t, uint16_t, const byte*)’:

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp:110:2: error: ‘DW1000’ was not declared in this scope

DW1000.newConfiguration();

^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp: In static member function ‘static void DW1000RangingClass::generalStart()’:

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp:121:2: error: ‘DW1000’ was not declared in this scope

DW1000.attachSentHandler(handleSent);

^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp: In static member function ‘static void DW1000RangingClass::startAsAnchor(char*, const byte*, bool)’:

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp:164:2: error: ‘DW1000’ was not declared in this scope

DW1000.convertToByte(address, _currentAddress);

^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp: In static member function ‘static void DW1000RangingClass::startAsTag(char*, const byte*, bool)’:

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp:197:2: error: ‘DW1000’ was not declared in this scope

DW1000.convertToByte(address, _currentAddress);

^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp: In static member function ‘static void DW1000RangingClass::loop()’:

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp:397:6: error: ‘DW1000’ was not declared in this scope

  DW1000.getTransmitTimestamp(myDistantDevice->timePollAckSent);

  ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp:404:5: error: ‘DW1000’ was not declared in this scope

 DW1000.getTransmitTimestamp(timePollSent);

 ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp:423:5: error: ‘DW1000’ was not declared in this scope

 DW1000.getTransmitTimestamp(timeRangeSent);

 ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp:451:3: error: ‘DW1000’ was not declared in this scope

DW1000.getData(data, LEN_DATA);

^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp: In static member function ‘static void DW1000RangingClass::transmitInit()’:

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp:759:2: error: ‘DW1000’ was not declared in this scope

DW1000.newTransmit();

^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp: In static member function ‘static void DW1000RangingClass::transmit(byte*)’:

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp:765:2: error: ‘DW1000’ was not declared in this scope

DW1000.setData(datas, LEN_DATA);

^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp: In static member function ‘static void DW1000RangingClass::transmit(byte*, DW1000Time)’:

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp:771:2: error: ‘DW1000’ was not declared in this scope

DW1000.setDelay(time);

^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp: In static member function ‘static void DW1000RangingClass::transmitRange(DW1000Device*)’:

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp:868:30: error: ‘DW1000’ was not declared in this scope

DW1000Time timeRangeSent = DW1000.setDelay(deltaTime);

                          ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp:892:36: error: ‘DW1000’ was not declared in this scope

myDistantDevice->timeRangeSent = DW1000.setDelay(deltaTime);

                                ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp: In static member function ‘static void DW1000RangingClass::receiver()’:

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000Ranging.cpp:928:2: error: ‘DW1000’ was not declared in this scope

DW1000.newReceive();

^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:38:39: error: ‘void (* DW1000Class::_handleSent)()’ is not a static data member of ‘class DW1000Class’

void (* DW1000Class::_handleSent)(void) = 0;

                                   ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:39:40: error: ‘void (* DW1000Class::_handleError)()’ is not a static data member of ‘class DW1000Class’

void (* DW1000Class::_handleError)(void) = 0;

                                    ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:40:43: error: ‘void (* DW1000Class::_handleReceived)()’ is not a static data member of ‘class DW1000Class’

void (* DW1000Class::_handleReceived)(void) = 0;

                                       ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:41:48: error: ‘void (* DW1000Class::_handleReceiveFailed)()’ is not a static data member of ‘class DW1000Class’

void (* DW1000Class::_handleReceiveFailed)(void) = 0;

                                            ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:42:49: error: ‘void (* DW1000Class::_handleReceiveTimeout)()’ is not a static data member of ‘class DW1000Class’

void (* DW1000Class::_handleReceiveTimeout)(void) = 0;

                                             ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:43:60: error: ‘void (* DW1000Class::_handleReceiveTimestampAvailable)()’ is not a static data member of ‘class DW1000Class’

void (* DW1000Class::_handleReceiveTimestampAvailable)(void) = 0;

                                                        ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:55:19: error: ‘byte DW1000Class::_vmeas3v3’ is not a static data member of ‘class DW1000Class’

byte DW1000Class::_vmeas3v3 = 0;

               ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:56:19: error: ‘byte DW1000Class::_tmeas23C’ is not a static data member of ‘class DW1000Class’

byte DW1000Class::_tmeas23C = 0;

               ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:59:25: error: ‘byte DW1000Class::_extendedFrameLength’ is not a static data member of ‘class DW1000Class’

byte DW1000Class::_extendedFrameLength = FRAME_LENGTH_NORMAL;

                     ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:60:25: error: ‘byte DW1000Class::_pacSize’ is not a static data member of ‘class DW1000Class’

byte DW1000Class::_pacSize = PAC_SIZE_8;

                     ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:61:25: error: ‘byte DW1000Class::_pulseFrequency’ is not a static data member of ‘class DW1000Class’

byte DW1000Class::_pulseFrequency = TX_PULSE_FREQ_16MHZ;

                     ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:62:25: error: ‘byte DW1000Class::_dataRate’ is not a static data member of ‘class DW1000Class’

byte DW1000Class::_dataRate = TRX_RATE_6800KBPS;

                     ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:63:25: error: ‘byte DW1000Class::_preambleLength’ is not a static data member of ‘class DW1000Class’

byte DW1000Class::_preambleLength = TX_PREAMBLE_LEN_128;

                     ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:64:25: error: ‘byte DW1000Class::_preambleCode’ is not a static data member of ‘class DW1000Class’

byte DW1000Class::_preambleCode = PREAMBLE_CODE_16MHZ_4;

                     ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:65:25: error: ‘byte DW1000Class::_channel’ is not a static data member of ‘class DW1000Class’

byte DW1000Class::_channel = CHANNEL_5;

                     ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:66:25: error: ‘DW1000Time DW1000Class::_antennaDelay’ is not a static data member of ‘class DW1000Class’

DW1000Time DW1000Class::_antennaDelay;

                     ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:67:25: error: ‘boolean DW1000Class::_antennaCalibrated’ is not a static data member of ‘class DW1000Class’

boolean DW1000Class::_antennaCalibrated = false;

                     ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:68:25: error: ‘boolean DW1000Class::_smartPower’ is not a static data member of ‘class DW1000Class’

boolean DW1000Class::_smartPower = false;

                     ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:70:25: error: ‘boolean DW1000Class::_frameCheck’ is not a static data member of ‘class DW1000Class’

boolean DW1000Class::_frameCheck = true;

                     ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:71:25: error: ‘boolean DW1000Class::_permanentReceive’ is not a static data member of ‘class DW1000Class’

boolean DW1000Class::_permanentReceive = false;

                     ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:72:25: error: ‘uint8_t DW1000Class::_deviceMode’ is not a static data member of ‘class DW1000Class’

uint8_t DW1000Class::_deviceMode = IDLE_MODE; // TODO replace by enum

                     ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:74:25: error: ‘boolean DW1000Class::_debounceClockEnabled’ is not a static data member of ‘class DW1000Class’

boolean DW1000Class::_debounceClockEnabled = false;

                     ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:109:33: error: ‘const SPISettings DW1000Class::_fastSPI’ is not a static data member of ‘class DW1000Class’

const SPISettings DW1000Class::_fastSPI = SPISettings(16000000L, MSBFIRST, SPI_MODE0);

                             ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:111:32: error: ‘const SPISettings DW1000Class::_slowSPI’ is not a static data member of ‘class DW1000Class’

const SPISettings DW1000Class::_slowSPI = SPISettings(2000000L, MSBFIRST, SPI_MODE0);

                            ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:112:33: error: ‘const SPISettings* DW1000Class::_currentSPI’ is not a static data member of ‘class DW1000Class’

const SPISettings* DW1000Class::_currentSPI = &_fastSPI;

                             ^

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:112:48: error: invalid use of non-static data member ‘DW1000Class::_fastSPI’

const SPISettings* DW1000Class::_currentSPI = &_fastSPI;

                                            ^

In file included from C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.cpp:24:0:

C:\Users\Muhammad Muzaffar\Documents\Arduino\libraries\DW1000_library\src\DW1000.h:566:20: note: declared here

const SPISettings _fastSPI;

                ^

exit status 1
Error compiling for board ESP32 Dev Module.

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

Is you or anyone further help me to get out from this situation so that I can control each anchor on one microcontroller?

From a quick glance through the errors it looks like one of the underlying classes (DW1000) also defined as being static and so can only be called from within a function that is static.
Which either means you need to work out which functions can be static and which can’t and go from there or you need to remove the static from the DW1000Class and repeat.
You are now on the second half of the first step, this isn’t even the hard bit.

Doing this and getting it to work this requires a knowledge of how the libraries work, what the keyword static means, and general c/c++ knowledge and experience.

Which brings us back to the first line of my first answer, it’s not easy. In terms of time/effort unless your time has zero cost associated with it or you are planning on building hundreds of systems it’s probably cheaper and easier to use one processor per part.

As for your question as to whether there is other code already existing that you could use to do this - positioning accuracy when anchors are all in the same place is terrible so this isn’t something you would normally want to do. That combined with the difficulty of hitting tight timing requirements on multiple devices simultaneously if they share a processor means that there are very few times when someone would ever want to run multiple devices off a single processor. Which is why just about all the code assumes only a single device.
Several years ago there was a DW1000 based phase difference of arrival dev kit offered. That ran two DW1000 devices off a single processor, the second one was slaved to the first rather than running as an independent device but it’s the only system I’m aware of that even came close to running two radios from a single processor. The official code for it was gone from the decawave site long before qorvo moved everything over to their domain but this is the internet, there is probably a copy floating around somewhere.

Hello, what is your exact use case ? having several UWB transceivers connected to a single MCU could work for very specific use cases. For a ‘standard’ RTLS thing (several anchors reporting distance), you need to have anchors separated from several meters in order to cover high surface and increase the precision of the location.

For this kind of use case, and 3 transceivers connected to a single MCU, you will likely need to have SPI wires of several meters, I’m not so sure it would work from a HW point of view. SPI bus is not meant for long distance.