Device unable to join (and skipping new join attempts)

Hello World

Recently I’ve bought a Seeeduino for my bachelor thesis. To get started with it, I decided trying to make a few simple programs first. So as a first I tried a simple “Hello World”, which actually took quite some work to get my laptop to accept the Seeeduino as a device. (I had some extra unnecessary services running.) But which I eventually got to work.

Hello LoRaWAN

After this step, I wanted to try to actually connect it to TTN. So I followed this guide: https://blog.squix.org/2017/07/seeeduino-lora-gps-getting-started-with-lorawan-and-ttn.html. I’ve added some extra lines to have a bit more debug of what is going on at a given time. (I’ve added my code at the bottom of this thread.)

However, now that I am trying to connect my Seeeduino, it just attempts to join once and then skips to the loop, without even showing the debug of a reattempt. It also does not display that it either succeeded or failed to join a server, just that it attempts it once and then moves on to the loop. Afterwards it tries to send some packets, of which about one in seven actually gets received according to the device monitor. Unfortunately, this so called successfully received packet is never shown on the server.

My question

How do I get my device to join TTN so that I can actually see data traffic on the server interface and so that I can use the device for different purposes in the future?

Device monitor

This is what the device monitor shows during execution of this code.

Hello world!
+VER: 2.1.15
+ID: DevAddr, 26:01:14:D0
+ID: DevEui, 00:21:FD:31:A2:88:6D:7E
+ID: AppEui, 70:B3:D5:7E:D0:00:C1:9F
+ID: DevEui, 00:21:FD:31:A2:88:6D:7E
+ID: AppEui, 70:B3:D5:7E:+KEY: APPKEY AB08FD9C50A0FF81A642D7F915D4CE45
+MODE: LWOTAA
+DR: EU868
+DR: DR0
+DR: EU868 DR0  SF12 BW125K
+CH: 0,868100000,DR0:DR5
+CH: 1,868300000,DR0:DR5
+CH: 2,868500000,DR0:DR5
+RXWIN1: 0,868100000
+RXWIN2: 869500000,DR3
+LW: DC, ON, 0
+LW: JDC, ON
+POWER: 14
+JOIN: Start
+JOIN: NORMAL
Connected!
Still alive
+MSG: No band in 140211ms
Packet sent: 0
Still alive
+MSG: No band in 118183ms
Packet sent: 0
Still alive

After a while, this turns into:

+MSG: Please join network first
Packet sent: 0
Still alive

My code


#include <LoRaWan.h>


unsigned char data[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA,};
char buffer[256];


void setup(void)
{
    pinMode(LED_BUILTIN, OUTPUT);
    
    SerialUSB.begin(115200);
    while(!SerialUSB){
       digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
       delay(1000);                       // wait for a second
    }
    digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
    SerialUSB.println("Hello world!");
    
    lora.init();
    
    memset(buffer, 0, 256);
    lora.getVersion(buffer, 256, 1);
    SerialUSB.print(buffer); 
    
    memset(buffer, 0, 256);
    lora.getId(buffer, 256, 1);
    SerialUSB.print(buffer);
    
    // void setId(char *DevAddr, char *DevEUI, char *AppEUI);
    lora.setId(NULL, "0021FD31A2886D7E", "70B3D57ED000C19F");
    // setKey(char *NwkSKey, char *AppSKey, char *AppKey);
    lora.setKey(NULL, NULL, "AB08FD9C50A0FF81A642D7F915D4CE45");
    
    lora.setDeciveMode(LWOTAA);
    lora.setDataRate(DR0, EU868);
    
    lora.setChannel(0, 868.1);
    lora.setChannel(1, 868.3);
    lora.setChannel(2, 868.5);
    
    lora.setReceiceWindowFirst(0, 868.1);
    lora.setReceiceWindowSecond(869.5, DR3);
    
    lora.setDutyCycle(true);
    lora.setJoinDutyCycle(true);
    
    lora.setPower(20);
    
    while(!lora.setOTAAJoin(JOIN)){
        for(int i=0; i<=3; i++){
          digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
          delay(100);                       
          digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
          delay(100);
        }
        digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
        delay(1000);
        SerialUSB.println("Connecting...") ;                                 
    }
    SerialUSB.println("Connected!");
    
}

void loop(void)
{   
  SerialUSB.println("Still alive");
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
  
    bool result = false;
    
    result = lora.transferPacket("Hello World!", 10);
    //result = lora.transferPacket(data, 10, 10);
    SerialUSB.print("Packet sent: ");
    SerialUSB.println(result);
    delay(10000);
    
  /*  
    if(result)
    {
        short length;
        short rssi;
        
        memset(buffer, 0, 256);
        length = lora.receivePacket(buffer, 256, &rssi);
        
        if(length)
        {
            SerialUSB.print("Length is: ");
            SerialUSB.println(length);
            SerialUSB.print("RSSI is: ");
            SerialUSB.println(rssi);
            SerialUSB.print("Data is: ");
            for(unsigned char i = 0; i < length; i ++)
            {
                SerialUSB.print("0x");
                SerialUSB.print(buffer[i], HEX);
                SerialUSB.print(" ");
            }
            SerialUSB.println();
        }
    }
    */
}


when I read an opening like this I always ask myself ’ WHY ’ … :sunglasses:

is your firmware updated

did you use search here … I found this

A few things I notice.

  • It looks like the parameters for the second receive window are not valid. When using OTAA you need to use SF0, not SF3. And for the frequency (for both OTAA and ABP) you should use 869.525 MHz not 869.5.

  • For the initial datarate, please use DR5 to DR3, not DR0.

  • For LoRaWAN the first receive frequency is the same frequency used to send the join request. Why are you setting it to a fixed frequency?

Ah thanks for your advice. Because of it I have made some changes to my code (yet it is still not working).

  • I have changed the second receive window to: lora.setReceiceWindowSecond(869.525, DR0);
    I did not change it to SF0 because that does not seem to be a configuration option. (https://blog.dbrgn.ch/2017/6/23/lorawan-data-rates/)
  • Changed the initial datarate to DR3: lora.setDataRate(DR3, EU868);
  • I have removed the set of the first receive frequency: //lora.setReceiceWindowFirst(0, 868.1);
  • I’ve also set a time-out for the join (which is much longer than the default)
    while(!lora.setOTAAJoin(JOIN, 60)){
    This way I do get a +Join: Failed notification in system monitor (once) before it moves to the loop without connecting. (It does mention +Join: Done but nothing else, no retries or anything.) Then I get the message: +MSG: Please join network first.

Would you have another idea where the problem could come from and how I could solve it?

Sorry, I don’t own that hardware so apart from the suggestions I made I can’t help you.