Tapatalk

Whisper Node LoRa TTN working example

Whisper Node LoRa TTN working example

3

PostDec 28, 2018#1

Hello,
can someone please point me to actually working example how to connect Wisen Whisper Node LoRa to TTN? (ABP or OTAA, I dont mind at the moment.)
I had minimal problem doing same with the Adafruit Feather 32u4 LoRa, but with Whisper Node I cannot find a single example.

Thanks in advance.

1

PostJan 26, 2019#2

Code: Select all

// Wisen LoraWan/TTN example
//
// FIRST: You need to close jumper JP15
// Sends faux temp to TTN via ABP in Cayenne LLP format every 16s
// (915/USA biased)
// See: https://github.com/matthijskooijman/arduino-lmic
// for more info and code comments
#include <lmic.h>
#include <hal/hal.h>
#include <SPI.h>
#include <LowPower.h>

// Get these from TTN
static const u4_t DEVADDR = 0x12345678; 
static const u1_t PROGMEM NWKSKEY[16] = { };
static const u1_t PROGMEM APPSKEY[16] = { };

const unsigned TX_INTERVAL = 16;  // seconds (multiples of 8)

void os_getArtEui (u1_t* buf) {}
void os_getDevEui (u1_t* buf) {}
void os_getDevKey (u1_t* buf) {}

static osjob_t sendjob;

byte TX_COMPLETE = 0;
byte TX_TIMEOUT = 0;
uint8_t payload[4];

// Pin mapping: these are hardware specific!
const lmic_pinmap lmic_pins = {
  .nss = 10,
  .rxtx = LMIC_UNUSED_PIN,
  .rst = LMIC_UNUSED_PIN,
  .dio = {2, A2, LMIC_UNUSED_PIN}, //DIO0 DIO1 DIO2
};

void do_send(osjob_t* j) { 
  // Check if there is not a current TX/RX job running
  if (LMIC.opmode & OP_TXRXPEND) {
    Serial.println(F("OP_TXRXPEND, not sending"));
  } else {

    // sending temp in celcius via Cayenne LLP format
    int16_t temp = 22.5 * 10;
    // Prepare upstream data transmission at the next possible time.
    payload[0] = 0x01; 
    payload[1] = 103;
    payload[2] = temp >> 8;
    payload[3] = temp;
    
    LMIC_setTxData2(1, (uint8_t*)payload, sizeof(payload), 0);
    Serial.println(F("Packet queued"));
  } 
}

// Next TX is scheduled after TX_COMPLETE event.
void onEvent (ev_t ev) {
  switch(ev) {
    case EV_TXCOMPLETE:
      Serial.println(F("EV_TXCOMPLETE"));
      
      if (LMIC.txrxFlags & TXRX_ACK)
        Serial.println(F("Received ack"));
        
      if (LMIC.dataLen) {
        Serial.println(F("Received "));
        Serial.println(LMIC.dataLen);
        Serial.println(F(" bytes of payload"));
      }
      TX_COMPLETE = 1;
      break;
    case EV_SCAN_TIMEOUT:
    case EV_LOST_TSYNC:
    case EV_RESET:
    case EV_RXCOMPLETE:
    case EV_LINK_DEAD:
    case EV_LINK_ALIVE:
      break;
    default:
      Serial.println(F("Unknown event"));
      break;
  }
}

void setup() {
  // See: https://github.com/matthijskooijman/arduino-lmic
  Serial.begin(115200);

  os_init();
  LMIC_reset();

  uint8_t appskey[sizeof(APPSKEY)];
  uint8_t nwkskey[sizeof(NWKSKEY)];
  memcpy_P(appskey, APPSKEY, sizeof(APPSKEY));
  memcpy_P(nwkskey, NWKSKEY, sizeof(NWKSKEY));
  LMIC_setSession (0x1, DEVADDR, nwkskey, appskey);

  LMIC_selectSubBand(0);
  LMIC_setLinkCheckMode(0);
  LMIC.dn2Dr = DR_SF9;
  LMIC_setDrTxpow(DR_SF7, 13);
}

void loop() {
  do_send(&sendjob);
  os_runloop_once();
  while(TX_COMPLETE != 1) {
    os_runloop_once();
    if (++TX_TIMEOUT > 60000) {
      Serial.println("Event Timeout\n");
      break;
    }
  }

  TX_COMPLETE = 0;  
  TX_TIMEOUT = 0;
  
  Serial.flush();

  for (int i = 0; i < TX_INTERVAL; i+=8) {
    //flash.sleep();
    //driver.sleep();
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);             
  }  
}

1885
1885

PostDec 08, 2019#3

Hello,

We have just published a blog showing how to connect the Whisper Node to the TTN using the TinyLoRa library: https://wisen.com.au/blog/whisper-node-and-ursalink-lorawan-gateway/

51

PostAug 02, 2021#4

Hello,

re: whisper-node and TTN v3

Confirming ABP works great as per blog post with v3.  Is there a library anyone can recommend that supports OTAA with the whisper-node?

Cheers