Created
April 28, 2018 15:24
-
-
Save penpencool/79cc8fe2cd7eea5d6029a50c86475d44 to your computer and use it in GitHub Desktop.
ArduinoLoRa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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()); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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); | |
| } |
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
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.