diagnostic-join.ino
When LoRaWAN join fails, the causes are always the same: this diagnostic program states the checks, tries three long joins, then lists ranked hypotheses. A reflex to have before swapping boards.
Hardware
An Arduino MKR WAN 1310 (SAMD21 microcontroller, LoRa modem driven by an onboard ESP32 that also exposes Wi-Fi, LoRa antenna and Wi-Fi antenna). MKR WAN 1310, antenna definitely screwed on, access to the LoRaWAN server console.
Wiring
No wiring; first check the antenna is present — without it, everything fails silently.
How it works
The checks are stated in order, then the long timeout (60 s, 3 tries) covers the legal duty cycle that forces waits between channels.
Running it
Install Arduino SAMD Boards and the MKRWAN 2.x library (MKRWAN1310), select the board, upload. The 1310 is driven through AT commands over its internal ESP32; for LoRa, plan a second LoRa board on the other end.
Variants
Add a channel-sweep test, or compare with a second sister board to rule out hardware failure.
diagnostic-join.ino
// Diagnostic d'echec de join sur MKR WAN 1310 : etapes + indices.
#include <MKRWiSOLAR.h>
const uint8_t DEVICE_EUI[] = {0xDE,0xAD,0xBE,0xEF,0xFE,0xED,0xC0,0xFF};
const uint8_t APP_EUI[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const uint8_t APP_KEY[16] = {0}; // a provisionner
LoRaWAN lora;
void setup() {
Serial.begin(9600);
Serial.println(F("1. Verifier les EUI saisis (inversion d'octets ?)"));
Serial.println(F("2. Region EU868 + duty cycle 1 % : etre patient"));
lora.setDeviceEui(DEVICE_EUI);
lora.setAppEui(APP_EUI);
lora.setAppKey(APP_KEY);
lora.setRegion(EU_863_870_R1);
Serial.println(F("3. Join avec 3 tentatives longues..."));
int ok = lora.join(OTAA, MODEL_TYPE_A, 60000, 3);
if (ok) { Serial.println(F("OK - le reseau repond")); return; }
Serial.println(F("ECHEC. Causes frequentes :"));
Serial.println(F(" - passerelle hors ligne / hors portee"));
Serial.println(F(" - AppKey differente du serveur (recopie !)"));
Serial.println(F(" - device pas activee / antenne debranchee"));
while (true);
}
void loop() {}