Hi All,
I purchased 4 UWB WROVER boards and 1 UWB DISPLAY PRO board. I'm using the 4 wrovers as anchors and the display as a tag.
I'm currently using this code: https://github.com/Makerfabs/Makerfabs- ... ag_display.
I want to send the range data of the proximity between the tag and the four anchors to the tag so I can track the (x,y,z) of the tag board. Does anyone know how I can do this?
Here is the algorithm I'm using to get the location of the tag in a 3d space:
x = sqr(r1) - sqr(r2) + c / 2 * c
y = sqr(r1) - sqr(r3) - sqr(x) + sqr(x - a)
(-z or z) = sqrt(sqr(r1) - sqr(x) - sqr(y))
determine if (-z or z) by whichever result is smaller
sqr(d-x) + sqr(e-y) + sqr(f-z)
sqr(d-x) + sqr(e-y) + sqr(f+z)
Just need to figure out how to send the range data from the anchor boards to the tag board so it can run this algorithm.
Thanks!
Lewis
sending range data from 4 anchors to the tag and printing in serial
-
- Posts: 1735
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: sending range data from 4 anchors to the tag and printing in serial
Thanks for the reply!
I copied and pasted the tag and anchor example codes, but so far they aren't working.
I'm currently getting this error message for the anchor code:
Any idea why this might be happening? I changed nothing in the example code. I'm running on an ESP32 Wrover Module.
Thanks!
I copied and pasted the tag and anchor example codes, but so far they aren't working.
I'm currently getting this error message for the anchor code:
Code: Select all
Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1).
Core 1 register dump:
PC : 0x4008c2ae PS : 0x00060735 A0 : 0x8008b226 A1 : 0x3ffbf19c
A2 : 0x3ffb7d84 A3 : 0x3ffbd364 A4 : 0x00000004 A5 : 0x00060723
A6 : 0x00060723 A7 : 0x00000001 A8 : 0x3ffbd364 A9 : 0x00000018
A10 : 0x3ffbd364 A11 : 0x00000018 A12 : 0x3ffc27d4 A13 : 0x00060723
A14 : 0x007bf348 A15 : 0x003fffff SAR : 0x0000001e EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x400855e1 LEND : 0x400855e9 LCOUNT : 0x00000026
Core 1 was running in ISR context:
EPC1 : 0x400e023b EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x00000000
Thanks!
Re: sending range data from 4 anchors to the tag and printing in serial
I found the line that was causing the error int the example anchor code:
// DW1000Ranging.initCommunication(PIN_RST, PIN_SS, PIN_IRQ);
What does this mean and how necessary is it?
As for the tag code, my board gets stuck in this loop and repeatedly prints "{"links":[]}"
void loop()
{
DW1000Ranging.loop();
if ((millis() - runtime) > 1000)
{
make_link_json(uwb_data, &all_json);
send_udp(&all_json);
runtime = millis();
Serial.println("hey");
}
}
// DW1000Ranging.initCommunication(PIN_RST, PIN_SS, PIN_IRQ);
Code: Select all
/*
For ESP32 UWB or ESP32 UWB Pro
*/
#include <SPI.h>
#include "DW1000Ranging.h"
#define ANCHOR_ADD "86:17:5B:D5:A9:9A:E2:9C"
#define SPI_SCK 18
#define SPI_MISO 19
#define SPI_MOSI 23
#define DW_CS 4
// connection pins
const uint8_t PIN_RST = 27; // reset pin
const uint8_t PIN_IRQ = 34; // irq pin
const uint8_t PIN_SS = 21; // spi select pin
void setup()
{
Serial.begin(115200);
delay(1000);
//init the configuration
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
[size=150]// DW1000Ranging.initCommunication(PIN_RST, PIN_SS, PIN_IRQ); [/size]//Reset, CS, IRQ pin
//define the sketch as anchor. It will be great to dynamically change the type of module
DW1000Ranging.attachNewRange(newRange);
DW1000Ranging.attachBlinkDevice(newBlink);
DW1000Ranging.attachInactiveDevice(inactiveDevice);
//Enable the filter to smooth the distance
//DW1000Ranging.useRangeFilter(true);
//we start the module as an anchor
// DW1000Ranging.startAsAnchor("82:17:5B:D5:A9:9A:E2:9C", DW1000.MODE_LONGDATA_RANGE_ACCURACY);
DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_LONGDATA_RANGE_LOWPOWER, false);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_SHORTDATA_FAST_LOWPOWER);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_LONGDATA_FAST_LOWPOWER);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_SHORTDATA_FAST_ACCURACY);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_LONGDATA_FAST_ACCURACY);
// DW1000Ranging.startAsAnchor(ANCHOR_ADD, DW1000.MODE_LONGDATA_RANGE_ACCURACY);
}
void loop()
{
DW1000Ranging.loop();
}
void newRange()
{
Serial.print("from: ");
Serial.print(DW1000Ranging.getDistantDevice()->getShortAddress(), HEX);
Serial.print("\t Range: ");
Serial.print(DW1000Ranging.getDistantDevice()->getRange());
Serial.print(" m");
Serial.print("\t RX power: ");
Serial.print(DW1000Ranging.getDistantDevice()->getRXPower());
Serial.println(" dBm");
}
void newBlink(DW1000Device *device)
{
Serial.print("blink; 1 device added ! -> ");
Serial.print(" short:");
Serial.println(device->getShortAddress(), HEX);
}
void inactiveDevice(DW1000Device *device)
{
Serial.print("delete inactive device: ");
Serial.println(device->getShortAddress(), HEX);
}
As for the tag code, my board gets stuck in this loop and repeatedly prints "{"links":[]}"
void loop()
{
DW1000Ranging.loop();
if ((millis() - runtime) > 1000)
{
make_link_json(uwb_data, &all_json);
send_udp(&all_json);
runtime = millis();
Serial.println("hey");
}
}
Code: Select all
/*
For ESP32 UWB or ESP32 UWB Pro
*/
#include <SPI.h>
#include <DW1000Ranging.h>
#include <WiFi.h>
#include "link.h"
#define SPI_SCK 18
#define SPI_MISO 19
#define SPI_MOSI 23
#define DW_CS 4
#define PIN_RST 27
#define PIN_IRQ 34
const char *ssid = "Mackelis9496";
const char *password = "doesmacdoo?";
const char *host = "192.168.0.106";
WiFiClient client;
struct MyLink *uwb_data;
int index_num = 0;
long runtime = 0;
String all_json = "";
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.setSleep(false);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("Connected");
Serial.print("IP Address:");
Serial.println(WiFi.localIP());
if (client.connect(host, 80))
{
Serial.println("Success");
client.print(String("GET /") + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n" +
"\r\n");
}
delay(1000);
//init the configuration
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
DW1000Ranging.initCommunication(PIN_RST, DW_CS, PIN_IRQ);
DW1000Ranging.attachNewRange(newRange);
DW1000Ranging.attachNewDevice(newDevice);
DW1000Ranging.attachInactiveDevice(inactiveDevice);
//we start the module as a tag
DW1000Ranging.startAsTag("7D:00:22:EA:82:60:3B:9C", DW1000.MODE_LONGDATA_RANGE_LOWPOWER);
uwb_data = init_link();
}
void loop()
{
DW1000Ranging.loop();
if ((millis() - runtime) > 1000)
{
make_link_json(uwb_data, &all_json);
send_udp(&all_json);
runtime = millis();
Serial.println("hey");
}
}
void newRange()
{
char c[30];
Serial.print("from: ");
Serial.print(DW1000Ranging.getDistantDevice()->getShortAddress(), HEX);
Serial.print("\t Range: ");
Serial.print(DW1000Ranging.getDistantDevice()->getRange());
Serial.print(" m");
Serial.print("\t RX power: ");
Serial.print(DW1000Ranging.getDistantDevice()->getRXPower());
Serial.println(" dBm");
fresh_link(uwb_data, DW1000Ranging.getDistantDevice()->getShortAddress(), DW1000Ranging.getDistantDevice()->getRange(), DW1000Ranging.getDistantDevice()->getRXPower());
}
void newDevice(DW1000Device *device)
{
Serial.print("ranging init; 1 device added ! -> ");
Serial.print(" short:");
Serial.println(device->getShortAddress(), HEX);
add_link(uwb_data, device->getShortAddress());
}
void inactiveDevice(DW1000Device *device)
{
Serial.print("delete inactive device: ");
Serial.println(device->getShortAddress(), HEX);
delete_link(uwb_data, device->getShortAddress());
}
void send_udp(String *msg_json)
{
if (client.connected())
{
client.print(*msg_json);
Serial.println("UDP send");
}
}
Who is online
Users browsing this forum: No registered users and 95 guests