LoRa receiver wakeup ESP32

Hi
I am using LoRa RFM 96 for both transmission and reception.
Both LoRa transceivers are working fine.
I am trying to wakeup ESP32 from deep sleep when LoRa receives data on pin DIO0.
Configured wakeup on High signal via:
esp_sleep_enable_ext0_wakeup(LORA_DIO0, 1);

Also before ESP deep sleep, I have init LoRa and put it in receive mode.

LoRa.onReceive(handleLoRaMsgCb);
LoRa.receive();

Some how i am not getting the esp32 out of deep sleep and no signal is detected on pin DIO0(GPIO 26)
I suspect before ESP go into deep sleep LoRa module is restarted and hence LoRa is not initialized(in receive mode anymore).
What's the possibility of it.
Any help/suggestion is greatly appreciated.

Regards,
mani

Distinct possibility.

Could be a problem with your code that you did not post.

When an ESP32 goes into deep sleep some of the GPIO pins 'glitch' and this can cause issues if this happens to the LoRa devices NRESET or DIO0 pins.

have you looked at DIO0 with an oscilloscope (or multimeter) to check the wakeup signal from the LoRa module occurs?

Hi Srnet,
I really wanted your expert opinion. Please suggest if any improvement or any mistakes in the code.
Here is my receiver code:

#include <SPI.h>
#include <LoRa.h>
#include <esp_sleep.h>
#include "driver/rtc_io.h"
//define the pins used by the transceiver module
//Lora Pins
#define LORA_SCK 18                 //lora SCK pin
#define LORA_MISO 19                //lora MISO pin
#define LORA_MOSI 23                //lora MOSI pin
#define LORA_CS 5                   //lora NSS pin
#define LORA_DIO0 GPIO_NUM_26       //lora DIO0 pin //wake-up enable GPIO pin
#define LORA_RST 27                 //lora RESET pin 

// Define frequency and sync word
#define LORA_FREQ 433E6 
#define LORA_SYNC_WORD 0xF3

void setup() {
  //initialize Serial Monitor
  Serial.begin(115200);
  pinMode(LORA_DIO0, INPUT_PULLDOWN);
  //pinMode(LORA_RST, OUTPUT | PULLUP);

  // Check if ESP32 woke up from DIO0 interrupt
  esp_sleep_wakeup_cause_t wakeup_cause = esp_sleep_get_wakeup_cause();
  switch (wakeup_cause) 
  {
    case ESP_SLEEP_WAKEUP_EXT0:     Serial.println("Wakeup caused by external signal using RTC_IO"); break;
    case ESP_SLEEP_WAKEUP_EXT1:     Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
    case ESP_SLEEP_WAKEUP_TIMER:    Serial.println("Wakeup caused by timer"); break;
    case ESP_SLEEP_WAKEUP_TOUCHPAD: Serial.println("Wakeup caused by touchpad"); break;
    case ESP_SLEEP_WAKEUP_ULP:      Serial.println("Wakeup caused by ULP program"); break;
    default:                        Serial.printf("Wakeup was not caused by deep sleep: %d\n", wakeup_cause); break;
  }

  if (wakeup_cause == ESP_SLEEP_WAKEUP_EXT0 || wakeup_cause == ESP_SLEEP_WAKEUP_EXT1)// || wakeup_cause == ESP_SLEEP_WAKEUP_GPIO) 
  {
    Serial.println("Woke up from LoRa message!");
    delay(100); // Allow some time for peripherals to stabilize
    initializeLoRa(); // Reinitialize LoRa after waking up
    handleLoRaMessage();
  } 
  else 
  {
    Serial.println("Normal boot...");
    initializeLoRa();
  }

  esp_sleep_enable_ext0_wakeup(LORA_DIO0, 1); // Wake on HIGH signal

  // Enter deep sleep
  Serial.println("Entering deep sleep...");
  Serial.flush();
  delay(2000); // Allow time for Serial logs to flush
  esp_deep_sleep_start();
  Serial.println("This will never be printed");
}
void loop() {
  // Will not reach here after deep sleep
  //handleLoRaMessage();
  //delay(100);
}


// Initialize LoRa module
void initializeLoRa() 
{
  while (!Serial);
  Serial.println("LoRa Receiver");
  
  //setup LoRa transceiver module
  LoRa.setPins(LORA_CS, LORA_RST, LORA_DIO0);
  
  while (!LoRa.begin(433E6)) 
  {
    Serial.println(".");
    delay(500);
  }
  LoRa.setSyncWord(0xF3);
  LoRa.receive(); // Put RFM96 in receive mode

  Serial.println("LoRa initialized and listening...");
}

// Handle LoRa message after waking up
void handleLoRaMessage()
{
  Serial.println("handleLoRaMessage: LoRa Message received after waking up");

  // try to parse packet
  String LoRaData = "";
  int packetSize = LoRa.parsePacket();
  if (packetSize) 
  {
    // received a packet
    Serial.print("Received packet: " + packetSize);
    // read packet
    while (LoRa.available()) 
    {
      LoRaData = LoRa.readString();
      Serial.println(LoRaData);
    }
  }
  else 
  {
    //Serial.println("No valid loRa packet received.");
  }
}

I have checked the DIO0 pin with LED attached to it and also with multimeter. Normally it blinks whenever it gets message from transmitter while esp32 sleep is disabled. But as soon as i enable esp deep sleep, it stops blinking (receiving messages)

testing with a RFM95 I find similar results
when receiving DIO0 looks like

when in deep sleep nothing

try light sleep?

what are you attempting to do?
are you attempting to deep sleep the transmitter and receiver?

There is no sleep code for the RFM95 so you can tell which mode its in by measuring the current it consumes. If in receive mode it takes circa 12mA, if in idle (like after reset) it takes about 1.5mA.

Check the NRESET and DIO0 pin with a scope when the ESP32 goes into sleep mode for any glitches on the pins.

Dont change the SyncWord, stick to the default. Some syncwords dont work, some result in reduced sensitivity and some let in packets with other syncwords (leaky).

Trying to deep sleep esp32 and it should wake up on LoRa msg receive and performs some action.

Thanks for the suggestions.
I have reverted the SyncWord to default. I don't have scope to check the glitches.
Any other method to do that?
Also I have added onReceive function with callback, but still no luck.

  // register the receive callback
  LoRa.onReceive(handleLoRaMsgCb);
  LoRa.receive(); // Put RFM96 in receive mode

  Serial.println("LoRa initialized and listening...");
}

void handleLoRaMsgCb(int packetSize) //TBC:: callback function is not called after wake up some how
{
  Serial.println("handleLoRaMsgCb: LoRa callback function called");
  Serial.println("packetSize: " + packetSize);
  handleLoRaMessage();
}

her is my output:

17:18:41.795 -> Wakeup was not caused by deep sleep: 0

17:18:41.795 -> Normal boot...

17:18:41.795 -> LoRa Receiver

17:18:41.795 -> LoRa initialized and listening...

17:18:41.795 -> Entering deep sleep...

One more thing, If i give 3.3v to GPIO26, I get this output:

17:14:10.954 -> Wakeup caused by external signal using RTC_IO

17:14:10.954 -> Woke up from LoRa message!

17:14:11.046 -> LoRa Receiver

17:14:11.093 -> LoRa initialized and listening...

17:14:11.093 -> handleLoRaMessage: LoRa Message received after waking up

17:14:11.093 -> Entering deep sleep...

have a look at this which wakes ESP32 from light sleep on DIO0 pulse

// ESP32 connected to a RFM95W LoRa module

// on receive packet wakeup from light sleep

#include <SPI.h>
#include <LoRa.h>
#include "driver/rtc_io.h"

// ESP32 VSPI connections
// ESP32 SCK pin GPIO18  to RFM95_pin SCK
// ESP32 MISO pin GPIO19  to RFM95_pin MISO
// ESP32 MOSI pin GPIO23  to RFM95_pin MOSI
// ESP32 pin GPIO 5   to RFM95 SS
// ESP32 pin GPIO4   to RFM95 Reset
// ESP32 pin GPIO2   to RFM95 DIO0

// measure time between rising edge using micros()

#define WAKEUP_GPIO GPIO_NUM_2  // RFM95 DIO0 wakeup pin

void setup() {
  Serial.begin(115200);
  delay(5000);
  Serial.println("\n\nESP32 LoRa RFM95W Receiver");
  // void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN);
  //LoRa.setPins(8, 4, 7);  // for Lora 32u4
  LoRa.setPins(5, 4, 2);  // for ESP32
  if (!LoRa.begin(866E6)) {
    Serial.println("Starting LoRa failed!");
    while (1)
      ;
  }
  Serial.println("Starting LoRa OK!");
}

// enable LoRa receiver, goto light sleep on wakeup read packet
void loop() {
  LoRa.receive();
  // set GPIO pin to wake on high pulse from RFM95 DIO0
  gpio_wakeup_enable(WAKEUP_GPIO, GPIO_INTR_HIGH_LEVEL);
  esp_sleep_enable_gpio_wakeup();
  Serial.println("goto light sleep");
  delay(1000);
  esp_light_sleep_start();  // light sleep!!
  Serial.begin(115200);
  while (!Serial) { delay(500); }
  Serial.println("wakeup from ligh sleep");
  // now read received packet
  int packetSize = LoRa.parsePacket();  // packet available
  if (packetSize) {
    Serial.print("Received packet '");
    while (LoRa.available()) {  // yes, read it
      Serial.print((char)LoRa.read());
    }
    // print RSSI of packet
    Serial.print("' with RSSI ");
    Serial.println(LoRa.packetRssi());
  }
}

Serial monitor prints

ESP32 LoRa RFM95W Receiver
Starting LoRa OK!
goto light sleep
wakeup from ligh sleep
Received packet 'hello 1442' with RSSI -69
goto light sleep
wakeup from ligh sleep
Received packet 'hello 1443' with RSSI -70
goto light sleep
wakeup from ligh sleep
Received packet 'hello 1444' with RSSI -70
goto light sleep
wakeup from ligh sleep
Received packet 'hello 1445' with RSSI -68
goto light sleep
wakeup from ligh sleep
Received packet 'hello 1446' with RSSI -69
goto light sleep

may give you some ideas

Thanks let me check light sleep.
But eventually I want ESP deep sleep to work.

This is what I get with light sleep using your code. It stucks at receive pkg as GPIO 26 LED is continuously ON.
Serial Monitor output:

00:45:05.624 -> ESP32 LoRa RFM95W Receiver

00:45:05.624 -> Starting LoRa OK!

00:45:05.624 -> goto light sleep

do you receive OK if you don't go into light sleep?
what is the transmitter and receiver expected to do?
think you need to post your code or at least a small program which displays the problem?
also a schematic showing the wiring?

Transmitter Code:

//config
#include <SPI.h>
#include <LoRa.h>
#include <Wire.h>
#include <RTClib.h>

// Pin setup
//#define LORA_SCK 18       //lora SCK pin
//#define LORA_MISO 19      //lora MISO pin
//#define LORA_MOSI 23      //lora MOSI pin
#define LORA_CS 5         //lora NSS pin
#define LORA_DIO0 26      //lora DIO0 pin
#define LORA_RST 27       //lora RESET pin


int counter = 0;

void setup() 
{
  Serial.begin(115200); 
  delay(1000); 
  Serial.println("Boot starting...");


  // Initialize LoRa
  LoRa.setPins(LORA_CS, LORA_RST, LORA_DIO0);
  if (!LoRa.begin(433E6)) // Set frequency to 915MHz =>915E6
  {  
    Serial.println("LoRa init failed!");
    while (1);
  }

  //LoRa.setSyncWord(0xF3);
  Serial.println("LoRa init success!");
}

void loop() 
{
  // Transmitting a message
  Serial.print("::Sending packet::");
  Serial.println(counter);
  String message = "Hello";
  //Send LoRa packet to receiver
  LoRa.beginPacket();
  LoRa.print(message);
  LoRa.print(counter);
  LoRa.endPacket();
  Serial.println(message +" "+ counter);

  counter++;

  delay(5000); //Send message after 10 seconds delay
}

Transmitter Output:

14:43:48.175 -> ::Sending packet::42

14:43:48.175 -> Hello42

14:43:53.205 -> ::Sending packet::43

14:43:53.205 -> Hello43

14:43:58.236 -> ::Sending packet::44

14:43:58.236 -> Hello44

14:44:03.237 -> ::Sending packet::45

14:44:03.294 -> Hello45

14:44:08.298 -> ::Sending packet::46

14:44:08.298 -> Hello46

14:44:13.321 -> ::Sending packet::47

14:44:13.368 -> Hello47

14:44:18.352 -> ::Sending packet::48

14:44:18.400 -> Hello48

14:44:23.389 -> ::Sending packet::49

14:44:23.389 -> Hello49

14:44:28.402 -> ::Sending packet::50

14:44:28.435 -> Hello50

Receiver Code:

#include <SPI.h>
#include <LoRa.h>
//define the pins used by the transceiver module
#define LORA_CS 5         //lora NSS pin
#define LORA_DIO0 GPIO_NUM_26      //lora DIO0 pin
#define LORA_RST 27       //lora RESET pin

void setup() {
  Serial.begin(115200);
  delay(5000);
  Serial.println("\n\nESP32 LoRa RFM996 Receiver");
  // void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN);
  //LoRa.setPins(8, 4, 7);  // for Lora 32u4
  LoRa.setPins(5, 27, 26);
  if (!LoRa.begin(433E6)) {
    Serial.println("Starting LoRa failed!");
    while (1)
      ;
  }
  Serial.println("Starting LoRa OK!");
}
// enable LoRa receiver, goto light sleep on wakeup read packet
void loop() {
  LoRa.receive();
  // set GPIO pin to wake on high pulse from RFM95 DIO0
  gpio_wakeup_enable(LORA_DIO0, GPIO_INTR_HIGH_LEVEL);
  esp_sleep_enable_gpio_wakeup();
  Serial.println("goto light sleep");
  delay(1000);
  esp_light_sleep_start();  // light sleep!!
  Serial.begin(115200);
  while (!Serial) { delay(500); }
  Serial.println("wakeup from ligh sleep");
  // now read received packet
  int packetSize = LoRa.parsePacket();  // packet available
  if (packetSize) {
    Serial.print("Received packet '");
    while (LoRa.available()) {  // yes, read it
      Serial.print((char)LoRa.read());
    }
    // print RSSI of packet
    Serial.print("' with RSSI ");
    Serial.println(LoRa.packetRssi());
  }
}

Receiver Output:

14:42:00.999 ->

14:42:00.999 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

14:42:00.999 -> configsip: 0, SPIWP:0xee

14:42:00.999 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

14:42:00.999 -> mode:DIO, clock div:1

14:42:00.999 -> load:0x3fff0030,len:4832

14:42:00.999 -> load:0x40078000,len:16460

14:42:00.999 -> load:0x40080400,len:4

14:42:00.999 -> load:0x40080404,len:3504

14:42:00.999 -> entry 0x400805cc

14:42:06.155 ->

14:42:06.155 ->

14:42:06.155 -> ESP32 LoRa RFM996 Receiver

14:42:06.155 -> Starting LoRa OK!

14:42:06.155 -> goto light sleep

tried my program of post 10 and it does not work with RFM95 DIO0 connected to GPIO26 - works OK connected to 27
try exchanging 26 and 27

You should be able to wakeup from deep sleep when a packet comes in, but I suspect the library you are using is not setup to allow you to read the received packet on a wakeup from ESP32 deep sleep. May not be a problem of course.

Remember that when the ESP32 goes into deep sleep, all variables, etc are lost, so on wakeup the LoRa library wont know how to access the LoRa device without being restarted, which might well clear the packet.

the RFM95 DIO0 signal will wake up the ESP32 from deep sleep but as you say the packet is lost

one possible technique is

  1. the receiver program enables LoRa receiver and goes to deep sleep
  2. initially the transmitter sends a short wakeup packet followed short time later by a data packet (the short time is to allow time for the RTC_IO reset and initialze the LoRa receiver )
  3. on receipt of the wakeup RTC_IO packet the receiver will then wait for a short time for the data packet
  4. receiver will read data packet, process it and then go into deep sleep

example code

// ESP32 connected to a RFM95W LoRa module

// when in deep sleep on receiving LoRa packet on a RTC_IO receiver wakes up 
// In Deep-sleep mode, the CPUs, most of the RAM, and 
// all digital peripherals that are clocked from APB_CLK are powered off.
// therefore any LoRa packet which caused wakeup from deep sleep wiil be lost

// one possible technique is
// 1. the receiver program enables LoRa receiver and goes to deep sleep
// 2. initially the transmitter sends a short wakeup packet followed short time later by a data packet 
//      (the short time is to allow time for the RTC_IO reset and initialze the LoRa receiver )
// 3. on receipt of the wakeup RTC_IO packet the receiver will then wait for a short time for the data packet
// 4. receiver will read data packet, process it and then go into deep sleep

#include <SPI.h>
#include <LoRa.h>
#include "driver/rtc_io.h"

// ESP32 VSPI connections
// ESP32 SCK pin GPIO18  to RFM95_pin SCK
// ESP32 MISO pin GPIO19  to RFM95_pin MISO
// ESP32 MOSI pin GPIO23  to RFM95_pin MOSI
// ESP32 pin GPIO 5   to RFM95 SS
// ESP32 pin GPIO4   to RFM95 Reset
// ESP32 pin GPIO2   to RFM95 DIO0

// measure time between rising edge using micros()

#define WAKEUP_GPIO GPIO_NUM_2  // RFM95 DIO0 wakeup pin

// on reset this will display the reason
int print_wakeup_reason() {
  esp_sleep_wakeup_cause_t wakeup_reason;
  wakeup_reason = esp_sleep_get_wakeup_cause();
  switch (wakeup_reason) {
    case ESP_SLEEP_WAKEUP_EXT0: Serial.println("Wakeup caused by external signal using RTC_IO"); break;
    case ESP_SLEEP_WAKEUP_EXT1: Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
    case ESP_SLEEP_WAKEUP_TIMER: Serial.println("Wakeup caused by timer"); break;
    case ESP_SLEEP_WAKEUP_TOUCHPAD: Serial.println("Wakeup caused by touchpad"); break;
    case ESP_SLEEP_WAKEUP_ULP: Serial.println("Wakeup caused by ULP program"); break;
    default:
      Serial.printf("Wakeup was not caused by deep sleep: %d\n", wakeup_reason);
      return -1;
      break;
  }
  return wakeup_reason;
}

void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.println("\n\nESP32 LoRa RFM95W Receiver");
  // void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN);
  //LoRa.setPins(8, 4, 7);  // for Lora 32u4
  LoRa.setPins(5, -1, 2);  // for ESP32
  if (!LoRa.begin(866E6)) {
    Serial.println("Starting LoRa failed!");
    while (1)
      ;
  }
  Serial.println("Starting LoRa OK!");
  // if woken up by external EXT0 from RFM95 DIO0
  if (print_wakeup_reason() == ESP_SLEEP_WAKEUP_EXT0) {
    // wait for a following packet
    unsigned long timer1 = millis();
    while (millis() - timer1 < 10000) {
      int packetSize = LoRa.parsePacket();
      if (packetSize) {
        Serial.print("Received packet '");
        while (LoRa.available()) {
          Serial.print((char)LoRa.read());
        }
        // print RSSI of packet
        Serial.print("' with RSSI ");
        Serial.println(LoRa.packetRssi());
        break;
      }
    }
  }

  // enable LoRa receiver and goto deep sleep waiting for next packet
  LoRa.receive();
  esp_sleep_enable_ext0_wakeup(WAKEUP_GPIO, 1);  //1 = High, 0 = Low
  // Configure pullup/downs via RTCIO to tie wakeup pins to inactive level during deepsleep.
  // EXT0 resides in the same power domain (RTC_PERIPH) as the RTC IO pullup/downs.
  // No need to keep that power domain explicitly, unlike EXT1.
  rtc_gpio_pullup_dis(WAKEUP_GPIO);
  rtc_gpio_pulldown_en(WAKEUP_GPIO);
  //Go to sleep now
  Serial.println("Going to sleep now");
  esp_deep_sleep_start();
  Serial.println("This will never be printed");
}

void loop() {}

a run gave

ESP32 LoRa RFM95W Receiver
Starting LoRa OK!
Wakeup was not caused by deep sleep: 0
Going to sleep now
ets Jul 29 2019 12:21:46

rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:4916
load:0x40078000,len:16436
load:0x40080400,len:4
ho 8 tail 4 room 4
load:0x40080404,len:3524
entry 0x400805b8


ESP32 LoRa RFM95W Receiver
Starting LoRa OK!
Wakeup caused by external signal using RTC_IO
Received packet 'hello 282' with RSSI -64
Going to sleep now

ESP32 LoRa RFM95W Receiver
Starting LoRa OK!
Wakeup caused by external signal using RTC_IO
Received packet 'hello 284' with RSSI -65
Going to sleep now

ESP32 LoRa RFM95W Receiver
Starting LoRa OK!
Wakeup caused by external signal using RTC_IO
Received packet 'hello 286' with RSSI -64
Going to sleep now

ESP32 LoRa RFM95W Receiver
Starting LoRa OK!
Wakeup caused by external signal using RTC_IO
Received packet 'hello 288' with RSSI -64
Going to sleep now

ESP32 LoRa RFM95W Receiver
Starting LoRa OK!
Wakeup caused by external signal using RTC_IO
Received packet 'hello 290' with RSSI -64
Going to sleep now

ESP32 LoRa RFM95W Receiver
Starting LoRa OK!
Wakeup caused by external signal using RTC_IO
Received packet 'hello 292' with RSSI -65
Going to sleep now

ESP32 LoRa RFM95W Receiver
Starting LoRa OK!
Wakeup caused by external signal using RTC_IO
Received packet 'hello 294' with RSSI -64
Going to sleep now
ets Jul 29 2019 12:21:46

ESP32 LoRa RFM95W Receiver
Starting LoRa OK!
Wakeup caused by external signal using RTC_IO
Received packet 'hello 296' with RSSI -65
Going to sleep now


ESP32 LoRa RFM95W Receiver
Starting LoRa OK!
Wakeup caused by external signal using RTC_IO
Received packet 'hello 298' with RSSI -64
Going to sleep now


ESP32 LoRa RFM95W Receiver
Starting LoRa OK!
Wakeup caused by external signal using RTC_IO
Received packet 'hello 300' with RSSI -65
Going to sleep now


ESP32 LoRa RFM95W Receiver
Starting LoRa OK!
Wakeup caused by external signal using RTC_IO
Received packet 'hello 302' with RSSI -65
Going to sleep now


ESP32 LoRa RFM95W Receiver
Starting LoRa OK!
Wakeup caused by external signal using RTC_IO
Received packet 'hello 304' with RSSI -65
Going to sleep now


one can see alternate LoRa packets are displayed

  1. first packet wakes up ESP32 but is lost
  2. second packet is read and displayed

Phew.
Thanks alot @horace
Swapping pins 26 and 27 works. ESP was able to wakeup during light sleep with LoRa.

output:

22:46:19.079 -> Received packet: Hello444' with RSSI -32

22:46:24.116 -> Received packet: Hello445' with RSSI -31

22:46:29.123 -> Received packet: Hello446' with RSSI -31

22:46:34.185 -> Received packet: Hello447' with RSSI -32

22:46:39.217 -> Received packet: Hello448' with RSSI -32

22:46:44.230 -> Received packet: Hello449' with RSSI -32

22:46:49.312 -> Received packet: Hello450' with RSSI -32

22:46:54.334 -> Received packet: Hello451' with RSSI -42

Thanks guys for the help. much appreciated. @horace and @srnet
LoRa.setPins(5, -1, 2); // for ESP32
This line does the trick. Setting Reset to '-1' wakes the ESP from deep sleep.
with your code, I am getting the same output as yours. intermediate packet is lost in waking up ESP module, which makes sense. And can be handled with logic.
Thanks again

Output:

22:53:08.418 ->
22:53:08.418 ->
22:53:08.418 -> ESP32 LoRa RFM96 Receiver
22:53:08.418 -> Starting LoRa OK!
22:53:08.418 -> Wakeup was not caused by deep sleep: 0
22:53:08.418 -> Going to sleep now
22:53:12.021 -> ets Jul 29 2019 12:21:46
22:53:12.022 ->
22:53:12.022 -> rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
22:53:12.022 -> configsip: 0, SPIWP:0xee
22:53:12.022 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
22:53:12.022 -> mode:DIO, clock div:1
22:53:12.022 -> load:0x3fff0030,len:4832
22:53:12.022 -> load:0x40078000,len:16460
22:53:12.022 -> load:0x40080400,len:4
22:53:12.022 -> load:0x40080404,len:3504
22:53:12.022 -> entry 0x400805cc
22:53:13.071 ->
22:53:13.111 ->
22:53:13.111 -> ESP32 LoRa RFM96 Receiver
22:53:13.111 -> Starting LoRa OK!
22:53:13.111 -> Wakeup caused by external signal using RTC_IO
22:53:17.028 -> Received packet 'Hello527' with RSSI -31
22:53:17.075 -> Going to sleep now
22:53:22.065 -> ets Jul 29 2019 12:21:46
22:53:22.103 ->
22:53:22.103 -> rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
22:53:22.103 -> configsip: 0, SPIWP:0xee
22:53:22.103 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
22:53:22.103 -> mode:DIO, clock div:1
22:53:22.103 -> load:0x3fff0030,len:4832
22:53:22.103 -> load:0x40078000,len:16460
22:53:22.103 -> load:0x40080400,len:4
22:53:22.103 -> load:0x40080404,len:3504
22:53:22.103 -> entry 0x400805cc
22:53:23.168 ->
22:53:23.168 ->
22:53:23.168 -> ESP32 LoRa RFM96 Receiver
22:53:23.168 -> Starting LoRa OK!
22:53:23.168 -> Wakeup caused by external signal using RTC_IO
22:53:27.127 -> Received packet 'Hello529' with RSSI -41
22:53:27.127 -> Going to sleep now
22:53:32.139 -> ets Jul 29 2019 12:21:46

As per the suggestion in post #2.

If on going into deep sleep there is a 'glitch' on the LoRa devices reset pin, its reset and no longer in receive mode.

And the simple current measurements suggested in post #7, would have told you if the LoRa device remained in receive mode or had been reset.