Indoor Positioning with Arduino Uno R3, 4 Anchors and one pozyx tag

Hello everyone. I am a beginner when it comes to arduino programming but i recently started to learn it because of a project that i have to do in school. So i visited the pozyx website and tried to learn from their tutorials. This coding below came from the tutorial inside, i have already change the anchor’s id and the x y z coordinates to fit into my scenario. As for the remote id i changed it to a particular hecadecimal sticker that was pasted beneath my tag, so i assumed it was the id specifically for my tag. however when i change the bool remote to true i cannot get any data from my serieal monitor. but when i set it to false, a random data appears in my serial monitor. If anyone spots a problem in my coding please reply to this. :):slight_smile:

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

////////////////////////////////////////////////
////////////////// PARAMETERS //////////////////
////////////////////////////////////////////////

uint16_t remote_id = 0x697f;
bool remote = false;

boolean use_processing = false;

const uint8_t num_anchors = 4; // the number of anchors
uint16_t anchors_id[num_anchors] = {0x6e6d, 0x6969, 0x6923,0x6961}; // the network id of the anchors: change these to the network ids of your anchors.
int32_t anchors_x[num_anchors] = {0, 0, 500, 300}; // anchor x-coorindates in mm
int32_t anchors_y[num_anchors] = {0, 400, 0,400}; // anchor y-coordinates in mm
int32_t heights[num_anchors] = {1000, 1000, 1000,1000}; // anchor z-coordinates in mm

uint8_t algorithm = POZYX_POS_ALG_UWB_ONLY; // positioning algorithm to use. try POZYX_POS_ALG_TRACKING for fast moving objects.
uint8_t dimension = POZYX_3D; // positioning dimension
int32_t height = 1000; // height of device, required in 2.5D positioning

////////////////////////////////////////////////

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

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.1----------"));
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.1----------"));
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();
// sets the positioning algorithm
Pozyx.setPositionAlgorithm(algorithm, dimension, remote_id);
delay(2000);

Serial.println(F("Starting positioning: "));
}

void loop(){
coordinates_t position;
int status;

if(remote){
status = Pozyx.doRemotePositioning(remote_id, &position, dimension, height, algorithm);
}
else{
status = Pozyx.doPositioning(&position, dimension, height, algorithm);
}

if (status == POZYX_SUCCESS){
// prints out the result
printCoordinates(position);
}else{
// prints out the error code
}
}

// prints the coordinates for either humans or for processing
void printCoordinates(coordinates_t coor){
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);
}
}

// function to manually set the anchor coordinates
void setAnchorsManual(){
for(int i = 0; i < num_anchors; i++){
device_coordinates_t anchor;
anchor.network_id = anchors_id*;*

  • anchor.flag = 0x1;*
    anchor.pos.x = anchors_x*;
    anchor.pos.y = anchors_y;
    _ anchor.pos.z = heights;
    Pozyx.addDevice(anchor);
    }_

    if (num_anchors > 4){
    Pozyx.setSelectionOfAnchors(POZYX_ANCHOR_SEL_AUTO, num_anchors, remote_id);
    _ }
    }*_

Use code tags for posting code!

I assume you have the wrong baud rate set in your serial monitor. So edit your post, add code tags, set the serial monitor to 115200 baud and post the output you got in the serial monitor.

Thank you very much for your comment and help. But what are code tags though.? sorry i'm pretty bad when it comes to coding. So sorry

But what are code tags though.?

Explained in the "How to use this forum" post heading every forum topic.