test-couverture.ino

Arduino MKR WAN 1310 · File : test-couverture.ino · Language : Arduino · Use case : Cartographier la couverture LoRaWAN en mobilité

Validating LoRaWAN coverage before deployment: this MKR WAN 1310 emits an id+counter frame every thirty seconds during a trip. Crossing the serial trace (transmit time) with server-side RSSI draws the reception map of the route.

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 powered by a power bank, joined LoRaWAN credentials, antenna, vehicle or walking route.

Wiring

Nothing to wire; note landmarks (junction, car park) to the minute for later georeferencing.

How it works

The incrementing counter counts losses server-side; the embedded battery voltage detects sag under radio load. Unconfirmed frames respect the duty cycle at close-range emission.

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 serial GPS for live georeferencing, or report the current DR to watch ADR follow the route.

test-couverture.ino

// Drive-test LoRaWAN : uplinks non confirmes + RSSI serveur ensuite.
// Emets une trame ID+compteur toutes les 30 s pendant le deplacement.
#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;
uint16_t compteur = 0;
unsigned long dernier = 0;

void setup() {
  Serial.begin(9600);
  lora.setDeviceEui(DEVICE_EUI);
  lora.setAppEui(APP_EUI);
  lora.setAppKey(APP_KEY);
  lora.setRegion(EU_863_870_R1);
  if (lora.join(OTAA, MODEL_TYPE_A, 30000, 8) == 0) while (true);
}

void loop() {
  lora.run();
  if (millis() - dernier < 30000) return;
  dernier = millis();
  uint8_t t[4];
  t[0] = 0x44; // marqueur "Drive-test"
  t[1] = compteur++;
  t[2] = analogRead(A1) >> 8; // tension batterie / 256
  t[3] = analogRead(A1) & 0xFF;
  lora.sendBuffer(t, 4, 7, 0);
  Serial.print(F("emis #"));
  Serial.println(t[1]); // horaire = trace serie + serveur croises
}

← Back to the board