<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Wake up using button A or button b]]></title><description><![CDATA[<p dir="auto">Hey, i try to wakeup m5stickc from deepsleep using button A or B with this function : esp_sleep_enable_ext1_wakeup with ESP_EXT1_WAKEUP_ANY_HIGH mode.  Problem encountered is that A and  B button have pullup enabled.</p>
<p dir="auto">Im aware that A and B button pull their respective GPIO low when pressed. How to activated pulldown for these buttons? i can't use ESP_EXT1_WAKEUP_ALL_LOW mode because wake up enabled when all GPIOs are low...</p>
<p dir="auto">gpio_pulldown_en(); has no effect!</p>
<p dir="auto">This is my code:</p>
<pre><code>#define BUTTON_PIN_BITMASK (BIT64(GPIO_NUM_37)| BIT64(GPIO_NUM_39))

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_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); break;
  }
}

/*
Method to print the GPIO that triggered the wakeup
*/
void print_GPIO_wake_up(){
  uint64_t GPIO_reason = esp_sleep_get_ext1_wakeup_status();
  Serial.print("GPIO that triggered the wake up: GPIO ");
  Serial.println((log(GPIO_reason))/log(2), 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));

  //Print the wakeup reason for ESP32
  print_wakeup_reason();

  //Print the GPIO used to wake up
  print_GPIO_wake_up();

  /*
  First we configure the wake up source
  We set our ESP32 to wake up for an external trigger.
  There are two types for ESP32, ext0 and ext1 .
  ext0 uses RTC_IO to wakeup thus requires RTC peripherals
  to be on while ext1 uses RTC Controller so doesnt need
  peripherals to be powered on.
  Note that using internal pullups/pulldowns also requires
  RTC peripherals to be turned on.
  */
  
  gpio_pulldown_en(GPIO_NUM_39);
  gpio_pulldown_en(GPIO_NUM_37);
  gpio_pullup_dis(GPIO_NUM_39);
  gpio_pullup_dis(GPIO_NUM_37);
  //If you were to use ext1, you would use it like
  esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK,ESP_EXT1_WAKEUP_ANY_HIGH);//ESP_EXT1_WAKEUP_ANY_HIGH  ESP_EXT1_WAKEUP_ALL_LOW
  //Go to sleep now
  Serial.println("Going to sleep now");
  delay(1000);
  esp_deep_sleep_start();
  Serial.println("This will never be printed");
}

void loop(){
  //This is not going to be called
}
</code></pre>
<p dir="auto">Thanks for your help</p>
]]></description><link>https://community.m5stack.com/topic/3356/wake-up-using-button-a-or-button-b</link><generator>RSS for Node</generator><lastBuildDate>Mon, 11 May 2026 06:52:57 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/3356.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 08 Jun 2021 15:22:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wake up using button A or button b on Sun, 20 Jun 2021 17:47:08 GMT]]></title><description><![CDATA[<p dir="auto">thanks, I think it's the only solution ;)</p>
]]></description><link>https://community.m5stack.com/post/14147</link><guid isPermaLink="true">https://community.m5stack.com/post/14147</guid><dc:creator><![CDATA[irokoi]]></dc:creator><pubDate>Sun, 20 Jun 2021 17:47:08 GMT</pubDate></item><item><title><![CDATA[Reply to Wake up using button A or button b on Wed, 09 Jun 2021 07:26:27 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/irokoi" aria-label="Profile: irokoi">@<bdi>irokoi</bdi></a></p>
<p dir="auto">have you considered using <code>ext0</code> instead? E.g.</p>
<pre><code>esp_sleep_enable_ext0_wakeup(GPIO_NUM_37, LOW);
esp_sleep_enable_ext0_wakeup(GPIO_NUM_39, LOW);
</code></pre>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/14058</link><guid isPermaLink="true">https://community.m5stack.com/post/14058</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Wed, 09 Jun 2021 07:26:27 GMT</pubDate></item></channel></rss>