arduino2/libraries/Heltec_ESP32_Dev-Boards/examples/LoRa/LoRaReceiverInterrupt/LoRaReceiverInterrupt.ino
2021-02-10 18:05:49 +01:00

48 lines
1.1 KiB
C++

/*
Uses interrup method check the new incoming messages, and print via serial
in 115200 baud rate.
The default interrupt pin in SX1276/8(DIO0) connected to ESP32's GPIO26
by Aaron.Lee from HelTec AutoMation, ChengDu, China
成都惠利特自动化科技有限公司
www.heltec.cn
this project also realess in GitHub:
https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series
*/
#include "heltec.h"
#define BAND 433E6 //you can set band here directly,e.g. 868E6,915E6
void setup() {
//WIFI Kit series V1 not support Vext control
Heltec.begin(true /*DisplayEnable Enable*/, true /*LoRa Disable*/, true /*Serial Enable*/, true /*PABOOST Enable*/, BAND /*long BAND*/);
// 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());
}