LoRa sends small messages over kilometres on a few milliamps — farm sensors, water-tank levels across a colony, or a gate alarm at the far end of a plot. The Ra-02 (SX1278, 433 MHz) is the common module in India.
It is a 3.3 V part with SPI pins that must not see 5 V, so on the Nano it needs a 3.3 V regulator and a 4-channel level shifter. The same sketch runs on both boards: one sends “hello n” every 5 seconds, the other prints each packet with signal strength.
Wiring
| Arduino Nano | SX1278 LoRa module (Ra-02, 433 MHz) | Wire | Notes |
|---|---|---|---|
| AMS1117 3.3 V module (IN from Nano 5V) · 3.3V | 3.3V | red | About 120 mA peaks while sending — too much for the Nano’s 3V3 pin. Module IN → Nano 5V, GND → Nano GND. |
| GND | GND | black | |
| D10 | NSS | purple | Via level shifter |
| D13 | SCK | yellow | Via level shifter |
| D11 | MOSI | green | Via level shifter |
| D12 | MISO | blue | 3.3 V output — the Nano reads it directly. |
| D9 | RST | orange | Via level shifter — Shifter LV = 3.3 V from the regulator, HV = Nano 5V. |
| D2 | DIO0 | cyan | Interrupt output from the module, 3.3 V — direct. |
3.3 V only (1.8–3.7 V) part, 5 V board. The SX1278 is a 3.3 V part and its pins are not 5 V tolerant. ESP32 and Pico connect directly. With an Uno or Nano, level-shift NSS, SCK, MOSI and RST, and power the module from a 3.3 V regulator that can supply about 120 mA while transmitting.
Board quirks
- The SX1278 is not 5 V tolerant. NSS, SCK, MOSI and RST from the Nano must go through a level shifter; outputs (MISO, DIO0) can go direct.
- BSS138 shifters are slow, so the sketch drops SPI to 1 MHz with
LoRa.setSPIFrequency(1E6). At the default 8 MHz,begin()often fails. - Never transmit without an antenna — it can damage the RF stage.
- 433.05–434.79 MHz is licence-free in India for low-power devices; the sketch sets 10 dBm. Check the current WPC rules before increasing power.
- Upload the same sketch to both Nanos, with
IS_SENDER = falseon the receiver. Both must use the same frequency and spreading factor.
Code
// SX1278 (Ra-02, 433 MHz) LoRa on an Arduino Nano — same sketch for sender and receiver.
// 3.3V ← 3.3 V regulator, GND → GND, NSS ← D10, SCK ← D13, MOSI ← D11, RST ← D9 (all four through
// a level shifter), MISO → D12 and DIO0 → D2 direct. Set IS_SENDER = false on the second Nano.
#include <SPI.h>
#include <LoRa.h>
const bool IS_SENDER = true;
const long FREQ = 433E6; // 433.05-434.79 MHz is the low-power licence-free band in India
void setup() {
Serial.begin(115200);
LoRa.setPins(10, 9, 2); // NSS, RST, DIO0
LoRa.setSPIFrequency(1E6); // BSS138 shifters are slow; 1 MHz is plenty for LoRa
if (!LoRa.begin(FREQ)) {
Serial.println(F("LoRa init failed - check 3.3V, shifter and NSS/RST wiring"));
for (;;) {}
}
LoRa.setTxPower(10); // 10 dBm = 10 mW
LoRa.setSpreadingFactor(9); // longer range than the default SF7, slower
Serial.println(IS_SENDER ? F("LoRa sender ready") : F("LoRa receiver ready"));
}
void loop() {
if (IS_SENDER) {
static unsigned int n = 0;
LoRa.beginPacket();
LoRa.print(F("hello "));
LoRa.print(n);
LoRa.endPacket();
Serial.print(F("Sent packet "));
Serial.println(n++);
delay(5000);
} else {
int size = LoRa.parsePacket();
if (size) {
Serial.print(F("Received '"));
while (LoRa.available()) Serial.print((char)LoRa.read());
Serial.print(F("' RSSI "));
Serial.print(LoRa.packetRssi());
Serial.print(F(" dBm SNR "));
Serial.println(LoRa.packetSnr(), 1);
}
}
}// SX1278 (Ra-02, 433 MHz) LoRa on an Arduino Nano — same sketch for sender and receiver.
// 3.3V ← 3.3 V regulator, GND → GND, NSS ← D10, SCK ← D13, MOSI ← D11, RST ← D9 (all four through
// a level shifter), MISO → D12 and DIO0 → D2 direct. Set IS_SENDER = false on the second Nano.
#include <SPI.h>
#include <LoRa.h>
const bool IS_SENDER = true;
const long FREQ = 433E6; // 433.05-434.79 MHz is the low-power licence-free band in India
void setup() {
Serial.begin(115200);
LoRa.setPins(10, 9, 2); // NSS, RST, DIO0
LoRa.setSPIFrequency(1E6); // BSS138 shifters are slow; 1 MHz is plenty for LoRa
if (!LoRa.begin(FREQ)) {
Serial.println(F("LoRa init failed - check 3.3V, shifter and NSS/RST wiring"));
for (;;) {}
}
LoRa.setTxPower(10); // 10 dBm = 10 mW
LoRa.setSpreadingFactor(9); // longer range than the default SF7, slower
Serial.println(IS_SENDER ? F("LoRa sender ready") : F("LoRa receiver ready"));
}
void loop() {
if (IS_SENDER) {
static unsigned int n = 0;
LoRa.beginPacket();
LoRa.print(F("hello "));
LoRa.print(n);
LoRa.endPacket();
Serial.print(F("Sent packet "));
Serial.println(n++);
delay(5000);
} else {
int size = LoRa.parsePacket();
if (size) {
Serial.print(F("Received '"));
while (LoRa.available()) Serial.print((char)LoRa.read());
Serial.print(F("' RSSI "));
Serial.print(LoRa.packetRssi());
Serial.print(F(" dBm SNR "));
Serial.println(LoRa.packetSnr(), 1);
}
}
}Library: LoRa (Sandeep Mistry) — compiled with LoRa 0.8.0.
Expected serial output
LoRa receiver ready
Received 'hello 0' RSSI -47 dBm SNR 9.8
Received 'hello 1' RSSI -48 dBm SNR 10.0LoRa receiver ready Received 'hello 0' RSSI -47 dBm SNR 9.8 Received 'hello 1' RSSI -48 dBm SNR 10.0
Common errors
LoRa init failed
No 3.3 V, NSS/RST on the wrong pins, or SPI too fast through the shifter. Check wiring and keep setSPIFrequency(1E6).
Sender works, receiver hears nothing
Different frequency or spreading factor, DIO0 not wired, or no antenna on one side.