Hi, All
Recently i published the code https://www.b4x.com/android/forum/threads/esp32-deepsleep-until-wake-up-by-timer-or-button.167482 that worked for classical ESP32.
But now i'm trying to make esp32-c3 to wake up by the GPIO0 button.
And this does not work. And more over - "Serial.println" from inline-C - does not work at all, and i'm not sure if #ifdef runs...
Any help with the code below ?
Usage is just
Recently i published the code https://www.b4x.com/android/forum/threads/esp32-deepsleep-until-wake-up-by-timer-or-button.167482 that worked for classical ESP32.
But now i'm trying to make esp32-c3 to wake up by the GPIO0 button.
And this does not work. And more over - "Serial.println" from inline-C - does not work at all, and i'm not sure if #ifdef runs...
Any help with the code below ?
B4X:
'if zero - just pin wake up is activated
Public Sub Go_Sleep(ms As ULong)
Log("Go deep sleep for ", ms, " msecs")
Delay(10)
esp32_DeepSleep(ms)
End Sub
Private Sub esp32_DeepSleep(ms As ULong)
RunNative("deepSleep", ms)
End Sub
#if C
#include <esp_sleep.h>
#include <driver/rtc_io.h>
#define BUTTON_PIN GPIO_NUM_0
void deepSleep(B4R::Object* o) {
// wake up by timer (msec)
uint64_t sleep_time_us = o->toULong() * 1000;
if(sleep_time_us > 0) {
esp_sleep_enable_timer_wakeup(sleep_time_us);
}
#ifdef CONFIG_IDF_TARGET_ESP32
// ESP32: use EXT0 (just single pin)
Serial.println("CONFIG_IDF_TARGET_ESP32");
delay(100);
esp_sleep_enable_ext0_wakeup(BUTTON_PIN, LOW);
#elifdef defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)
Serial.println("CONFIG_IDF_TARGET_ESP32++++");
delay(100);
// ESP32-S2 / C3 / S3: use EXT1 (pins mask)
uint64_t ext1_mask = 1ULL << BUTTON_PIN;
esp_sleep_enable_ext1_wakeup(ext1_mask, ESP_SLEEP_EXT1_WAKEUP_ALL_LOW); //ESP_SLEEP_EXT1_WAKEUP_ANY_HIGH
#endif
delay(100);
// going To Deep Sleep
esp_deep_sleep_start();
}
#end if
Usage is just
B4X:
Log("going to sleep")
others.Go_Sleep(0)
New upload port: COM14 (serial)
---------------------
AppStart
ESP.ResetReasonMessage = Restarted 11: Unknown reset reason (11)
Device_ID = F0F5BDFDD470_v0.20
MAGIC_EEPROM = 213
This device name = aiFonar_F0F5BDFDD470_v0.20
RTC read BatCapacity = 0
From RTC BatCapacity = 0, try from NVS
From NVS BatCapacity = 59.8000
RTC saved BatCapacity = 59.8000
Configuring WDT...
Last Reset : ESP_OK
WDT is configured
going to sleep
Go deep sleep for 0 msecs