[Codebox=c file=Untitled.c][/Codebox]
Hardware being used is a Heltec Lora 32(V2) board under Arduino.
Started using GPIO 36 & GPIO 39 as inputs from a Reed Switch.
Was using RTC_GPIO functions. Could not get any inputs, high to low. Using external pullups.
Switched to RTC_GPIO 12 & 13 as inputs, no external pullups but using internal pullups.
Some sample RTC code:
rtc_gpio_deinit(GPIO_NUM_12);
rtc_gpio_deinit(GPIO_NUM_13);
rtc_gpio_set_direction(GPIO_NUM_12, RTC_GPIO_MODE_INPUT_ONLY);
rtc_gpio_set_direction(GPIO_NUM_13, RTC_GPIO_MODE_INPUT_ONLY);
rtc_gpio_pullup_en(GPIO_NUM_12);
rtc_gpio_pullup_en(GPIO_NUM_13);
Was not able to get input transition from Reed Switch.
Decided to switch to GPIO output and toggle GPIO 12. RTC_GPIO functions did not work trying to toggle the outputs on RTC_GPIO 12.
The following does toggles the output
I switched to pinMode() and digitalWrite().
Some code:
pinMode(GPIO_NUM_12,OUTPUT);
delay(200);
while (1) {
digitalWrite(12, HIGH); // sets the digital pin 13 on
delay(1000); // waits for a second
digitalWrite(12, LOW); // sets the digital pin 13 off
delay(1000); // waits for a second
}
The RTC_GPIO functions do not work! Am I missing something setting up to use these RTC Functions?
I need to be able to wake up from Deep Sleep using RTC_GPIO inputs.
What am I missing?
I have not tried to use the pinMode and digitalWrite in my code base to get inputs from Reed Switch. That's next.
RTC GPIO Functions Not Working
Re: RTC GPIO Functions Not Working
Why are you calling rtc_gpio_deinit instead of rtc_gpio_init
-
- Posts: 12
- Joined: Tue Sep 14, 2021 6:39 pm
Re: RTC GPIO Functions Not Working
I am specifying the GPIO pin as a digital input, not an analog input.I saw this method in some example code on the forum.
I take it I should call rtc_gpio_init.
Will try this.
I take it I should call rtc_gpio_init.
Will try this.
-
- Posts: 12
- Joined: Tue Sep 14, 2021 6:39 pm
Re: RTC GPIO Functions Not Working
I found the function in a esp32 document and the wording indicates it is for analog pin:
esp_err_trtc_gpio_init(gpio_num_tgpio_num)
Init a GPIO as RTC GPIO.
This function must be called when initializing a pad for an analog function.
So I did not think it applied for digital pin.
esp_err_trtc_gpio_init(gpio_num_tgpio_num)
Init a GPIO as RTC GPIO.
This function must be called when initializing a pad for an analog function.
So I did not think it applied for digital pin.
-
- Posts: 12
- Joined: Tue Sep 14, 2021 6:39 pm
Re: RTC GPIO Functions Not Working
I tried rtc_gpio_init().
I still do not get an output.
I also called the function to see if GPIO_NUM_12 was an RTC GPIO. It returned TRUE.
Stuck on this one.
I still do not get an output.
I also called the function to see if GPIO_NUM_12 was an RTC GPIO. It returned TRUE.
Stuck on this one.
Re: RTC GPIO Functions Not Working
Hello @slaughterjim
since you are using Arduino. May I ask why you are trying to use any of the gpio* functions directly? What am I missing here?
I suggest you check out this example on how to setup deep sleep using Arduino functions: https://randomnerdtutorials.com/esp32-d ... p-sources/?
Thanks
Felix
Hardware being used is a Heltec Lora 32(V2) board under Arduino.
since you are using Arduino. May I ask why you are trying to use any of the gpio* functions directly? What am I missing here?
I suggest you check out this example on how to setup deep sleep using Arduino functions: https://randomnerdtutorials.com/esp32-d ... p-sources/?
Thanks
Felix
-
- Posts: 12
- Joined: Tue Sep 14, 2021 6:39 pm
Re: RTC GPIO Functions Not Working
The Arduino functions seemed like the way to go. I have never gotten the inputs or my output test to work.
I switched to pinMode(). I am able to generate a GPIO (pin 12) wakeup from deep sleep.
Things go bad after this first wakeup, but I am working that issue.
I am reading the document that was referenced. Thanks.
I switched to pinMode(). I am able to generate a GPIO (pin 12) wakeup from deep sleep.
Things go bad after this first wakeup, but I am working that issue.
I am reading the document that was referenced. Thanks.
-
- Posts: 12
- Joined: Tue Sep 14, 2021 6:39 pm
Re: RTC GPIO Functions Not Working
When I wake from esp_deep_sleep_start() using ext0, what do I need to do in my code?
Do I need to do a pinMode again? Do I need to enable pullup's again?
Initial setup I am using:
pinMode(GPIO_NUM_12,INPUT_PULLUP);
pinMode(GPIO_NUM_13,INPUT_PULLUP);
I determine the wakeup source and go process either GPIO 12 or GPIO 13. Only 1 GPIO will wake up so I am using ext0 since I need a LOW (going HIGH to LOW).
esp_sleep_enable_ext0_wakeup(GPIO_NUM_12, LOW);
I can wake up once correctly. Seems I am not setting something before I go back to sleep?
I cannot find anything in the document that was specified in previous response.
Thanks.
Do I need to do a pinMode again? Do I need to enable pullup's again?
Initial setup I am using:
pinMode(GPIO_NUM_12,INPUT_PULLUP);
pinMode(GPIO_NUM_13,INPUT_PULLUP);
I determine the wakeup source and go process either GPIO 12 or GPIO 13. Only 1 GPIO will wake up so I am using ext0 since I need a LOW (going HIGH to LOW).
esp_sleep_enable_ext0_wakeup(GPIO_NUM_12, LOW);
I can wake up once correctly. Seems I am not setting something before I go back to sleep?
I cannot find anything in the document that was specified in previous response.
Thanks.
-
- Posts: 12
- Joined: Tue Sep 14, 2021 6:39 pm
Re: RTC GPIO Functions Not Working
Ok I found this function esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_AUTO);
Will try it.
Will try it.
Who is online
Users browsing this forum: Majestic-12 [Bot] and 95 guests