You've already forked arduino-LoRa
mirror of
https://github.com/sandeepmistry/arduino-LoRa.git
synced 2025-06-12 19:41:53 +03:00
Some tweaks to new examples
This commit is contained in:
@ -6,13 +6,13 @@
|
||||
|
||||
Spreading factor affects how far apart the radio's transmissions
|
||||
are, across the available bandwidth. Radios with different spreading
|
||||
factors will not receive each other's transmissions. This is one way you
|
||||
factors will not receive each other's transmissions. This is one way you
|
||||
can filter out radios you want to ignore, without making an addressing scheme.
|
||||
|
||||
Spreading factor affects reliability of transmission at high rates, however,
|
||||
so avoid a hugh spreading factor when you're sending continually.
|
||||
|
||||
See the Semtech datasheete, http://www.semtech.com/images/datasheet/sx1276.pdf
|
||||
|
||||
See the Semtech datasheet, http://www.semtech.com/images/datasheet/sx1276.pdf
|
||||
for more on Spreading Factor.
|
||||
|
||||
created 28 April 2017
|
||||
@ -20,6 +20,7 @@
|
||||
*/
|
||||
#include <SPI.h> // include libraries
|
||||
#include <LoRa.h>
|
||||
|
||||
const int csPin = 7; // LoRa radio chip select
|
||||
const int resetPin = 6; // LoRa radio reset
|
||||
const int irqPin = 1; // change for your board; must be a hardware interrupt pin
|
||||
@ -29,16 +30,20 @@ int interval = 2000; // interval between sends
|
||||
long lastSendTime = 0; // time of last packet send
|
||||
|
||||
void setup() {
|
||||
while (!Serial);
|
||||
Serial.begin(9600); // initialize serial
|
||||
Serial.println("LoRa Duplex");
|
||||
LoRa.setPins(csPin, resetPin, irqPin);// set CS, reset, IRQ pin
|
||||
while (!Serial);
|
||||
|
||||
if (!LoRa.begin(915E6)) { // initialize ratio at 915Mhz
|
||||
Serial.println("LoRa Duplex - Set spreading factor");
|
||||
|
||||
// override the default CS, reset, and IRQ pins (optional)
|
||||
LoRa.setPins(csPin, resetPin, irqPin); // set CS, reset, IRQ pin
|
||||
|
||||
if (!LoRa.begin(915E6)) { // initialize ratio at 915 MHz
|
||||
Serial.println("LoRa init failed. Check your connections.");
|
||||
while (true); // if failed, do nothing
|
||||
}
|
||||
LoRa.setSpreadingFactor(8); // ranges from 6-12,default 7 see API docs
|
||||
|
||||
LoRa.setSpreadingFactor(8); // ranges from 6-12,default 7 see API docs
|
||||
Serial.println("LoRa init succeeded.");
|
||||
}
|
||||
|
||||
@ -64,18 +69,19 @@ void sendMessage(String outgoing) {
|
||||
msgCount++; // increment message ID
|
||||
}
|
||||
|
||||
|
||||
void onReceive(int packetSize) {
|
||||
if (packetSize == 0) return; // if there's no packet, return
|
||||
|
||||
// read packet header bytes:
|
||||
String incoming = "";
|
||||
|
||||
while (LoRa.available()) {
|
||||
incoming += (char)LoRa.read();
|
||||
}
|
||||
Serial.println("Message:" + incoming);
|
||||
Serial.println("RSSI:" + String(LoRa.packetRssi()));
|
||||
Serial.println("Snr:" + String(LoRa.packetSnr()));
|
||||
|
||||
Serial.println("Message: " + incoming);
|
||||
Serial.println("RSSI: " + String(LoRa.packetRssi()));
|
||||
Serial.println("Snr: " + String(LoRa.packetSnr()));
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user