Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <LoRa.h>
- #include <Wire.h>
- #define SCK 5 // GPIO5 -- SX1278's SCK
- #define MISO 19 // GPIO19 -- SX1278's MISO
- #define MOSI 27 // GPIO27 -- SX1278's MOSI
- #define SS 18 // GPIO18 -- SX1278's CS
- #define RST 14 // GPIO14 -- SX1278's RESET
- #define DI0 26 // GPIO26 -- SX1278's IRQ(Interrupt Request)
- void setup() {
- Serial.begin(115200);
- while (!Serial);
- Serial.println("LoRa Receiver");
- SPI.begin(SCK,MISO,MOSI,SS);
- LoRa.setPins(SS,RST,DI0);
- if (!LoRa.begin(434.75E6)) {
- Serial.println("Starting LoRa failed!");
- while (1);
- }
- }
- void loop() {
- int packetSize = LoRa.parsePacket();
- if (packetSize) {
- Serial.print("Received packet '");
- while (LoRa.available()) {
- Serial.print((char)LoRa.read());
- }
- Serial.print("' with RSSI ");
- Serial.println(LoRa.packetRssi());
- }
- }
- `
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement