Accurate positioning

Home > Documentation > Tutorials > Changing a device's ID

Changing a device's ID

Go to Arduino versionGo to Python version

Ever since saving Pozyx registers to its flash memory was implemented, changing your device's ID has become possible. It's possible to do this both locally and remotely, and that's what will be discussed in this short article.

Open up the Arduino sketch in the Arduino IDE under File > Examples > Pozyx > useful > pozyx_change_network_id.

Open up the Python script in the Pozyx library's useful folder. If you downloaded your library, you can likely find this at "Downloads/Pozyx-Python-library/useful/change_network_id.py"

The code explained


uint16_t new_id = 0x1000;    // the new network id of the pozyx device, change as desired
bool remote = true;         // whether to use the remote device
uint16_t remote_id = 0x6000; // the remote ID
new_id = 0x1000         # the new network id of the pozyx device, change as desired
remote = True          # whether to use the remote device
remote_id = 0x6000      # the remote ID

The parameters are what you'd expect for changing the ID: the new_id the device will take, and whether we're working with a remote device with ID remote_id. Change these to suit your preferences. In the parameters shown above, running the code would mean that a remote device with ID 0x6000 would have its ID changed to 0x1000.

Changing the ID

Now, let's look at the code that effectively reconfigures a device's network ID.

void setup(){

  // ...
  // Pozyx and serial initalization

  Pozyx.setNetworkId(new_id, remote_id);

  uint8_t regs[1] = {POZYX_NETWORK_ID};

  status = Pozyx.saveConfiguration(POZYX_FLASH_REGS, regs, 1, remote_id);
  if(status == POZYX_SUCCESS){
    Serial.println("Saving to flash was successful! Resetting system...");
    Serial.println("Saving to flash was unsuccessful!");
def set_new_id(pozyx, new_id, remote_id):
    print("Setting the Pozyx ID to 0x%0.4x" % new_id)
    pozyx.setNetworkId(new_id, remote_id)
    if pozyx.saveConfiguration(POZYX_FLASH_REGS, [POZYX_NETWORK_ID], remote_id) == POZYX_SUCCESS:
        print("Saving new ID successful! Resetting system...")
        if pozyx.resetSystem(remote_id) == POZYX_SUCCESS:

We can see that there are three steps involved in configuring a device with a new network ID. As of writing, setNetworkId doesn't change the network ID the Pozyx is using, and the Pozyx needs to be reset after its new ID has been saved to its flash memory. So these three steps are:

  • Setting the Pozyx's new ID using setNetworkId
  • Saving the Pozyx network ID register. Note that while the ID is a uint16_t value, we only use the first register address to save it. We don't need to save two registers.
  • If saving was successful, we reset the device. After the reset, the device uses the new ID. All the while, textual feedback is given to the user.

Finishing up

Changing the ID does not seem to have an immediate purpose except for if you have devices with a double ID, but changing the ID can be convenient for other reasons as well to make your setup more maintainable. Identifying anchors with a prefix, for example. Naming your anchors 0xA001 up to 0xA004 or more. This is easier to read than the default device IDs. If you have anchors on different UWB channel, naming the set on channel 5 0xA501 to 0xA504 and the set on channel 2 0xA201-0xA204 will make your life easier, and so on.

Home > Documentation > Tutorials > Changing a device's ID