I have tried GPIO5 and GPIO7 in LOW and HIGH and all combinations wake up with no problem.
I don’t know what is different from your environment, but if XIAO can’t wake up from GPIO5 and 7, how about the following idea?
For example, change D0–>DIR connected to pololu stspin220 to D10–>DIR and use D0 as a wake-up pin.
the problem isn’t that it can’t wake up, the problem is that it automatically wakes up, when it shouldn’t. When I use an external pull down resistor it works fine, but adding those inside my planetarium watch is a challenge, so I rather would use the internal pull down method.
I attached a phone based oscilloscope to Gpio_7 and it sure enough shows a big 50 Hz sine wave, with an amplitude of about 4V (more when I touch the wire). That kind of signal could trigger the wakeup. But I didn’t expect that signal to be present when the internal pull down is enabled.
Why do you think D0 would behave different?
It does not wake up on its own, but only when the switch is pressed.
GPIO5-8 are JTAG pins, and BoardSupportPackage initializes the pins for JTAG, but the pull-up and pull-down settings may not override this setting properly. Or maybe there is a difference in functionality between the documentation and the chip due to differences in production timing. I actually don’t know.
with the pull up enabled (instead of pull down) (pulldown disabled and wakeup on LOW) could you add this line
Serial.printf(“level %d (should be 1)\n”,rtc_gpio_get_level(WAKEUP_GPIO));
If you use my attached code, there is a long delay so you might need wait a long time. In my case it prints 0 instead of 1.
#include <Arduino.h>
#include "driver/rtc_io.h"
#define BUTTON_PIN_BITMASK(GPIO) (1ULL << GPIO) // 2 ^ GPIO_NUMBER
#define WAKEUP_GPIO GPIO_NUM_7
RTC_DATA_ATTR int bootCount = 0;
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));
delay(15000); // extra long delay, so i can wake it up and write new code to it
gpio_reset_pin(WAKEUP_GPIO); // just to make sure
esp_sleep_enable_ext1_wakeup_io(1ULL << WAKEUP_GPIO, ESP_EXT1_WAKEUP_ANY_LOW);
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
rtc_gpio_pullup_en(WAKEUP_GPIO);
rtc_gpio_pulldown_dis(WAKEUP_GPIO);
delay(200);
Serial.printf("level %d (should be 1)\n",rtc_gpio_get_level(WAKEUP_GPIO));
delay(1000);
Serial.println("Going to sleep now");
esp_deep_sleep_start();
Serial.println("This will never be printed");
}
void loop() {
}
I tried yours, and hold down reset for 3 seconds, it doesn’t work for me. I think it is more or less the same but without the added print statement of the level
Could you try with it?
The display is wrong only the times immediately after the reset, but after that it wakes up every time I push the switch for a short time LOW and the display is fine.
You said that it wakes up automatically, but do you keep inputting LOW?
<---- reset
15:32:21.648 -> Boot number: 1
15:32:21.843 -> level 0 (should be 1)
15:32:22.827 -> Going to sleep now
15:32:36.316 -> Boot number: 2 <---- push switch
15:32:36.513 -> level 1 (should be 1)
15:32:37.530 -> Going to sleep now
15:32:46.348 -> Boot number: 3 <---- push switch
15:32:46.546 -> level 1 (should be 1)
15:32:47.530 -> Going to sleep now
//----------------------------------------------------------------------------------------------
//Board Library : esp32 by Espressif 3.0.7
//Board Select : XIAO_ESP32C6
//----------------------------------------------------------------------------------------------
// 2025/01/26
/*
NOTE:
Only RTC IO can be used as a source for external wake
See ESP32-C6 Technical Reference Manual 7.13 LO IO MUX Functions List
XIAO ESP32C6 RTC IO pins : D0(0), D1(1), D2(2), Backside MTMS(4), MTDI(5), MTCK(6), MTDO(7)
EXT0 wakeup causes compaing error
*/
#include "driver/rtc_io.h"
#define BUTTON_PIN_BITMASK(GPIO) (1ULL << GPIO)
#define WAKEUP_GPIO GPIO_NUM_5
RTC_DATA_ATTR int bootCount = 0;
void setup() {
Serial.begin(115200);
delay(1000);
++bootCount;
Serial.println("Boot number: " + String(bootCount));
/*
// wake up in HIGH
esp_sleep_enable_ext1_wakeup_io(BUTTON_PIN_BITMASK(WAKEUP_GPIO), ESP_EXT1_WAKEUP_ANY_HIGH);
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
rtc_gpio_pulldown_en(WAKEUP_GPIO);
rtc_gpio_pullup_dis(WAKEUP_GPIO);
*/
// wake up in LOW
esp_sleep_enable_ext1_wakeup_io(BUTTON_PIN_BITMASK(WAKEUP_GPIO), ESP_EXT1_WAKEUP_ANY_LOW);
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
rtc_gpio_pulldown_dis(WAKEUP_GPIO);
rtc_gpio_pullup_en(WAKEUP_GPIO);
delay(200);
Serial.printf("level %d (should be 1)\n",rtc_gpio_get_level(WAKEUP_GPIO));
delay(1000);
Serial.println("Going to sleep now");
esp_deep_sleep_start();
Serial.println("This will never be printed");
}
void loop() {
}
No, I don’t keep it low, I keep it floating, and the internal resistor should keep it high. I’m stumped. yours works like I would expect (thanks for your time testing this). my esp32c6 only works with external resistors.
I now have two esp32c6 with the same bad behavior. I’m using version 3.1.1 of the espressif esp32 boardmanager package and arduino ide 2.3.2
scary… I just tried 3.0.7 and it cause a core dump (Guru Meditation Error: Core 0 panic’ed (Interrupt wdt timeout on CPU0))
But I tried once more and… drum roll… it works!!
Thanks a lot!!
of course now is the big question what is changed between 3.0.7 and 3.1.1 that made this happen.
just to confirm. It didn’t work with version 3.1.1 of the board definition, switched to 3.0.7 and it worked. switched to 3.1.0 and it failed, back to 3.0.7 and it first showed me again the core dump, but compiling it one extra time and it works fine with version 3.0.7.
Where should I report this?
Congrats on getting it going, The BSP again is the culprit… LOL thanks Espressif. Who the heck knows what and why they changed it.
changes just introduced a bunch or problems. (to be fair) they did fix some compatibility for the TFT_eSPI LIB so SPI stuff probably got cleaned up. If I didn’t know better I would think they are Jerking us around trying to get folks to switch dev systems to ESP-IDF. jagoff’s
They rose to fame on Arduino, now kick them to the curb.
They try to put everything but the kitchen sink in the ESP32 and just make it worse IMO. Even there SLEEP and LOW power is sus.
I’m only doing pretty simple things, mostly driving stepper motors using a stepper motor controller like TMC2209. I’m very happy with this esp32c6 board. it has a tiny form factor and comes with a battery charging circuit. Just what I needed. For this project (and probably my next two), I want a very tiny stepper motor to run my planetarium. It is battery powered and especially for my current project (a watch sized planetarium) there isn’t a lot of space. It needs this board, a low voltage stepper motor controller board, battery, a magnet, a reed switch, a resistor and a motor. On top of that all the planets and some metal strips to turn the existing knob on the watch into a switch. So being able to use the internal pull down resistors instead of two extra resistors is a big plus. So I’m happy, just hoping they undo the mistake they made with 3.1.1 version.
I assumed you were using 3.0.7 as well, since the beginning of the sketch I posted clearly states that it was compiled with 3.0.7.
BoardSupportPackage has been upgraded in the past without any emphasis on compatibility, so I don’t know if this will solve the problem, but why don’t you raise the issue below