Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //modified lora library by Sandeep Mistry for Lora32U4
- // lora receiverCallBack modified by hwthinker
- #include <SPI.h>
- #include <LoRa.h>
- #ifdef ARDUINO_SAMD_MKRWAN1300
- #error "This example is not compatible with the Arduino MKR WAN 1300 board!"
- #endif
- // GPIO5 -- SX1278's SCK
- // GPIO19 -- SX1278's MISO
- // GPIO27 -- SX1278's MOSI
- // GPIO18 -- SX1278's CS
- // GPIO14 -- SX1278's RESET
- // GPIO26 -- SX1278's IRQ(Interrupt Request)
- #define SS 8
- #define RST 4
- #define DI0 7
- #define BAND 433E6
- void setup() {
- Serial.begin(115200);
- //while (!Serial); disable for LORA32U4
- // SPI.begin(5,19,27,18);
- LoRa.setPins(SS,RST,DI0);
- Serial.println("LoRa Receiver Callback");
- if (!LoRa.begin(BAND)) {
- Serial.println("Starting LoRa failed!");
- while (1);
- }
- // register the receive callback
- LoRa.onReceive(onReceive);
- // put the radio into receive mode
- LoRa.receive();
- }
- void loop() {
- // do nothing
- }
- void onReceive(int packetSize) {
- // received a packet
- Serial.print("Received packet '");
- // read packet
- for (int i = 0; i < packetSize; i++) {
- Serial.print((char)LoRa.read());
- }
- // print RSSI of packet
- Serial.print("' with RSSI ");
- Serial.println(LoRa.packetRssi());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement