I’m having a problem with Pro Mico ESP32-C3 compiling ExternalWakeUp.ino low power example. The Timer Wake Up example compiles and runs okay on the Pro Mico. ExternalWakeUp.ino compiles and runs okay on a different ESP32 platform, but not on the Pro Micro.
It would seem the problem is related to the Pro Mico ESP32-C3 board file from Sparkfun, but I’m not sure. Does anyone have any thoughts?
Thanks, I’ll take check it out. I installed the Board Files from GitHub about a year ago when I bought my first Pro Micro ESP32-C3, but I’ll take another look.
I followed the Software Setup steps, which were actually a modification of what I already had installed. It didn’t change the compile errors on the ExternalWakeUp.ino example.
esp_sleep_enable_ext0_wakeup(WAKEUP_GPIO, 1); is not recognized.
rtc_gpio_pullup_dis(WAKEUP_GPIO); and rtc_gpio_pulldown_en(WAKEUP_GPIO); are also not found.
ESP32 vs. ESP32-C3 Differences:
The ESP32-C3 is based on the RISC-V architecture and has a different sleep wakeup implementation than the original ESP32.
Different Deep Sleep Wakeup Functions:
The esp_sleep_enable_ext0_wakeup() function does not exist for ESP32-C3. Instead, you need to use esp_sleep_enable_ext1_wakeup() or gpio_wakeup_enable().
Thanks for your suggestions. I can get the Pro Micro ESP32-C3 to go into the sleep mode and I get this message :
ESP-ROM:esp32c3-api1-20210207
Boot number: 1
Wakeup was not caused by deep sleep: 0
Going to sleep now
But pressing the button to bring the GPIO HIGH does not wake up the processor. I’ll post my modification of the example version of ExternalWakeUp.ino below:
<#include <Arduino.h
#include <driver/gpio.h> // GPIO definitions
#include <esp_sleep.h> // Sleep functions
#define BUTTON_PIN_BITMASK(GPIO) (1ULL << GPIO) // 2 ^ GPIO_NUMBER in hex
#define USE_EXT0_WAKEUP 1 // 1 = EXT0 wakeup, 0 = EXT1 wakeup
#define WAKEUP_GPIO GPIO_NUM_4 // Using GPIO 4 for wake up
RTC_DATA_ATTR int bootCount = 0;
/*
Method to print the reason by which ESP32
has been awaken from sleep
*/
void print_wakeup_reason() {
esp_sleep_wakeup_cause_t wakeup_reason;
wakeup_reason = esp_sleep_get_wakeup_cause();
switch (wakeup_reason) {
case ESP_SLEEP_WAKEUP_GPIO: Serial.println("Wakeup caused by GPIO"); break;
case ESP_SLEEP_WAKEUP_TIMER: Serial.println("Wakeup caused by timer"); break;
case ESP_SLEEP_WAKEUP_UART: Serial.println("Wakeup caused by UART"); break;
default: Serial.printf("Wakeup was not caused by deep sleep: %d\n", wakeup_reason); break;
}
}
void setup() {
Serial.begin(115200);
delay(1000); //Take some time to open up the Serial Monitor
//Increment boot number and print it every reboot
++bootCount;
Serial.println("Boot number: " + String(bootCount));
//Print the wakeup reason for ESP32
print_wakeup_reason();
#if USE_EXT0_WAKEUP
// Using GPIO wake up method as recommended by Sparkfun
gpio_wakeup_enable((gpio_num_t)WAKEUP_GPIO, GPIO_INTR_HIGH_LEVEL);
esp_sleep_enable_gpio_wakeup();
// Configure pullup/downs using standard GPIO functions
gpio_pullup_dis((gpio_num_t)WAKEUP_GPIO);
gpio_pulldown_en((gpio_num_t)WAKEUP_GPIO);
#else // EXT1 WAKEUP
//If you were to use ext1, you would use it like
esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK(WAKEUP_GPIO), ESP_EXT1_WAKEUP_ANY_HIGH);
// Configure GPIO pullup/pulldown
gpio_pullup_dis((gpio_num_t)WAKEUP_GPIO);
gpio_pulldown_en((gpio_num_t)WAKEUP_GPIO);
#endif
//Go to sleep now
Serial.println("Going to sleep now");
delay(100); // Brief delay to allow serial to finish
esp_deep_sleep_start();
Serial.println("This will never be printed");
}
void loop() {
//This is not going to be called
}
I’ve used the Sparkfun Pro Micro ESP32-C3 for a number of recent projects. It’s compact size makes it particularly suitable for battery-powered projects.
The sketch that works is the one in the answer reply. It seems quite simple compared to some of the others we’ve looked at. Initial current measurements: 17mA awake, 0.5mA asleep. Those measurements are with the red power LED in the circuit.