Arduino pozyx multitag positioning

Hello I want to detect my two pozyx tags using the 4 anchor devices however it gives me (error positioning, local code error 0x17) i tried to detect one tag at a time and it worked however when i try to detect both using the multitag code i get an error

#include <Pozyx.h>
#include <Pozyx_definitions.h>

#include <Pozyx.h>
#include <Pozyx_definitions.h>
#include <Wire.h>

int num_tags = 2;
uint16_t tags[2] = {0x6a5d, 0x673c};
uint16_t remote_id = 0x673c;
boolean remote = false ; // set this to true to use the remote ID
boolean use_processing = false; // set this to true to output data for the processing sketch
uint8_t num_anchors = 4; // the number of anchors
uint16_t anchors[4] = {0x6a37, 0x6a38, 0x6a3d, 0x6a54}; // the network id of the anchors: change these to the network ids of your anchors.
int32_t anchors_x[4] = {0, 0, 6108, 7050}; // anchor x-coorindates in mm
int32_t anchors_y[4] = {3467, 7986, 10754, 0}; // anchor y-coordinates in mm
int32_t heights[4] = {1951, 2699, 1441, 2559}; // anchor z-coordinates in mm
uint8_t algorithm = POZYX_POS_ALG_UWB_ONLY;
uint8_t dimension = POZYX_3D;
int32_t height = 1000;

void setup(){
Serial.begin(9600);

if(Pozyx.begin() == POZYX_FAILURE){
Serial.println(F(“ERROR: Unable to connect to POZYX shield”));
Serial.println(F(“Reset required”));
delay(100);
abort();
}
if(!remote){
remote_id = NULL;
}
Serial.println(F("----------POZYX POSITIONING V1.0----------"));
Serial.println(F(“NOTES:”));
Serial.println(F("- No parameters required."));
Serial.println();
Serial.println(F("- System will auto start anchor configuration"));
Serial.println();
Serial.println(F("- System will auto start positioning"));
Serial.println(F("----------POZYX POSITIONING V1.0----------"));
Serial.println();
Serial.println(F(“Performing manual anchor configuration:”));
// clear all previous devices in the device list
Pozyx.clearDevices(remote_id);
// sets the anchor manually
setAnchorsManual();
delay(2000);
Serial.println(F(“Starting positioning: “));
}
void setAnchorsManual(){
for (int i = 0; i < num_tags; i++){
int status = Pozyx.clearDevices(tags[i]);
for(int i = 0; i < num_anchors; i++){
device_coordinates_t anchor;
anchor.network_id = anchors[i];
anchor.flag = 0x1;
anchor.pos.x = anchors_x[i];
anchor.pos.y = anchors_y[i];
anchor.pos.z = heights[i];
status &= Pozyx.addDevice(anchor, tags[i]);
}
if (status == POZYX_SUCCESS){
Serial.print(“Configuring ID 0x”);
Serial.print(tags[i], HEX);
Serial.println(” success!”);
}else{
printErrorCode(“configuration”, tags[i]);
}
}
}
// prints the coordinates for either humans or for processing
void printCoordinates(coordinates_t coor, uint16_t tags){
uint16_t network_id = remote_id;
if (network_id == NULL){
network_id = 0;
}
if(!use_processing){
Serial.print(“POS ID 0x”);
Serial.print(network_id, HEX);
Serial.print(", x(mm): “);
Serial.print(coor.x);
Serial.print(”, y(mm): “);
Serial.print(coor.y);
Serial.print(”, z(mm): “);
Serial.println(coor.z);
}else{
Serial.print(“POS,0x”);
Serial.print(network_id,HEX);
Serial.print(”,");
Serial.print(coor.x);
Serial.print(",");
Serial.print(coor.y);
Serial.print(",");
Serial.println(coor.z);
}
}
void printErrorCode(String operation, uint16_t tags){
uint8_t error_code;
if (remote_id == NULL){
Pozyx.getErrorCode(&error_code);
Serial.print(“ERROR “);
Serial.print(operation);
Serial.print(”, local error code: 0x”);
Serial.println(error_code, HEX);
return;
}
int status = Pozyx.getErrorCode(&error_code, remote_id);
if(status == POZYX_SUCCESS){
Serial.print(“ERROR “);
Serial.print(operation);
Serial.print(” on ID 0x”);
Serial.print(remote_id, HEX);
Serial.print(", error code: 0x");
Serial.println(error_code, HEX);
}else{
Pozyx.getErrorCode(&error_code);
Serial.print(“ERROR “);
Serial.print(operation);
Serial.print(”, couldn’t retrieve remote error code, local error: 0x”);
Serial.println(error_code, HEX);
}
}
void loop(){
for (int i = 0; i < num_tags; i++){
coordinates_t position;
int status = Pozyx.doRemotePositioning(tags[i], &position, dimension, height, algorithm);
if (status == POZYX_SUCCESS){
// prints out the result
printCoordinates(position, tags[i]);
}else{
// prints out the error code
printErrorCode(“positioning”, tags[i]);
}
}
}

Your topic has been moved to this forum section as this location is more relevant to the subject

Please follow the advice given in the link below when posting code

Hello
publish your sketch in code </> and specify your question do you have.

1 Like
#include <Pozyx.h>
#include <Pozyx_definitions.h>
#include <Wire.h>

int num_tags = 2;
uint16_t tags[2] = {0x6a5d, 0x673c};
uint16_t remote_id = 0x673c;
boolean remote = true;                                        // set this to true to use the remote ID
boolean use_processing = false;                             // set this to true to output data for the processing sketch
uint8_t num_anchors = 4; // the number of anchors
uint16_t anchors[4] = {0x6a37, 0x6a38, 0x6a3d, 0x6a54};      // the network id of the anchors: change these to the network ids of your anchors.
int32_t anchors_x[4] = {0, 0, 6108, 7050};               // anchor x-coorindates in mm
int32_t anchors_y[4] = {3467, 7986, 10754, 0};                  // anchor y-coordinates in mm
int32_t heights[4] = {1951, 2699, 1441, 2559};  // anchor z-coordinates in mm
uint8_t algorithm = POZYX_POS_ALG_UWB_ONLY;
uint8_t dimension = POZYX_3D;
int32_t height = 1000;

void setup(){
  Serial.begin(9600);
 
  if(Pozyx.begin() == POZYX_FAILURE){
    Serial.println(F("ERROR: Unable to connect to POZYX shield"));
    Serial.println(F("Reset required"));
    delay(100);
    abort();
  }
  if(!remote){
    remote_id = NULL;
  }
  Serial.println(F("----------POZYX POSITIONING V1.0----------"));
  Serial.println(F("NOTES:"));
  Serial.println(F("- No parameters required."));
  Serial.println();
  Serial.println(F("- System will auto start anchor configuration"));
  Serial.println();
  Serial.println(F("- System will auto start positioning"));
  Serial.println(F("----------POZYX POSITIONING V1.0----------"));
  Serial.println();
  Serial.println(F("Performing manual anchor configuration:"));
  // clear all previous devices in the device list
  Pozyx.clearDevices(remote_id);
  // sets the anchor manually
  setAnchorsManual();
  delay(2000);
  Serial.println(F("Starting positioning: "));
}
void setAnchorsManual(){
  for (int i = 0; i < num_tags; i++){
    int status = Pozyx.clearDevices(tags[i]);
    for(int i = 0; i < num_anchors; i++){
      device_coordinates_t anchor;
      anchor.network_id = anchors[i];
      anchor.flag = 0x1;
      anchor.pos.x = anchors_x[i];
      anchor.pos.y = anchors_y[i];
      anchor.pos.z = heights[i];
      status &= Pozyx.addDevice(anchor, tags[i]);
    }
    if (status == POZYX_SUCCESS){
      Serial.print("Configuring ID 0x");
      Serial.print(tags[i], HEX);
      Serial.println(" success!");
    }else{
      printErrorCode("configuration", tags[i]);
    }
  }
}
// prints the coordinates for either humans or for processing
void printCoordinates(coordinates_t coor, uint16_t tags){
  uint16_t network_id = remote_id;
  if (network_id == NULL){
    network_id = 0;
  }
  if(!use_processing){
    Serial.print("POS ID 0x");
    Serial.print(network_id, HEX);
    Serial.print(", x(mm): ");
    Serial.print(coor.x);
    Serial.print(", y(mm): ");
    Serial.print(coor.y);
    Serial.print(", z(mm): ");
    Serial.println(coor.z);
  }else{
    Serial.print("POS,0x");
    Serial.print(network_id,HEX);
    Serial.print(",");
    Serial.print(coor.x);
    Serial.print(",");
    Serial.print(coor.y);
    Serial.print(",");
    Serial.println(coor.z);
  }
}
  void printErrorCode(String operation, uint16_t tags){
  uint8_t error_code;
  if (remote_id == NULL){
    Pozyx.getErrorCode(&error_code);
    Serial.print("ERROR ");
    Serial.print(operation);
    Serial.print(", local error code: 0x");
    Serial.println(error_code, HEX);
    return;
  }
  int status = Pozyx.getErrorCode(&error_code, remote_id);
  if(status == POZYX_SUCCESS){
    Serial.print("ERROR ");
    Serial.print(operation);
    Serial.print(" on ID 0x");
    Serial.print(remote_id, HEX);
    Serial.print(", error code: 0x");
    Serial.println(error_code, HEX);
  }else{
    Pozyx.getErrorCode(&error_code);
    Serial.print("ERROR ");
    Serial.print(operation);
    Serial.print(", couldn't retrieve remote error code, local error: 0x");
    Serial.println(error_code, HEX);
  }
}
void loop(){
  for (int i = 0; i < num_tags; i++){
    coordinates_t position;
    int status = Pozyx.doRemotePositioning(tags[i], &position, dimension, height, algorithm);
    if (status == POZYX_SUCCESS){
    // prints out the result
    printCoordinates(position, tags[i]);
    }else{
      // prints out the error code
      printErrorCode("positioning", tags[i]);
    }
  }
}

I want to find the positions of the two tags simultanously how di i do that

Your other topic on the same subject has been removed

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.