Long-range LoRa sensor link at 866 MHz
Build it step by step
0 of 5 doneFit the antennas first
Solder or screw an 868 MHz antenna to each RFM95W. Transmitting without one can damage the radio.
Wire both radios
3V3, GND, SCK 18, MISO 19, MOSI 23, NSS 5, RESET 14, DIO0 2.
Build the sender
BME280 on GPIO21/22. Upload with SENDER 1.
Build the receiver
OLED on GPIO21/22. Upload with SENDER 0.
Range test
Put the sender high up (a terrace) and walk or ride away with the receiver on a power bank, noting RSSI and where packets stop.
How do you build a long-range LoRa sensor link at 866 MHz?
One ESP32 sends BME280 readings over LoRa in India's 865 to 867 MHz band, and a second ESP32 shows them with signal strength on an OLED, often over a kilometre away. You need ESP32 DevKit V1 × 2, RFM95W LoRa module (868 MHz) × 2, 868 MHz LoRa antenna × 2, BME280 Environmental Sensor, SSD1306 OLED Display, USB A to micro-USB cable (data) × 2 and Jumper wires female to female (40 pcs). It takes 5 steps and about 150 minutes.
- Level
- Advanced
- Time
- About 150 min
- Parts
- 7
Wiring
| From | To | Why |
|---|---|---|
| RFM95W 3.3V / GND | ESP32 3V3 / GND | Radio power (both boards) |
| RFM95W SCK / MISO / MOSI | ESP32 GPIO18 / GPIO19 / GPIO23 | SPI |
| RFM95W NSS / RESET / DIO0 | ESP32 GPIO5 / GPIO14 / GPIO2 | Chip select, reset, packet interrupt |
| RFM95W ANT | 868 MHz antenna | Never transmit without an antenna |
| Sender: BME280 SDA / SCL | GPIO21 / GPIO22 | Sensor |
| Receiver: OLED SDA / SCL | GPIO21 / GPIO22 | Display |
Code
Arduino IDE with the ESP32 board package (Espressif), board "ESP32 Dev Module". Install "LoRa" by Sandeep Mistry, "Adafruit BME280" and "Adafruit SSD1306". 865 to 867 MHz is licence-exempt for low-power devices in India; keep to it.
Runs on a virtual ESP32 Dev Module in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#define SENDER 1 // 1 = sensor node, 0 = receiver with OLED
#include <SPI.h>
#include <LoRa.h>
#include <Wire.h>
void radio() {
LoRa.setPins(5, 14, 2); // NSS, RESET, DIO0
if (!LoRa.begin(866E6)) { Serial.println("LoRa not found"); while (true) delay(100); }
LoRa.setSpreadingFactor(9); // longer range than the default 7, slower
LoRa.setSignalBandwidth(125E3);
LoRa.setSyncWord(0x5A); // only talk to our own nodes
LoRa.enableCrc();
}
#if SENDER
#include <Adafruit_BME280.h>
Adafruit_BME280 bme;
int count = 0;
void setup() { Serial.begin(115200); bme.begin(0x76); radio(); }
void loop() {
String msg = String(count++) + "," + String(bme.readTemperature(), 1) + "," + String(bme.readHumidity(), 0) + "," + String(bme.readPressure() / 100, 0);
LoRa.beginPacket(); LoRa.print(msg); LoRa.endPacket();
Serial.println("Sent " + msg);
delay(15000);
}
#else
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
void setup() {
Serial.begin(115200); radio();
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C); oled.setTextColor(SSD1306_WHITE);
}
void loop() {
if (!LoRa.parsePacket()) return;
String msg; while (LoRa.available()) msg += (char)LoRa.read();
int rssi = LoRa.packetRssi(); float snr = LoRa.packetSnr();
Serial.printf("%s RSSI %d dBm SNR %.1f dB\n", msg.c_str(), rssi, snr);
int a = msg.indexOf(','), b = msg.indexOf(',', a + 1), c = msg.indexOf(',', b + 1);
oled.clearDisplay(); oled.setCursor(0, 0);
oled.printf("Packet #%s\n\n", msg.substring(0, a).c_str());
oled.printf("Temp %s C\nHum %s %%\nPress %s hPa\n\n", msg.substring(a + 1, b).c_str(), msg.substring(b + 1, c).c_str(), msg.substring(c + 1).c_str());
oled.printf("RSSI %d SNR %.1f", rssi, snr);
oled.display();
}
#endifTest checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Same room | Packets every 15 s, RSSI about −30 to −60 dBm, SNR above +8 dB |
| Packet number | Goes up by one each time; gaps mean lost packets |
| Edge of range | RSSI near −120 dBm and SNR below −10 dB before packets stop |
| Open line of sight with the sender on a roof | Often 1 to 3 km at SF9 |
If it does not work
"LoRa not found"
Check NSS, RESET and the SPI wires. The RFM95W is 3.3 V only.
Nothing received
Both sides must use the same frequency, spreading factor, bandwidth and sync word.
Short range
Raise the antennas, keep them vertical and away from metal, or try SF10 to SF12 (slower but longer).
Legal use
Stay in 865 to 867 MHz and send short packets with gaps, as here.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the long-range LoRa sensor link at 866 MHz?
ESP32 DevKit V1 × 2, RFM95W LoRa module (868 MHz) × 2, 868 MHz LoRa antenna × 2, BME280 Environmental Sensor, SSD1306 OLED Display, USB A to micro-USB cable (data) × 2 and Jumper wires female to female (40 pcs). RFM95W LoRa module (868 MHz) × 2: 868 MHz modules tune to 866 MHz.
How long does the long-range LoRa sensor link at 866 MHz take to build?
About 150 minutes for a advanced maker, in 5 steps.
How do I know the long-range LoRa sensor link at 866 MHz works?
Same room: Packets every 15 s, RSSI about −30 to −60 dBm, SNR above +8 dB. Packet number: Goes up by one each time; gaps mean lost packets. Edge of range: RSSI near −120 dBm and SNR below −10 dB before packets stop.
LoRa not found: what should I check?
Check NSS, RESET and the SPI wires. The RFM95W is 3.3 V only.
Nothing received: what should I check?
Both sides must use the same frequency, spreading factor, bandwidth and sync word.
Short range: what should I check?
Raise the antennas, keep them vertical and away from metal, or try SF10 to SF12 (slower but longer).
Legal use: what should I check?
Stay in 865 to 867 MHz and send short packets with gaps, as here.
