DeepakTech PreviewBharat Pi
Published

Wireless Data Transmission with Bharat Pi LoRa Boards

Unlock the potential of long-range communication: Transmit and receive data effortlessly using Bharat Pi LoRa Boards

IntermediateFull instructions provided472
Wireless Data Transmission with Bharat Pi LoRa Boards

Things used in this project

Hardware components

Bharat Pi LoRa Module with ESP32, LoRa RFM95W 868MHZ lora Long range transreceiver module chip with ESP32 WROOM
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

LoRa Pinout

Code

Transmitter Code

Arduino
#include <SPI.h>
#include <LoRa.h>

//define the pins used by the transceiver module
#define ss 4
#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
  // 866 MHz to 867 MHZ is licensed in India
  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 receiver
  LoRa.beginPacket();
  LoRa.print("hello ");
  LoRa.print(counter);
  LoRa.endPacket();

  counter++;

  delay(1000);
}

Receiver Code

Arduino
#include <SPI.h>
#include <LoRa.h>

//define the pins used by the transceiver module
#define ss 4
#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)) {
  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());
  }
}

Credits

Deepak
5 projects • 1 follower
Contact
Tech Preview
5 projects • 0 followers
Contact
Bharat Pi
13 projects • 4 followers
IoT Prototyping platform for students, innovators, startups, OEMs and system integrators. Build any IoT use case using Bharat Pi boards!
Contact

Comments

Please log in or sign up to comment.