This part has a page of its own, with a note on using it and a circuit to try: the part page.
LoRa module, SX1278 (Ra-02)
The Ai-Thinker Ra-02: a Semtech SX1278 LoRa radio, 433 MHz, on SPI, with a spring
antenna. LoRa.h (Sandeep Mistry's library) or RadioLib.h drives it.
Aliases: LoRa, Ra-02, SX1278, SX1276, RFM95W, RFM96W, LoRa radio. The SX1276 (the 868 and 915 MHz RFM95W) is the same chip with the same registers, so this part is that one too.
Every LoRa module on the canvas shares the air
Put two modules down, wire each to its own board, and they hear each other, with no
wire between them. As for the nRF24L01, the air is the extra pin ANT: Mokxi joins
the ANT of every LoRa module on the canvas, and that line is the room. Two modules
that send at the same time spoil each other's packets.
A LoRa module and an nRF24L01 do not hear each other: they have airs of their own.
Pins
| Pin | What it does |
|---|---|
GND |
Ground. |
3.3V |
Supply, 1.8 to 3.7 V. Use the board's 3.3 V pin. |
RST |
Reset, active low. |
DIO0 |
Packet received, packet sent or channel scan done, as the sketch maps it. |
DIO1 |
Receive timeout. DIO2 to DIO5 stay low. |
NSS |
SPI chip select. |
SCK, MOSI, MISO |
SPI. |
ANT |
The air every LoRa module on the canvas shares. Leave it unwired. |
LoRa.h's default Uno wiring is NSS to 10, RST to 9 and DIO0 to 2, with SCK,
MOSI and MISO on 13, 11 and 12. LoRa.setPins(ss, reset, dio0) changes it.
What is modeled
The chip is a register file behind SPI, as Semtech's datasheet has it, and
RegVersion reads 0x12, so LoRa.begin() and RadioLib's begin() find it. In LoRa
mode the modes are the datasheet's: sleep, standby, transmit, receive continuous,
receive single (which gives up after SymbTimeout symbols) and channel activity
detection, with the FIFO, its base addresses and pointer, the IRQ flags and mask, and
DIO0 and DIO1.
Packets take as long as real ones. The bit rate is LoRa's, set by the spreading factor and the bandwidth, and the preamble goes first: a 20 byte packet takes about 60 ms at SF7 and 125 kHz, and well over a second at SF12. A sketch that sends faster than that finds the radio still busy.
A receiver takes a packet only when its frequency, sync word, spreading factor and
bandwidth match the sender's, as a real one does. The CRC goes with the packet when
it is on, and a spoiled packet raises PayloadCrcError.
What is not modeled
The radio itself: distance, walls, fading and output power. packetRssi() and
getRSSI() always report -45 dBm and packetSnr() 9.5 dB, a strong close signal,
because there is no distance in the simulator. The coding rate is stored but does not
change the time on air, and modules with different coding rates still hear each
other. Invert IQ and implicit header mode are stored and not modeled. The FSK modem is
not modeled: in FSK mode nothing is sent or heard. There is no LoRaWAN gateway or
network server, so LMIC and The Things Network sketches have nobody to join.
Common mistakes
5 V on 3.3V. The SX1278 is a 3.3 V chip.
Different settings on the two sides. LoRa.begin(433E6) on one board and
LoRa.begin(915E6) on the other, or a setSyncWord() on only one, and nothing
arrives.
Sending in a tight loop. At SF12 one packet is over a second on the air.