Testing a Badgerboard with @thethingsntwrk The Things Network and @nasys_no Badgerboard

A Badgerboard is a small Arduino-compatible LoRaWAN development board with an integrated RN2483 module. From the looks of it, it is easily one of the best designed boards on the marked, It is also one of the smallest RN2483-based LoRaWAN boards I have seen (the smallest being the one from Thomas van Bellegem from The Netherlands) and with a list price of €51,- including shipping, it is by far the cheapest fully LoRaWAN certified development board in existence at the moment.

With all that good news, there is a flipside: the included Arduino sketches are a mess. It looks like the software was created as a by-product for the hardware, and none of the example programs make any sense. Sending values in JSON? Sending a float? No API to read on-board sensors? No automatic storage of App-EU? If an experienced Arduino programmer had spend a couple of days, these sketches would actually be helpful in understanding the workings of the board.

That said, this board connects to the LoRaWAN network (I’ve used The Things Network for this test) rock solid, checks it’s own inner workings and reboots if things fail, has a battery saving scheduler and is Arduino compatible. Things could be improved enormously, but as it stands, this is working territory.

Getting it connected

I’ve rewritten the included example programs to make some sense if you’ve worked with and programmed a TTN node before. Reach out to me if you need the TL;DR.

// Badgerboard demonstration sketch that connects to The Things Network
// every five minutes and sends a temperature value from the onboard temp sensor

#include 
badger_scheduler temp_sched(5 * 60 * 1000UL, 30 * 1000UL, PRINT_ENABLE); // Send every 5 minutes
uint32_t s_badger_sleep_period_ms = 32 * 1000UL; // Wake every 32 seconds

// devEUI comes from the Badgerboard, appKey and appEUI are provided by The Things Network
// The values below are fictional and need to be replaced with your own secret values
const uint8_t devEUI[8] = {0x70, 0xB3, 0xA3, 0xB0, 0x20, 0xF3, 0x5C, 0xE9};
const uint8_t appKey[16] = {0x1F, 0x9D, 0x75, 0xF8, 0x55, 0x6E, 0x9E, 0x80, 0xFF, 0xDA, 0x05, 0xD3, 0xD6, 0x7E, 0xC7, 0xBB};
const uint8_t appEUI[8] = {0x70, 0xB3, 0xA5, 0xB0, 0xF0, 0x00, 0x4D, 0xB5};

void setup() 
{
  Serial.begin(9600); // Set the terminal to 9600 bits per second, the default
  badger_init(); // Inits some variables and wakes up the temperature sensor
  Serial.println("Badgerboard firmware started."); // Send a message to the terminal, if connected
  badger_print_EUI(devEUI); // No idea what this does. Leave it here
  LoRa_init(devEUI, appEUI, appKey);  // Init the RN2483 module and provide the secrets for Over-The-Air activation
}

void loop()
{
  // This loop runs every s_badger_sleep_period_ms, 30 secs 
  if (temp_sched.run_now())
  {
     Serial.print("Sending temperature");
     badger_pulse_led(1); // Pulse Bager board once
     badger_blink_error(badger_temp_send()); // 4 bytes float, blink led on error  
  } else {
    Serial.print("Nothing to do. ");
  }
  if (Lora_requires_reset()) // Check if everything is connected to LoRaWAN
  {
    Serial.println("Restarting due to disconnected LoRa module");
    badger_restart();        
  }
  Serial.println("Sending Badgerboard to sleep.");
  badger_sleep_now(s_badger_sleep_period_ms);
  Serial.print("Woke up. ");
}

This sketch sends the temperature as float, which uses four bytes. Those four bytes aren’t that easily translated back to floats, so you need to decode them as soon as they are send to The Things Network, which is done in the ‘Decoder’ section of the application:

function Decoder(bytes, port) {
  // Decode an uplink message from a buffer
  // (array) of bytes to an object of fields.
  
  var decoded = {};
  
  function bytesToFloat(bytes) {
    var bits = bytes[3]<<24 | bytes[2]<<16 | bytes[1]<<8 | bytes[3]; var sign = (bits>>>31 == 0) ? 1.0 : -1.0;
    var e = bits>>>23 & 0xff;
    var m = (e == 0) ? (bits & 0x7fffff)<<1 : (bits & 0x7fffff) | 0x800000;
    var f = sign * m * Math.pow(2, e - 150);
    return f;
  }
  
  if (port == 1) {
     // Decode bytes to float and fix number of decimals to 3
    decoded.temperature = bytesToFloat(bytes.slice(0, 4).toFixed(3)); 
  }
  return decoded;  
}

Test results

I’ve used this board for a number of days, connected to my Mac, to a seperate USB charger and to a USB power bank with the same results: flawless connections. The board has an integrated LiPo-charger and JST connector for a LiPo battery, but those I have not used yet. The included antenna works just fine (I’ll do a boards and antenna comparison in the near future).

Conclusion

I didn’t know what to expect from this board, with the software in the state it is. However, after spending some time with the software, the board works just great. The Badgerboard connect flawlessly, sleep mode works as a dream and sensor values are transmitted reliably. This might just as well be the best node on the market at the moment, if you’re willing to take the time to get the software to work. Your milage may vary, though, depending on your LoRaWAN and Arduino experience. @nasys_no, you really should spend a couple of days finishing the software and documentation.

Apple event op dinsdag 12 september 19.00 (NL tijd)

Aan de uitnodiging vallen een aantal zaken op:

  • Gebruik van heldere tinten, in de kleuren blauw, rood en wit. Amerikaanse vlag? Productie van Apple producten of diensten vanuit de VS in plaats van China? Of viering van het 10-jarige bestaan van de iPhone?
  • Heldere kleuren, nieuwe beeldtechnologie? OLED?
  • Rechthoekige, afgeronden vormen met verhoudingen die lijken op een iPhone. Nieuw model iPhone? Ik zie er overigens drie (het rode vlak heeft rechtsonder een onverwachte afbuiging, hetgeen suggereert dat er twee iPhones op elkaar liggen, de bovenste kleiner dan de onderste).
  • In het nieuwe Steve Jobs Theater. Da’s mooi, een ruimte vernoemd naar de overleden baas van Apple. Zeker als bij introductie van de oorspronkelijke iPhone in 2007 wordt stilgestaan. Ik weet dat me dat in 2007 wel maanden heeft beziggehouden.

Het evenement is om 19.00 en normaliter is het live te volgen vanaf een Apple TV, iPad, iPhone of Mac. Apple heeft hiervoor deze placeholder gereserveerd. Uiteraard hebben de blogs ook de nodige berichtgeving:

Het gevalletje bedrijfsspionage waar Apple afgelopen week mee te maken heeft gekregen is toch een beetje alsof je stukken van het script van Jochem Meyjers nieuwe theatershow te zien krijgt. Gelukkig is de media overwegend terughoudend om al te veel ‘clues’ te lekken, zodat ik nog steeds uitkijk naar het live event. Ik ben ook erg benieuwd welk verhaal er achter de bedrijfsspionage vandaan komt. Niemand wordt er beter van, zeker de betreffende medewerker van Apple niet.