Node to Node LoRa communication using Nano 33 BLE Sense

What is LoRa?

LoRa, short for long-range, is the physical layer or the wireless modulation utilized to create a long-range communication link. LoRa is based on Chirp Spread Spectrum (CSS) modulation, which maintains the same low power characteristics as FSK modulation but significantly increases the communication range.

Material Required is as follows:

  • 2x LoRa Bee modules
  • 2xNano 33 Ble Sense
  • 1x Breadboard
  • Jumper Wires

Circuit Diagram

Pin Details

LoRe BEE

LoRe BEE

physical pin

Nano 33 BLE Sense

MISO

  4

        D12(MISO)

RESET

 5

        D9

MOSI

11

        D11(MOSI)

D0  

 12

        D2

NSS

 17

        D10

SCK

 18

        D13(SCLK)

3V3

  1

         3V3

GND

 10

         GND

Now we are going to set up LoRa Node to Node communication using Nano 33 BLE Sense. In Node to Node communication, we use two nodes. One of the nodes we configure as Transmitter and another node as Receiver.

Step1: Adding Nano 33 BLE Sense in Arduino IDE

Go to Tools > Board > Boards Manager

Search for Nano 33 BLE Sense and Click on the install button

It should be installed after a few seconds.

Step2: Code and Library

Download the Zip file for Arduino-LoRa Library from the link given below

https://www.arduino.cc/reference/en/libraries/lora/

Installing library

In the Arduino IDE, navigate to Sketch > Include Library

At the top of the drop-down list, select the option to "Add. ZIP Library'' and then choose the zip file downloaded from the link given above.

Step 3: Sender Code

In the Arduino IDE, go to Tools > Board>Arduino mbed OS Board

Select Nano 33 BLE board

Select the correct COM port from Tools > Port

Enter the code given below and click on the Upload button in the Arduino IDE

                   #include <SPI.h>

#include <LoRa.h>

//define the pins used by the transceiver module

#define ss 5

#define rst 14

#define dio0 2

int counter = 0;

void setup() {

  //initialize Serial Monitor

  Serial.begin(115200);

  while (!Serial);

  Serial.println("LoRa Sender");

  //setup LoRa transceiver module

  LoRa.setPins(ss, rst, dio0);

  //replace the LoRa.begin(---E-) argument with your location's frequency

  //433E6 for Asia

  //866E6 for Europe

  //915E6 for North America

  while (!LoRa.begin(866E6)) {

    Serial.println(".");

    delay(500);

  }

  // Change sync word (0xF3) to match the receiver

  // The sync word assures you don't get LoRa messages from other LoRa transceivers

  // ranges from 0-0xFF

  LoRa.setSyncWord(0xF3);

  Serial.println("LoRa Initializing OK!");

}

void loop() {

  Serial.print("Sending packet: ");

  Serial.println(counter);

  //Send LoRa packet to the receiver

  LoRa.beginPacket();

  LoRa.print("hello ");

  LoRa.print(counter);

  LoRa.endPacket();

  counter++;

  delay(10000);

}

After uploading code open Arduino Serial monitor

d

Step 4: Receiver Code

               

In the Arduino IDE, go to Tools > Board>Arduino mbed OS Board

Select Nano 33 BLE board

Select the correct COM port from Tools > Port

Enter the code given below and click on the Upload button in the Arduino IDE

#include <SPI.h>

#include <LoRa.h>

//define the pins used by the transceiver module

#define ss 5

#define rst 14

#define dio0 2

void setup() {

  //initialize Serial Monitor

  Serial.begin(115200);

  while (!Serial);

  Serial.println("LoRa Receiver");

  //setup LoRa transceiver module

  LoRa.setPins(ss, rst, dio0);

 

  //replace the LoRa.begin(---E-) argument with your location's frequency

  //433E6 for Asia

  //866E6 for Europe

  //915E6 for North America

  while (!LoRa.begin(866E6)) {

    Serial.println(".");

    delay(500);

  }

   // Change sync word (0xF3) to match the receiver

  // The sync word assures you don't get LoRa messages from other LoRa transceivers

  // ranges from 0-0xFF

  LoRa.setSyncWord(0xF3);

  Serial.println("LoRa Initializing OK!");

}

void loop() {

  // try to parse packet

  int packetSize = LoRa.parsePacket();

  if (packetSize) {

    // received a packet

    Serial.print("Received packet '");

    // read packet

    while (LoRa.available()) {

      String LoRaData = LoRa.readString();

      Serial.print(LoRaData);

    }

    // print RSSI of packet

    Serial.print("' with RSSI ");

    Serial.println(LoRa.packetRssi());

  }

}

After uploading the code, open the Arduino Serial monitor

On the receiver node, you can see the received packet

Troubleshooting

After uploading code if you are not receiving any packet in the receiver node follow the points mentioned below

    1.Make sure both node sender and receiver are using the same

       frequency in the line given below:

while (!LoRa.begin(866E6))

  2.Ensure you have selected a baud rate of 115200 in the Serial monitor.

Leave a comment

Please note, comments must be approved before they are published