esp_err_t rtc_gpio_pulldown_en(GPIO_NUM_33); not working

Dean Greenhough
Posts: 4
Joined: Wed Mar 28, 2018 9:44 pm

esp_err_t rtc_gpio_pulldown_en(GPIO_NUM_33); not working

Postby Dean Greenhough » Fri Apr 06, 2018 3:56 pm

Hi all

First time to post and just migrating over to the esp32, I still classify myself as a newbie.

The problem

I am attempting to setup an RTC IO PIN 33 as per the ExternalWakeup.ino sketch in the esp32 examples section.

The sketch works perfectly using an external 10k pulldown resistor with push button on the breadboard. I wanted to use internal pulldown on the esp32 and inserted the following line: esp_err_t rtc_gpio_pulldown_en(GPIO_NUM_33); compiles OK, but has no effect on the pin, there is still a floating voltage enough to false trigger.

I have looked at the documentation and found:

/**
* @brief RTC GPIO pulldown enable
*
* This function only works for RTC IOs. In general, call gpio_pulldown_en,
* which will work both for normal GPIOs and RTC IOs.
*
* @param gpio_num GPIO number (e.g. GPIO_NUM_12)
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG GPIO is not an RTC IO
*/
esp_err_t rtc_gpio_pulldown_en(gpio_num_t gpio_num);

I would therefore like to be able to get @return- ESP_OK Success - ESP_ERR_INVALID_ARG GPIO is not an RTC IO to see if the pulldown has been successful or failed.

Not sure if I have completely got this wrong or if this function is not yet enabled. In the past I have used something like this
char returnErrorCode = esp_err_t rtc_gpio_pulldown_en(GPIO_NUM_33);

Not sure if this is a gap in my understanding, Im really lost as to how to proceed.

Many thanks for taking the time to read and hopefully answer the above.







Code: Select all

/*
Deep Sleep with External Wake Up
=====================================
This code displays how to use deep sleep with
an external trigger as a wake up source and how
to store data in RTC memory to use it over reboots

This code is under Public Domain License.

Hardware Connections
======================
Push Button to GPIO 33 pulled down with a 10K Ohm
resistor

NOTE:
======
Only RTC IO can be used as a source for external wake
source. They are pins: 0,2,4,12-15,25-27,32-39.

Author:
Pranav Cherukupalli <cherukupallip@gmail.com>
*/

//#define BUTTON_PIN_BITMASK 0x200000000 // 2^33 in hex

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 1  : Serial.println("Wakeup caused by external signal using RTC_IO"); break;
    case 2  : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
    case 3  : Serial.println("Wakeup caused by timer"); break;
    case 4  : Serial.println("Wakeup caused by touchpad"); break;
    case 5  : Serial.println("Wakeup caused by ULP program"); break;
    default : Serial.println("Wakeup was not caused by deep sleep"); 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();

  /*
  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.
  */
  esp_err_t rtc_gpio_pulldown_en(GPIO_NUM_33);
  
  esp_sleep_enable_ext0_wakeup(GPIO_NUM_33,1); //1 = High, 0 = Low

  //If you were to use ext1, you would use it like
  //esp_deep_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK,ESP_EXT1_WAKEUP_ANY_HIGH);

  //Go to sleep now
  Serial.println("Going to sleep now");
  esp_deep_sleep_start();
  Serial.println("This will never be printed");
}

void loop(){
  //This is not going to be called
}

EinfachArne
Posts: 1
Joined: Mon Apr 13, 2020 6:19 pm

Re: esp_err_t rtc_gpio_pulldown_en(GPIO_NUM_33); not working

Postby EinfachArne » Mon Apr 13, 2020 6:28 pm

Hello everybody,

this post is now almost two years old but I found myself with the exact same problem. I try to wakeup my ESP32 via switch. If the switch is open, the ESP32 wakes up all the time and as soon as I close it everything works fine.

Is there something else to do for it to work?

Best regards
Arne

Who is online

Users browsing this forum: Google [Bot] and 136 guests