Skip to content
This repository has been archived by the owner on Jul 21, 2022. It is now read-only.

Commit

Permalink
add example for LORA
Browse files Browse the repository at this point in the history
  • Loading branch information
graydonli committed Jan 7, 2019
1 parent e85a1b0 commit 5fc4824
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
47 changes: 47 additions & 0 deletions Module/LORA/Arduino/LoRaReceiver/LoRaReceiver.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include <M5Stack.h>
#include <M5LoRa.h>


void setup() {

M5.begin();

// override the default CS, reset, and IRQ pins (optional)
LoRa.setPins(); // default set CS, reset, IRQ pin
Serial.println("LoRa Receiver");
M5.Lcd.println("LoRa Receiver");

// frequency in Hz (433E6, 866E6, 915E6)
if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
M5.Lcd.println("Starting LoRa failed!");
while (1);
}

// LoRa.setSyncWord(0x69);
Serial.println("LoRa init succeeded.");
M5.Lcd.println("LoRa init succeeded.");
}

void loop() {
// try to parse packet
int packetSize = LoRa.parsePacket();
if (packetSize) {
// received a packet
Serial.print("Received packet: \"");
M5.Lcd.print("Received packet: \"");

// read packet
while (LoRa.available()) {
char ch = (char)LoRa.read();
Serial.print(ch);
M5.Lcd.print(ch);
}

// print RSSI of packet
Serial.print("\" with RSSI ");
Serial.println(LoRa.packetRssi());
M5.Lcd.print("\" with RSSI ");
M5.Lcd.println(LoRa.packetRssi());
}
}
42 changes: 42 additions & 0 deletions Module/LORA/Arduino/LoRaSender/LoRaSender.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <M5Stack.h>
#include <M5LoRa.h>


void setup() {

M5.begin();

// override the default CS, reset, and IRQ pins (optional)
LoRa.setPins(); // default set CS, reset, IRQ pin
Serial.println("LoRa Sender");
M5.Lcd.println("LoRa Sender");

// frequency in Hz (433E6, 866E6, 915E6)
if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
M5.Lcd.println("Starting LoRa failed!");
while (1);
}

// LoRa.setSyncWord(0x69);
Serial.println("LoRa init succeeded.");
M5.Lcd.println("LoRa init succeeded.");
}

void loop() {
// try to parse packet
static uint32_t counter;

Serial.print("Sending packet: ");
Serial.println(counter);

// send packet
LoRa.beginPacket();
LoRa.print("hello ");
LoRa.print(counter);
LoRa.endPacket();

counter++;

delay(1000);
}
Binary file added Unit/CARDKB/firmware_328p/cardkb_sch_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5fc4824

Please sign in to comment.