In this article, some basic code snippets are provided that can help you figure out any problems when things aren't going as they should. If you haven't read the getting started, please do so and install the necessary tools and libraries.
These code snippets can be found in a Python script as well, which can be used for troubleshooting a local and remote device straight from the bat. You can find this file in the Python library's useful folder. If you downloaded the library directly from GitHub, its path is probably "Downloads/Pozyx-Python-library/useful/basic_troubleshooting.py".
We take the code snippet approach in this article because being able to re-use these in your own projects is the ultimate goal here. Here is an overview of the troubleshooting basics:
- Device check
- Network check
- Interpreting the LEDs
Local and remote device check
The first thing to do to get an insight in your Pozyx's operation status, is reading out its basic status registers.
Registers can be read using the function Pozyx.getRead() for your local device or for a remote device. A full overview of all the registers with their description can be found here. Let's read out the first 5 bytes starting from the memory address POZYX_WHO_AM_I and display the result.
pozyx.getRead(POZYX_WHO_AM_I, data, remote_id=remote_id) print('who am i: 0x%0.2x' % data) print('firmware version: 0x%0.2x' % data) print('hardware version: 0x%0.2x' % data) print('self test result: %s' % bin(data)) print('error: 0x%0.2x' % data)
For a tag, the output should show the following result:
who am i: 0x43 firmware version: 0x10 hardware version: 0x23 self test result: 0b111111 error: 0
From these results you can already learn a great deal:
- who am i is wrong: the Pozyx device is not running or it is badly connected with the Arduino. Make sure that the jumper is on the BOOT0 pins.
- firmware version is wrong: you must update the firmware as explained in updating the firmware. Make sure that all devices, anchors and tags are running on the same firmware version.
- Hardware version is wrong: is your device on fire?
- Self test is different: for the tag the result should be 0b111111, for the anchor it should be 0b110000. Check out POZYX_ST_RESULT for more information. Note: in firmware version 1.0, the self-test might currently display 0b110000 instead of 0b111111. This is an anomaly which occurs when the selftest is done before the sensors are initialized. Don't panic, this doesn't necessarily mean the sensors aren't initialized. You can try the third tutorial to quickly see whether the IMU is actually operational.Check if the problem remains after resetting the device.
- The error code is not 0: Something went wrong, this isn't necessarily dramatic. Check out POZYX_ERRORCODE to see which error was triggered. If you see error 0x09, you can safely ignore this.
Note that the function __init__ will check most of these registers as well to see if everything is working properly.
Not finding a remote device
When the who am i is not correct when reading out the register remotely, there may be additional causes:
- The remote address is wrong. It is printed on the label on the device.
- The devices are not within range or their signal is blocked for some reason.
- The devices are configured with different UWB settings. The UWB settings must be the same to enable communication. See POZYX_UWB_CHANNEL and the subsequent registers.
- Multiple Pozyx device are transmitting at the same time and are interfering with one-another.
- If you're using doDiscovery to find devices, as in the UWB configurator (Arduino), the slot duration might be too short for the UWB settings of the devices. This happpens at channel 1, max preamble length.
For positioning, a number of tags and anchors are required. Despite the hardware differences, each device can operate in both modes, for positioning. Anchors won't have IMU data. This operation mode is selected with jumper on the T/A pins.
- Tag mode: the jumper is present. This device can move around and perform positioning
- Anchor mode: the jumper absent. This device must remain stationary and will support other devices in positioning.
With the function Pozyx.doDiscovery() it is possible to obtain a list of all the devices within range. The function takes one parameter to discover either tags, anchors or both. The constants for this parameter is POZYX_DISCOVERY_ALL_DEVICES for all devices, POZYX_DISCOVERY_TAGS_ONLY for finding only tags and, as you've likely guessed, POZYX_DISCOVERY_ANCHORS_ONLY for anchors. The following code will find and display all devices within range:
pozyx.clearDevices(remote_id) if pozyx.doDiscovery(discovery_type=POZYX_DISCOVERY_ALL_DEVICES, remote_id=remote_id) == POZYX_SUCCESS: pozyx.printDeviceList(remote_id)
Interpreting the LEDs
The Pozyx device has a number of status LEDs that can also be used to analyze the Pozyx behavior at a glance.
- LED 1: This LED should be blinking slowly to indicate that the system is responsive.
- LED 2: This LED indicates that the Pozyx device is performing a specific function (for example, calibration or positioning).
- LED 3: This LED has no function.
- LED 4: This LED will indicate that there was an error somewhere. The error can be found by reading the register POZYX_ERRORCODE.
- RX LED: This indicates that the UWB receiver is enabled and that the device can receive wireless signals.
- TX LED: This LED indicates that the device has transmitted a wireless signal.
Using the register POZYX_CONFIG_LEDS the status LEDs can be configured to be turned off.