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:
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:
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:
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.
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)
The Pozyx device has a number of status LEDs that can also be used to analyze the Pozyx behavior at a glance.
Using the register POZYX_CONFIG_LEDS the status LEDs can be configured to be turned off.