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