I’ve gone a day and a half at this one so far. I managed to make things work with light sleep, but not deep sleep. What i am trying to do is to put the ESP32 into deep sleep mode and have it wake on GPIO26 (LoRa rx,tx complete). First i’ll share the code that is working (with light sleep):
#include "Arduino.h"
#include "heltec.h"
#define BAND 915E6 //you can set band here directly,e.g. 868E6,915E6
String packSize = "--";
String packet;
void cbk(int packetSize) {
packet = "";
packSize = String(packetSize,DEC);
for (int i = 0; i < packetSize; i++) {
packet += (char) LoRa.read();
}
Serial.println(packet);
}
void setup() {
Heltec.begin(false /*DisplayEnable Enable*/, true /*Heltec.Heltec.Heltec.LoRa Disable*/, true /*Serial Enable*/, true /*PABOOST Enable*/, BAND /*long BAND*/);
LoRa.receive();
delay(10);
gpio_wakeup_enable(GPIO_NUM_26, GPIO_INTR_HIGH_LEVEL);
esp_sleep_enable_gpio_wakeup();
}
void loop() {
esp_light_sleep_start();
Serial.println("Incoming Message");
int packetSize = LoRa.parsePacket();
if (packetSize) {
cbk(packetSize);
}
LoRa.receive(); // Evidently the LoRa radio has to be put back into continuous recieve mode \
after waking up the ESP32 from sleep, otherwise it will not raise DIO0 to \
which indicates RX is done (new message has arived).
}
And here is my attempt (failed) with deep sleep:
#include "Arduino.h"
#include "heltec.h"
#define BAND 915E6 //you can set band here directly,e.g. 868E6,915E6
String packSize = "--";
String packet;
void cbk(int packetSize) {
packet ="";
packSize = String(packetSize,DEC);
for (int i = 0; i < packetSize; i++) {
packet += (char) LoRa.read();
}
Serial.println(packet);
}
void setup() {
Heltec.begin(false /*DisplayEnable Enable*/, true /*Heltec.Heltec.Heltec.LoRa Disable*/, true /*Serial Enable*/, true /*PABOOST Enable*/, BAND /*long BAND*/);
LoRa.receive();
esp_sleep_enable_ext0_wakeup(GPIO_NUM_26, 1);
delay(10);
int packetSize = LoRa.parsePacket();
if (packetSize) {
cbk(packetSize);
Serial.println("Message Processed");
}
Serial.println("Starting deep sleep");
//rtc_gpio_hold_en(GPIO_NUM_26);
esp_deep_sleep_start();
}
void loop() {
}
The LoRa radio is not sending DIO0 high to indicate a new message is “in”, i am assuming it is leaving continuous receive mode but not sure how to keep this from happening.