UWB Feather

Getting started with the UWB Feather.
Note: Work on creating a new board variant, platoformio package and example documentation is still in progress. In the mean time it is possible to use the board with the following code snippets.

To get started, create a new platformio project with the target set to Adafruit M0 Feather. Use the pinout and example code below. To use the DWM1000 install the thotro/arduino-dw1000 library.

To put the board into programming mode, double press the reset button. The RGB LED will fade blue slowly if a connection is successful.

Changes to board variant

Some changes need to be made to the Adafruit M0 board variant

variant.h

Disable the RX/TX led at lines 81 & 82

// Disable the following
//#define PIN_LED_RXL          (25u)
//#define PIN_LED_TXL          (26u)

variant.cpp

Modify line 74 to make PB03 and analog input

{ PORTB,  3, PIO_ANALOG, PIN_ATTR_DIGITAL, ADC_Channel11, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },

Configuration.h

The following is the pin assignment

#ifndef CONFIGURATION_H
#define CONFIGURATION_H
#include <Arduino.h>

#define DW1000_RST      2
#define DW1000_IRQ      3
#define DW1000_CS       4

#define LED_RED         26
#define LED_GREEN       31
#define LED_BLUE        30

#define BATTERY_VOLT    25
#define BATTERY_CHARGE  27

#endif

Main.cpp

The following is example code use to test the module. It shows how to use the RGB LED, measure voltage and monitor charge status.

#include <Arduino.h>
#include "Configuration.h"

void pulse(int pin, int interval) {
  digitalWrite(pin, HIGH);
  delay(interval);
  digitalWrite(pin, LOW);
  delay(interval);
}

float calculateBattVoltage(int pin) {
  float measuredvbat = analogRead(pin);
  measuredvbat *= 2;    // we divided by 2, so multiply back
  measuredvbat *= 3.3;  // Multiply by 3.3V, our reference voltage
  measuredvbat /= 1024; // convert to voltage
  return measuredvbat;
}

void setup() {
  Serial.begin(9600);
  while(!Serial);

  Serial.println("Starting...");
  pinMode(LED_RED, OUTPUT);
  pinMode(LED_GREEN, OUTPUT);
  pinMode(LED_BLUE, OUTPUT);
  //pinMode(BATTERY_VOLT, INPUT);
  pinMode(BATTERY_CHARGE, INPUT);

  Serial.println("Testing RGB LED...");
  Serial.println("RED");
  pulse(LED_RED, 1000);

  Serial.println("GREEN");
  pulse(LED_GREEN, 1000);

  Serial.println("BLUE");
  pulse(LED_BLUE, 1000);

  Serial.println("Testing battery...");
  Serial.println("Running battery test for 20 seconds");
  long millisNow = millis();
  while(millis() < millisNow + 20000) {
    Serial.print("VBat: "); Serial.println(calculateBattVoltage(BATTERY_VOLT));
    Serial.print("Charge: "); Serial.println(!digitalRead(BATTERY_CHARGE));
    
    delay(500);
  }

  Serial.println("Need to test DWM1000 module");
  Serial.println("Testing complete");
  
}

void loop() {
  // put your main code here, to run repeatedly:
}

Using the DWM1000

Create a new DW1000Ranging instance using the pin definitions from configuration.h

DW1000Ranging.initCommunication(PIN_RST, PIN_SS, PIN_IRQ);

TODO

Work that needs to be completed:
– Create PlatformIO board and Arduino varient
– Create library for easy of use (i.e. charge status interrupt, LED control and pin assignments)
– Include instructions for updating bootloader
– Update GitHub repositories to reflect changes

Questions?

For any help with getting started contact hi@prototypingcorner.io