RAK3172 Not joining Network

Hello,

I am trying to connect my RAK3172 to TTN by OTAA. But the device join is failing with error “Wait for LoRaWAN join…+EVT:JOIN_FAILED_RX_TIMEOUT” or “Wait for LoRaWAN join…Restricted_Wait_3478478_ms”
image

Bin File Version: RUI_4.0.1_RAK3172_E
Board Version in Arduino: 4.1.0
image

My Code:

// Timers
static uint64_t last = 0;
static uint64_t elapsed;

// Frame Counter
uint32_t frame_counter;

// Max Frame Counter
uint32_t max_frame_counter = 264950;

// Frequency Band of LoRa Radio
#define OTAA_BAND (RAK_REGION_IN865)
// EUIs & Keys for LoRaWAN
#define OTAA_APPEUI \
  { 0xXX, 0xXX, 0x75, 0x1B, 0x1E, 0x4E, 0x4B, 0xF0 }
#define OTAA_DEVEUI \
  { 0x70, 0xB3, 0xXX, 0xXX, 0xD0, 0x06, 0x77, 0x9D }
#define OTAA_APPKEY \
  { 0x77, 0x33, 0x12, 0xC6, 0xXX, 0xXX, 0x37, 0xF6, 0x96, 0xEB, 0xXX, 0xXX, 0xBA, 0xD4, 0x8B, 0xD5 }

void setup() {
  /* Begin Serial Communication */
  Serial.begin(115200, RAK_AT_MODE);
  Serial.println("Initializing LoRa Node");

  /* LoRa initialization */
  // OTAA Device EUI MSB first
  uint8_t node_device_eui[8] = OTAA_DEVEUI;
  // OTAA Application EUI MSB first
  uint8_t node_app_eui[8] = OTAA_APPEUI;
  // OTAA Application Key MSB first
  uint8_t node_app_key[16] = OTAA_APPKEY;
  // Set Network mode to LoRaWAN
  if (api.lorawan.nwm.get() != 1) {
    Serial.printf("Set Node device work mode %s\r\n",
                  api.lorawan.nwm.set(1) ? "Success" : "Fail");
    api.system.reboot();
  }
  if (!api.lorawan.appeui.set(node_app_eui, 8)) {
    Serial.printf("LoRaWan OTAA - set application EUI is incorrect! \r\n");
    return;
  }
  if (!api.lorawan.appkey.set(node_app_key, 16)) {
    Serial.printf("LoRaWan OTAA - set application key is incorrect! \r\n");
    return;
  }
  if (!api.lorawan.deui.set(node_device_eui, 8)) {
    Serial.printf("LoRaWan OTAA - set device EUI is incorrect! \r\n");
    return;
  }
  if (!api.lorawan.band.set(OTAA_BAND)) {
    Serial.printf("LoRaWan OTAA - set band is incorrect! \r\n");
    return;
  }
  if (!api.lorawan.deviceClass.set(RAK_LORA_CLASS_A)) {
    Serial.printf("LoRaWan OTAA - set device class is incorrect! \r\n");
    return;
  }
  if (!api.lorawan.njm.set(RAK_LORA_OTAA))  // Set the network join mode to OTAA
  {
    Serial.printf("LoRaWan OTAA - set network join mode is incorrect! \r\n");
    return;
  }
  if (!api.lorawan.join())  // Join to Gateway
  {
    Serial.printf("LoRaWan OTAA - join fail! \r\n");
    return;
  }

  /** Wait for Join success */
  while (api.lorawan.njs.get() == 0) {
    Serial.print("Wait for LoRaWAN join...");
    api.lorawan.join();
    delay(10000);
  }

  if (!api.lorawan.adr.set(0)) {
    Serial.printf("LoRaWan OTAA - set adaptive data rate is incorrect! \r\n");
    return;
  }
  if (!api.lorawan.txp.set(1)) {
    Serial.printf("LoRaWan OTAA - set TX power is incorrect! \r\n");
    return;
  }
  if (!api.lorawan.dr.set(4)) {
    Serial.printf("LoRaWan OTAA - set data rate is incorrect! \r\n");
    return;
  }
  if (!api.lorawan.rety.set(1)) {
    Serial.printf("LoRaWan OTAA - set retry times is incorrect! \r\n");
    return;
  }
  if (!api.lorawan.cfm.set(1)) {
    Serial.printf("LoRaWan OTAA - set confirm mode is incorrect! \r\n");
    return;
  }

  /** Check LoRaWan Status*/
  Serial.println("Device Configuration");
  Serial.printf("Network working mode = %s\r\n", api.lorawan.nwm.get() ? "LoRaWan" : "P2P");
  Serial.printf("Packet is %s\r\n", api.lorawan.cfm.get() ? "CONFIRMED" : "UNCONFIRMED");  // Check Confirm status
  Serial.printf("Adaptive data rate is  %s\r\n", api.lorawan.adr.get() ? "Enable" : "Disable");
  Serial.printf("The transmit power is %d\r\n", api.lorawan.txp.get());
  Serial.printf("The data rate is %d\r\n", api.lorawan.dr.get());
  switch (api.lorawan.deviceClass.get()) {
    case 0:
      Serial.println("Device is in Class A");
      break;
    case 1:
      Serial.println("Device is in Class B");
      break;
    case 2:
      Serial.println("Device is in Class C");
      break;
  }
  Serial.printf("Duty cycle is %s\r\n", api.lorawan.dcs.get() ? "ON" : "OFF");  // Check Duty Cycle status
  uint8_t assigned_dev_addr[4] = { 0 };
  api.lorawan.daddr.get(assigned_dev_addr, 4);
  Serial.printf("Device Address is %02X%02X%02X%02X\r\n", assigned_dev_addr[0], assigned_dev_addr[1], assigned_dev_addr[2], assigned_dev_addr[3]);  // Check Device Address
  Serial.printf("Uplink period is %ums\r\n", SLEEP_PERIOD);
  api.lorawan.registerRecvCallback(recvCallback);
  api.lorawan.registerJoinCallback(joinCallback);
  api.lorawan.registerSendCallback(sendCallback);
}

void loop() {
  if ((elapsed = millis() - last) > SLEEP_PERIOD) {
    uplink_routine();
    last = millis();
  }
  stop();
  api.system.sleep.all(SLEEP_PERIOD);
}

void uplink_routine() {
// Custom Code
}

void recvCallback(SERVICE_LORA_RECEIVE_T *data) {
  if (data->BufferSize > 0) {
    Serial.println("Something received!");
    for (int i = 0; i < data->BufferSize; i++) {
      Serial.printf("%x", data->Buffer[i]);
    }
    Serial.print("\r\n");
  }
}

void joinCallback(int32_t status) {
  Serial.printf("Join status: %d\r\n", status);
}

void sendCallback(int32_t status) {
  if (status == 0) {
    Serial.println("Successfully sent");
  } else {
    Serial.println("Sending failed");
  }
}

Can anyone help me with this issue?

Welcome back to the forum @Steve1

(1) is your gateway seen as connected in TTN?
(2) is your node setup correct in TTN?
(3) do you see the join requests in TTN?

The error message +EVT:JOIN_FAILED_RX_TIMEOUT means that the device has sent an join request, but did not receive the join accept.

The error message Restricted_Wait_3478478_ms means that you have violated the duty cycle rules with too many failed join requests and the device is now following the duty cycle rules and will not retry to join for the reported time.

(1) is your gateway seen as connected in TTN?
A. Yes
(2) is your node setup correct in TTN?
A. Yes
(3) do you see the join requests in TTN?
A. Yes.

If you can share the logs from TTN it would be helpful.

Does TTN send the join accepts?

Do you see the join accepts on the gateway logs?

What are the RSSI and SNR levels of the join request?

How far are the device and the node from each other?

In all sides, TTN LNS, gateway and your RAK3172, the same value for:

  1. Same Region IN865?
  2. Same sub-band?
  3. LoRa IDs: DEVEUI, APPEUI and APPKEY?

Claudio