Problem With WakeUp on External for Heltec ESP32 v2

I am writing a simple code on Heltec ESP32 v2 board and want to make it deep sleep till an external signal got from PIR.
For this GPIO_NUM_27 pin as input.
But the problem is although the pir is not connected to the pin 27 it wakes up in 2-2.5 seconds I also changed it to low but no affect.
I have tried the same with 33 there is no problem or 19.

The code is like

void setup(){
//WIFI Kit series V1 not support Vext control
Heltec.begin(false /DisplayEnable Enable/, true /LoRa Disable/, true /Serial Enable/, true /PABOOST Enable/, BAND /long BAND/);
//Increment boot number and print it every reboot
++bootCount;
Serial.println("Boot number: " + String(bootCount));
delay(2);
//Print the wakeup reason for ESP32
print_wakeup_reason();
Serial.println(“Setup ESP32 to sleep for every " + String(TIME_TO_SLEEP) +
" Seconds”);
delay(100);

LoRa.end();
LoRa.sleep();
delay(100);

pinMode(5,INPUT);

pinMode(14,INPUT);
pinMode(15,INPUT);
pinMode(16,INPUT);
pinMode(17,INPUT);
pinMode(18,INPUT);
pinMode(19,INPUT);

pinMode(26,INPUT);
pinMode(27,INPUT);

delay(100);
Serial.println(“Going to sleep now”);
delay(2);
esp_sleep_enable_ext0_wakeup(GPIO_NUM_27,1);
delay(1000);
esp_deep_sleep_start();
Serial.println(“This will never be printed”);
}

I did same as you. I tried first this code example:
https://randomnerdtutorials.com/esp32-deep-sleep-arduino-ide-wake-up-sources/

Yes that was the starting point but did not create a solution on Heltec.

There is a discussion https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/issues/6

GPIO27 is wired to LoRa MOSI
GPIO19 is wired to LoRa MISO

To prevent issues you should not use these GPIO’s to trigger external wakeup interrupts from a PIR.


Not relevant for your issue, but note that Heltec Wifi LoRa 32 V2 has I2C related configuration issues.
See the following post for more information.

1 Like

Thanks blueJedi. You are right i will change the GPIO port. As declared in the layout only 2,12,13 are free to use for digital in.
image