scan-canaux.ino
Before picking your LoRa channel, measure the environment: this program sweeps nine EU868 channels and publishes each one's mean and minimum RSSI. A noisy channel (neighbouring gateways, interference) shows up instantly as a raised RSSI floor.
Hardware
An Arduino MKR WAN 1300 (SAMD21 microcontroller, Semtech SX1272 LoRa modem for point-to-point links, no built-in LoRaWAN stack, 868/915 MHz antenna). A single MKR WAN 1300 is enough; the fitted antenna picks up surrounding radio activity.
Wiring
No wiring; move around or run the scan for 24 h to cover neighbouring transmitters' activity cycles.
How it works
readRssi() returns the noise level measured by the SX1272 on the current channel. Sampling 20 times per channel yields a stable statistic; the CSV imports straight into a spreadsheet.
Running it
Install Arduino SAMD Boards and the MKRWAN library, select the board, upload. You need TWO LoRa boards (two MKR WAN 1300s, or a 1300 and a 1310) to see exchanges; set the same frequency plan in the code.
Variants
Add an hourly histogram to see occupancy peaks, or trigger automatic channel switching when mean RSSI crosses a threshold.
scan-canaux.ino
// Analyseur de spectre approximatif : RSSI moyen par canal EU868.
// Roll-call des canaux 868.0 a 869.5 MHz par pas de 200 kHz.
#include <MKRWAN.h>
LoRaModem modem;
const float FREQS[] = {868.0, 868.1, 868.3, 868.5, 868.7, 868.9, 869.1, 869.3, 869.5};
const int N = 9;
const int MESA = 20; // mesures par canal
void setup() {
Serial.begin(115200);
while (!Serial);
if (!modem.begin(EU868)) while (true);
modem.setSpreadingFactor(7);
Serial.println(F("freq_mhz;rssi_moyen;rssi_min"));
}
void loop() {
for (int c = 0; c < N; c++) {
modem.setFrequency(FREQS[c]);
long somme = 0;
int minirssi = 0;
for (int m = 0; m < MESA; m++) {
delay(20);
int r = modem.readRssi();
somme += r;
if (m == 0 || r < minirssi) minirssi = r;
}
Serial.print(FREQS[c], 1);
Serial.print(';');
Serial.print((float)somme / MESA, 1);
Serial.print(';');
Serial.println(minirssi);
}
Serial.println(F("---"));
delay(10000); // rafraichissement toutes les 10 s
}