PitRMF95W è arrivata l'ora di LoRA

L'utilizzo della trasmissione LoRA per l'IOT.

 

Le istruzioni principali per le connessioni il codice e le librerie da utilizzare si trovano sul libro di Pier Calderan e sul sito di Rui Santos

Immagini delle connessioni e dell'utilizzo in modalità point to point:

ozio_gallery_jgallery

Cosa serve:

  • 2 Sensori PitRMF95W
  • Arduino Uno
  • ESP32
  • cavetti

Codice sorgente Sender:


/*********
  Modified from the examples of the Arduino LoRa library
  More resources: https://randomnerdtutorials.com
  detail to: https://randomnerdtutorials.com/esp32-lora-rfm95-transceiver-arduino-ide/
*********/
#include "SPI.h"
#include "LoRa.h"
//define the pins used by the transceiver module
//per ESP32
#define ss 5
#define rst 14
#define dio0 2
//per Arduino
//#define ss 5
//#define rst 10
//#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 receiver
  LoRa.beginPacket();
  LoRa.print("hello ");
  LoRa.print(counter);
  LoRa.endPacket();
  counter++;
  delay(10000);
}

Codice sorgente Receiver:


/*********
  Modified from the examples of the Arduino LoRa library
  More resources: https://randomnerdtutorials.com
  detail to: https://randomnerdtutorials.com/esp32-lora-rfm95-transceiver-arduino-ide/
*********/
#include "SPI.h"
#include "LoRa.h"
//define the pins used by the transceiver module
//per ESP32
//#define ss 5
//#define rst 14
//#define dio0 2
//per Arduino
#define ss 5
#define rst 10
#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());
  }
}

 

Scarica tutto quello che serve: