LoRa technology & its working:
The basic principle is that information is encoded using chirp (a gradual increase or decrease in the frequency of the carrier wave over time). Before sending a message, the LoRa transmitter will send out a chirp signal to check that the band is free to send the message. Once the LoRa receiver has picked up the preamble chirp from the transmitter, the end of the preamble is signalled by the reverse chirp, which tells the LoRa transmitter that is it clear to begin transmission.

The architecture:
It consists of LoRa Modulation, Transceivers & End-Nodes and Picocells & Gateways.

Semtech SX1278 Applications
1. Automated Meter Reading
2. Home and Building Automation
3. Wireless Alarm and Security Systems
4. Industrial Monitoring and Control
5. Long range Irrigation Systems

Semtech SX1278 Pinout
There are different versions and types of SX1278 breakout board available in market. But basically all of them has same pinout as LoRa SX1278 is an SPI module. I am using this board as shown in photos below.

Interfacing SX1278 LoRa Module with Arduino
The LoRa module that I am using here is the SX1278 Ra-02 which operates on 433MHz. But this module is not breadboarded friendly neither it has a soldered antenna. So simply I soldered few 2.54″ male connector to make it breadboard friendly. I also soldered the antenna.

Arduino LoRa SX1278 Transmitter
The circuit diagram for Arduino LoRa SX1278 Transmitter is given below. You can either make a pcb for this circuit or simply assemble it on the breadboard.

S.NO ARDUINO PIN  LoRa PIN
1 9 RESET
2 10 NSS
3 11 MOSI
4 12 MISO
5 13 SCK
6 A0 POT CENTRE POINT
7 GND GND
8 3.3V 3.3V
9 POT  5V

The LoRa SX1278 is not 5V friendly so do not supply 5V to it else the board will get damaged. Use 3.3V of Arduino to connect it to VCC pin. Connect all the GND pins to GND. Connect the RST pin to D9 and DIO0 to D2 of Arduino. Connect the SPI Pins NSS, MOSI, MISO, SCK to Arduino D10, D11, D12, D13 of Arduino respectively.
RECEIVER CODE:

#include <SPI.h>
#include <LoRa.h> 
int pot = A0;
 
void setup() 
{
  Serial.begin(9600);
  pinMode(pot,INPUT);
  while (!Serial);  
  Serial.println("LoRa Sender");
  if (!LoRa.begin(433E6)) 
{ 
// or 915E6, the MHz speed of yout module
    Serial.println("Starting LoRa failed!");
    while (1);
  }
}
 
void loop() 

{
  int val = map(analogRead(pot),0,1024,0,255);
  LoRa.beginPacket();  
  LoRa.print(val);
  LoRa.endPacket();
  delay(50); 
}

Use any potentiometer like 10K and connect its middle pin to A0 of Arduino and remaining two pins to GND and 5V.

Arduino LoRa SX1278 Receiver
Similarly the circuit diagram for Arduino LoRa SX1278 Receiver is given below. You can either make a pcb for this circuit or simply assemble it on the breadboard.

S.NO ARDUINO PIN  LoRa PIN
1 9 RESET
2 10 NSS
3 11 MOSI
4 12 MISO
5 13 SCK
6 3 OUTPUT LED
7 GND GND
8 3.3V 3.3V
9 2 DIO0

The LoRa SX1278 is not 5V friendly so do not supply 5V to it else the board will get damaged. Use 3.3V of Arduino to connect it to VCC pin. Connect all the GND pins to GND. Connect the RST pin to D9 and DIO0 to D2 of Arduino. Connect the SPI Pins NSS, MOSI, MISO, SCK to Arduino D10, D11, D12, D13 of Arduino respectively.
TRANSMITTER CODE:

#include <SPI.h>
#include <LoRa.h> 
int LED = 3;
String inString = ""; 
int val = 0;
 
void setup() 
{
  Serial.begin(9600);
  pinMode(LED,OUTPUT);
  
  while (!Serial);
  Serial.println("LoRa Receiver");
  if (!LoRa.begin(433E6))
 { // or 915E6
    Serial.println("Starting LoRa failed!");
    while (1);
  }
}
 
void loop() 
{
  int packetSize = LoRa.parsePacket();
  if (packetSize) 
{     
    while (LoRa.available())
    {
      int inChar = LoRa.read();
      inString += (char)inChar;
      val = inString.toInt();       
    }
    inString = "";     
    LoRa.packetRssi();    
  }
      
  Serial.println(val);  
  analogWrite(LED, val);
}

About the Author

Subramanian

Hello! My Dear Friends. I am Subramanian. I am writing posts on androiderode about Electronics testing and equipments.

View All Articles