A simple DW3000 library for the ESP32
This library is compatible with the ESP32 UWB DW3000 PCB (WROOM version tested) chip made by makerfabs. The project was primarely focused on giving an alternative to the official makerfabs library that is easy to understand and adapt.
For the currently existing examples you will need two ESP32 UWB DW3000 PCBs.
The DWM3000EVB chip is NOT compatible with this library if paired with an Arduino Uno! This is due to its limitation in cpu speed (16MHz, compared to the ESP32 with a 240MHz cpu speed).
Just download the zip, extract it in your Arduino's "library" folder, restart your Arduino IDE and open the two examples under file > examples > DW3000 Arduino
.
Additionally, you'll have to install the ESP32 Add-on for Arduino IDE, following this manual.
Please refer to dw3000_doublesided_ranging_ping and dw3000_doublesided_ranging_pong to get the most reliable ranging results.
One chip sends a predefined message, the other chip receives the messages. Useful for checking for hardware faults as it is the easiest example.
The ping device sends a message to the pong device, which increments the message by 1 and sends the incremented message back to the ping device. The output on the ping device should be incremented by 2 per cycle.
The ping device sends a message to the pong device, which after a fixed delay sends a message back. By then comparing the send and receive timestamps on the ping device a distance between both devices can be estimated. This is a single-sided two-way-ranging system which due to its design isn't as accurate as a double-sided two-way-ranging system for example.
This is the recommended way to get more accurate ranging results.
This approach uses 3 ranging messages to evaluate the distance between both devices. This not only limits the influence of the clock offset between the chips but also averages the results between those 3 messages.
Be aware that all methods that are exclusively used in double-sided ranging have a "ds_" as a prefix.
This chapter describes the most important methods the library features.
Has to be called before anything else is done with the library. The method configures the SPI bus to communicate with the DW3000 chip.
Checks the connection towards the chip by reading known data from the chip and comparing it to what the data should look like. Soft resets the DW3000 chip and configures the chip.
Physically resets the DW3000 chip by pulling the reset line low. This is useful if the chip didn't get disconnected from power to ensure that no registers are still set.
Configures the GPIO pins on the DW3000 chip. These pins can be used to light some status LEDs.
Lights a LED. 0-2 are valid values and control a different LED each.
Shuts off a LED. 0-2 are valid values and control a different LED each.
Uses all the given parameters to calculate the distance between the chips after doing a double-sided ranging. Returns a time value that is in DW3000 custom units of ~15.65ps per unit.
Should be processed by convertToCM() to get a usable result.
Checks if the Arduino can establish a connection to the DW3000 chip. Returns True if so, False if not.