Hi everyone,
i already wrote this topic into the german channel but should try it again in the Portenta category.
With the example sketch of the UWB Shield i am able to track 2 UWB Stella. For each Stella (Tag) i just have to start a new session with an individual preamble.
What i cant do is tracking one Tag with Multiple c33 + UWB Shield. The goal is to set up a RTLS with 8 Anchors (all c33+UWB Shiel) and 30 Tags (all Stella).
I am playing around with 2 Anchors and 1 Tag right now.
btw: my coding experiance is 2 out of 10 so please dont judge me ![]()
Anchor 1:
#include <PortentaUWBShield.h>
void rangingHandler(UWBRangingData &rangingData) {
if(rangingData.measureType()==(uint8_t)uwb::MeasurementType::TWO_WAY)
{
RangingMeasures twr=rangingData.twoWayRangingMeasure();
for(int j=0;j<rangingData.available();j++)
{
if(twr[j].status==0 && twr[j].distance!=0xFFFF)
{
Serial.print("Entfernung zur Session ");
Serial.print(rangingData.sessionHandle(), HEX);
Serial.print(" - ");
Serial.print(twr[j].distance);
Serial.println(" cm");
}
}
}
}
void setup()
{
Serial.begin(115200);
#if defined(ARDUINO_PORTENTA_C33)
pinMode(LEDR, OUTPUT);
digitalWrite(LEDR, LOW);
#endif
UWB.registerRangingCallback(rangingHandler);
UWB.begin();
Serial.println("Starting UWB ...");
while(UWB.state()!=0)
delay(10);
// ============ SESSION 1 START ============
Serial.println("Starte Session 1 ...");
uint8_t anchor1Addr[] = {0x21, 0x01}; // Verbindung von Anchor 1 zu Tag 1.
uint8_t tag1Addr[] = {0x10, 0x01}; // Verbindung zu Tag 1.
UWBMacAddress anchor1Mac(UWBMacAddress::Size::SHORT, anchor1Addr);
UWBMacAddress tag1Mac(UWBMacAddress::Size::SHORT, tag1Addr);
//Session 100001 für Tag 1 - bis *30 abändern
UWBMultiSessionAnchor session1(0x100101, anchor1Mac, tag1Mac, 11);
UWBSessionManager.addSession(session1);
session1.init();
session1.start();
// ============ SESSION 1 ENDE ============
}
void loop()
{
#if defined(ARDUINO_PORTENTA_C33)
digitalWrite(LEDR, !digitalRead(LEDR));
#endif
delay(1000);
}
Anchor 2
#include <PortentaUWBShield.h>
void rangingHandler(UWBRangingData &rangingData) {
if(rangingData.measureType()==(uint8_t)uwb::MeasurementType::TWO_WAY)
{
RangingMeasures twr=rangingData.twoWayRangingMeasure();
for(int j=0;j<rangingData.available();j++)
{
if(twr[j].status==0 && twr[j].distance!=0xFFFF)
{
Serial.print("Entfernung zur Session ");
Serial.print(rangingData.sessionHandle(), HEX);
Serial.print(" - ");
Serial.print(twr[j].distance);
Serial.println(" cm");
}
}
}
}
void setup()
{
Serial.begin(115200);
#if defined(ARDUINO_PORTENTA_C33)
pinMode(LEDR, OUTPUT);
digitalWrite(LEDR, LOW);
#endif
UWB.registerRangingCallback(rangingHandler);
UWB.begin();
Serial.println("Starting UWB ...");
while(UWB.state()!=0)
delay(10);
// ============ SESSION 1 START ============
Serial.println("Starte Session 1 ...");
uint8_t anchor1Addr[] = {0x22, 0x01}; // Verbindung von Anchor 2 zu Tag 1.
uint8_t tag1Addr[] = {0x10, 0x01}; // Verbindung zu Tag 1.
UWBMacAddress anchor1Mac(UWBMacAddress::Size::SHORT, anchor1Addr);
UWBMacAddress tag1Mac(UWBMacAddress::Size::SHORT, tag1Addr);
//Session 100001 für Tag 1 - bis *30 abändern
UWBMultiSessionAnchor session1(0x100102, anchor1Mac, tag1Mac, 11);
UWBSessionManager.addSession(session1);
session1.init();
session1.start();
// ============ SESSION 1 ENDE ============
}
void loop()
{
#if defined(ARDUINO_PORTENTA_C33)
digitalWrite(LEDR, !digitalRead(LEDR));
#endif
delay(1000);
}
Tag
#include "StellaUWB.h"
void rangingHandler(UWBRangingData &rangingData) {
if(rangingData.measureType()==(uint8_t)uwb::MeasurementType::TWO_WAY)
{
RangingMeasures twr=rangingData.twoWayRangingMeasure();
for(int j=0;j<rangingData.available();j++)
{
if(twr[j].status==0 && twr[j].distance!=0xFFFF)
{
Serial.print("Distance: ");
Serial.println(twr[j].distance);
}
}
}
}
void setup() {
Serial.begin(115200);
uint8_t devAddr[]={0x10,0x01};
uint8_t destination1[]={0x21,0x01}; // Verbindung zu Anchor 1 von Tag 1.
uint8_t destination2[]={0x22,0x01}; // Verbindung zu Anchor 2 von Tag 1.
UWBMacAddress srcAddr(UWBMacAddress::Size::SHORT,devAddr);
UWBMacAddress dstAddr1(UWBMacAddress::Size::SHORT,destination1);
UWBMacAddress dstAddr2(UWBMacAddress::Size::SHORT,destination2);
UWB.registerRangingCallback(rangingHandler);
UWB.begin();
Serial.println("Starting UWB ...");
while(UWB.state()!=0)
delay(10);
Serial.println("Starting session ...");
UWBMultiSessionTag myTag1(0x100101, srcAddr, dstAddr1, 11);
UWBMultiSessionTag myTag2(0x100102, srcAddr, dstAddr2, 11);
UWBSessionManager.addSession(myTag1);
UWBSessionManager.addSession(myTag2);
myTag1.init();
myTag2.init();
myTag1.start();
myTag2.start();
}
void loop() {
delay(1000);
}
Anchor 1 > Tag 1 is working fine
Anchor 2 > Tag 1 is not
In the Tag code i defined 2 destinations: (0x21, 0x01) and (0x22, 0x01).
So the Tag "knows" both Anchors.
In each Anchor i defined the Tag with (0x10, 0x01)
So both Anchors knows the Tag
Aso both Anchors are defined as anchor mac (0x21, 0x01) and (0x22, 0x01), which is matching to the tag.
What i am doing whrong here?