Skip to content

Instantly share code, notes, and snippets.

@penpencool
Created April 28, 2018 15:24
Show Gist options
  • Select an option

  • Save penpencool/79cc8fe2cd7eea5d6029a50c86475d44 to your computer and use it in GitHub Desktop.

Select an option

Save penpencool/79cc8fe2cd7eea5d6029a50c86475d44 to your computer and use it in GitHub Desktop.
ArduinoLoRa
#include <SPI.h>
#include <LoRa.h>
// Example By ArduinoAll
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("LoRa Receiver");
if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
}
void loop() {
// try to parse packet
int packetSize = LoRa.parsePacket();
if (packetSize) {
// received a packet
Serial.print("Received packet '");
// read packet
while (LoRa.available()) {
Serial.print((char)LoRa.read());
}
// print RSSI of packet
Serial.print("' with RSSI ");
Serial.println(LoRa.packetRssi());
}
}
#include <SPI.h>
#include <LoRa.h>
// Example By ArduinoAll
int counter = 0;
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("LoRa Sender");
if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
}
void loop() {
Serial.print("Sending packet: ");
Serial.println(counter);
// send packet
LoRa.beginPacket();
LoRa.print("hello ");
LoRa.print(counter);
LoRa.endPacket();
counter++;
delay(5000);
}
@ZachreyNM
Copy link

ZachreyNM commented Sep 25, 2024

I compiled and flashed LoRaReceiver.ino onto a TTGO LoRa32 v_1.6.1 board, "T3_V1.6.1" printed on the LoRa side of the board and I always get "Starting LoRa failed!" What do I do now? I know the board is good because I can put Meshtastic on it and everything is good.

@forstjiri
Copy link

Works great! I just changed default ports:
LoRa.setPins(33, 32, 35); // NSS, RST, DIO0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment