Tapatalk

Getting started with LORA

Getting started with LORA

15

PostJun 18, 2018#1

Hi,

I just got a whisper node Lora and im trying to send a package withaut any sucess.
After some googling i tryed this sketch:

Code: Select all

#include <lmic.h>
#include <hal/hal.h>
#include <SPI.h>

// LoRaWAN NwkSKey, network session key
static const PROGMEM u1_t NWKSKEY[16] = {  };

// LoRaWAN AppSKey, application session key
static const u1_t PROGMEM APPSKEY[16] = {  };

// LoRaWAN end-device address (DevAddr)
static const u4_t DEVADDR = {  };

// These callbacks are only used in over-the-air activation, so they are
// left empty here (we cannot leave them out completely unless
// DISABLE_JOIN is set in config.h, otherwise the linker will complain).
void os_getArtEui (u1_t* buf) { }
void os_getDevEui (u1_t* buf) { }
void os_getDevKey (u1_t* buf) { }

static uint8_t mydata[] = "HI,Lora World!";
static osjob_t sendjob;

// Schedule data trasmission in every this many seconds (might become longer due to duty
// cycle limitations).
// we set 10 seconds interval
const unsigned TX_INTERVAL = 10;

// Pin mapping
const lmic_pinmap lmic_pins = {
  .nss = 10,
  .rxtx = LMIC_UNUSED_PIN,
  .rst = 7,
  .dio = {2, A2, LMIC_UNUSED_PIN},
};

void onEvent (ev_t ev) {
  Serial.print(os_getTime());
  Serial.print(": ");
  switch(ev) {
    case EV_TXCOMPLETE:
      Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
      // Schedule next transmission
      os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send);
      break;  
    default:
      Serial.println(F("Unknown event"));
      break;
  }
}

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 {
    // Prepare upstream data transmission at the next possible time.
    LMIC_setTxData2(1, mydata, sizeof(mydata)-1, 0);
    Serial.println(F("Packet queued"));
  }
  // Next TX is scheduled after TX_COMPLETE event.
}

void setup() {
  Serial.begin(115200);
  Serial.println(F("Starting"));

  // LMIC init
  os_init();

  // Reset the MAC state. Session and pending data transfers will be discarded.
  LMIC_reset();

  // Set static session parameters. Instead of dynamically establishing a session
  // by joining the network, precomputed session parameters are be provided.
  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);

  // Select frequencies range
  LMIC_selectSubBand(3);

  // Disable link check validation
  LMIC_setLinkCheckMode(0);

        // Disable ADR
        LMIC_setAdrMode(false);

  // TTN uses SF9 for its RX2 window.
  LMIC.dn2Dr = DR_SF9;

  // Set data rate and transmit power for uplink (note: txpow seems to be ignored by the library)
  LMIC_setDrTxpow(DR_SF7,14);

  // Start job
  do_send(&sendjob);
}

void loop() {
  os_runloop_once();
}
Got this output:

Code: Select all

Starting
RXMODE_RSSI
230: engineUpdate, opmode=0x808
259: Uplink data pending
298: Airtime available at 258 (channel duty limit)
464: Ready for uplink
1034: TXMODE, freq=920000000, len=27, SF=7, BW=125, CR=4/5, IH=0
Packet queued
5158: irq: dio: 0x0 flags: 0x8
5196: Scheduled job 0x285, cb 0x3f0 ASAP
5235: Running job 0x285, cb 0x3f0, deadline 0
5450: Scheduled job 0x285, cb 0x418 at 67555
67557: Running job 0x285, cb 0x418, deadline 67555
67683: RXMODE_SINGLE, freq=923300000, SF=7, BW=500, CR=4/5, IH=0
But in the Things Network Console got nothing.
Can anyone help me?

Thanks in advance

1885
1885

PostJun 20, 2018#2

Hi Bombix,

For any TTN related I would suggest getting into the TTN Forum. Any Arduino + RFM95 example should work very similar in the Whisper Node. Are you using a public gateway or your own? It's important to make sure you're in an area with coverage as well if using Public ones.

15

PostJun 21, 2018#3

Hi,

I got a public gateway a couple of meters from were i tested it.
Do i need to sorder any of the jumpers?
What ttn forum are you referring to?
Thanks in advance

PostJun 22, 2018#4

Hi,

Could you just tell me the pins that i should be using?

PostJun 25, 2018#5

Hi,

I used the lmic exampler ttn-abp and:
// Pin mapping
const lmic_pinmap lmic_pins = {
  .nss = 10,
  .rxtx = LMIC_UNUSED_PIN,
  .rst = 7,
  .dio = {2, A2, LMIC_UNUSED_PIN},
};
 But i could get info in my console.
Can you please help me?

Thanks in advance