You have a sensor in a field 3 km away, a water tank on a rooftop, or a meter somewhere with no Wi-Fi, and you want its reading at home. Wi-Fi won't reach, Bluetooth is shorter still, and a mobile SIM means a monthly bill. This is where LoRa comes in: a radio that sends small amounts of data over kilometres, and can run for months or years on a battery.
What exactly does LoRa do?
LoRa (short for Long Range) is a radio modulation that lets a signal be heard even when it's weaker than the noise. That gives very long range at low power.
The trade-off is that it's very slow: from about 0.3 to 37 kbps. You send numbers (temperature, humidity, water level, door state), not pictures or sound.
| Wi-Fi | Bluetooth | LoRa | |
|---|---|---|---|
| Range | Tens of metres | Metres to tens | 2–15 km or more |
| Speed | Very high | Medium | Very slow |
| Power use | High | Low | Very low |
| Used for | Internet and video | Headphones and phones | Remote sensors |
Range varies hugely with the terrain: in open land with the antenna high up it can reach 10 km or more, while inside a city among buildings it drops to 1–3 km.
LoRa or LoRaWAN?
- LoRa: the radio itself. Two modules talk directly (point to point). This is where we start, and it needs no subscription.
- LoRaWAN: a network protocol on top of LoRa. Devices send to a gateway, which connects to the internet and a server. Suitable when you have many devices.
Frequencies
LoRa runs on licence-free bands, but they differ by country: 433 MHz, 868 MHz (Europe and many regions) and 915 MHz (the Americas). Buy modules for the band allowed where you are, and make sure both ends use the same frequency.
Popular modules
- SX1276 / SX1278 (such as RFM95 and Ra-02): the most common and cheapest, with plenty of libraries.
- SX1262 (such as E22 modules and some ready-made ESP32 boards): newer, with lower power and better range.
- ESP32 boards with LoRa built in: an ESP32, a LoRa module and sometimes an OLED display. The easiest way to start.
Wiring to an ESP32
The module talks to the ESP32 over SPI (read UART, I2C and SPI):
| Module | ESP32 |
|---|---|
| VCC | 3.3V (not 5V!) |
| GND | GND |
| SCK | GPIO18 |
| MISO | GPIO19 |
| MOSI | GPIO23 |
| NSS / CS | GPIO5 |
| RST | GPIO14 |
| DIO0 / IRQ | GPIO2 |
Important warning: never transmit without an antenna. The power with nowhere to go reflects back into the chip and can damage it.
A simple transmitter
Using Sandeep Mistry's LoRa library (from the Library Manager):
#include <SPI.h>
#include <LoRa.h>
void setup() {
Serial.begin(115200);
LoRa.setPins(5, 14, 2); // CS, RST, DIO0
if (!LoRa.begin(868E6)) { // frequency: same as the receiver
Serial.println("LoRa not working");
while (true);
}
LoRa.setSpreadingFactor(9); // higher = more range, less speed
}
void loop() {
float temp = 25.4; // your sensor reading here
LoRa.beginPacket();
LoRa.print("T=");
LoRa.print(temp);
LoRa.endPacket();
delay(60000); // once a minute
}
The receiver uses LoRa.parsePacket() and reads the characters, along with LoRa.packetRssi(), which tells you the signal strength.
Spreading factor: range against speed
The spreading factor (SF) runs from 7 to 12:
- SF7: faster, shorter messages, less range.
- SF12: much slower, a single message can take over a second, but more range.
Start with SF9 and adjust for the distance. Both ends must use the same settings (frequency, SF and bandwidth).
The antenna: half the range
Most range problems come down to the antenna:
- A quarter-wave antenna for 868 MHz is about 8.2 cm of straight wire. Work out the length for any frequency with the antenna length calculator.
- Keep it vertical, with both ends oriented the same way.
- Height matters more than power: an antenna on the roof makes a huge difference compared with one inside a flat.
- Keep it away from metal and steel boxes. If the enclosure is metal, bring the antenna outside on a cable.
The battery
A sensor with an ESP32 and LoRa that sends every 10 minutes and sleeps the rest of the time can last months on an 18650 cell. The secret is deep sleep for the ESP32 and sleep for the module between transmissions. Read deep sleep on the ESP32.
Project ideas
- Soil moisture in a field, and switching irrigation.
- Water level in a rooftop tank.
- Gate status or a remote storeroom door.
- Tracking a vehicle or livestock in open land (with GPS).
If the distance is short (inside a home or building) and you don't want a router, see ESP-NOW. And if you need a complete LoRa project with a board design and enclosure, see our hardware design service.
FAQ
Does LoRa need internet? No. The two modules talk directly by radio. You only need internet if you want the data on your phone from anywhere, and that goes through the receiver.
Can I send a picture over LoRa? In practice no. The speed is so low that a small picture could take minutes. LoRa is for numbers and states.
How do I know the signal is good? From the RSSI (closer to zero is better; -120 is very weak) and the SNR. Move away step by step and record them.