Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //modified lora library by Sandeep Mistry for TTGO T-BEAM LORA ESP32 GPS
- // lora receiverCallBack modified by HwThinker
- #include <SPI.h>
- #include <LoRa.h>
- #define SCK 5 // GPIO5 -- lora SCK
- #define MISO 19 // GPIO19 -- lora MISO
- #define MOSI 27 // GPIO27 -- lora MOSI
- #define SS 18 // GPIO18 -- lora CS
- #define RST 23 // GPIO23 -- RESET
- #define DI0 26 // GPIO26 -- IRQ(Interrupt Request)
- #define BAND 915E6 // 915MHz modifikasi Frekuensi Band lora sesuai dengan Lora anda
- //#define BAND 433E6 //433MHz modifikasi Frekuensi Band lora sesuai dengan Lora anda
- void setup() {
- Serial.begin(9600);
- while (!Serial);
- SPI.begin(SCK, MISO, MOSI, SS);
- 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());
- }
Add Comment
Please, Sign In to add comment