Why use Serial.println() to configure sleep mode?

Involute
Posts: 10
Joined: Mon Oct 14, 2019 3:22 am

Why use Serial.println() to configure sleep mode?

Postby Involute » Mon Oct 14, 2019 3:35 am

I'm developing some code that I want to put into deep sleep. According to what I've read, the configuration instruction should be as follows:

Code: Select all

Serial.println(esp_deep_sleep_enable_ext0_wakeup((gpio_num_t)RTC_IN, 0));   // 1 = active high, 0 = active low.
In my application RTC_IN is the pin through which I feed a signal from an external RTC which I'll use to awaken the ESP32.

My code compiles, though I haven't tried to run it yet. Why is the configuration instruction supposed to be placed inside a Serial.println() statement? Especially since the command to go to sleep is not placed in a Serial.println(), as expected:

Code: Select all

esp_deep_sleep_start();
Why not just use:

Code: Select all

esp_deep_sleep_enable_ext0_wakeup((gpio_num_t)RTC_IN, 0);   // 1 = active high, 0 = active low.
Which also compiles, btw.

Also, which pins can be used to trigger the wake-up? Thanks for any tips?

boarchuz
Posts: 606
Joined: Tue Aug 21, 2018 5:28 am

Re: Why use Serial.println() to configure sleep mode?

Postby boarchuz » Mon Oct 14, 2019 5:51 am

Its just passing the return value to println() for debugging. Same as

Code: Select all

esp_err_t result;
result = esp_deep_sleep_enable_ext0_wakeup((gpio_num_t)RTC_IN, 0)
Serial.println(result);
You can see the return values here:
https://docs.espressif.com/projects/esp ... pio_num_ti
So if you see anything other than "0" (ie. ESP_OK) then something has gone wrong. If you don't want to see this, you can remove the println() as you noted.
It also happens to list all the RTC pins there so you know which you can use.

Involute
Posts: 10
Joined: Mon Oct 14, 2019 3:22 am

Re: Why use Serial.println() to configure sleep mode?

Postby Involute » Mon Oct 14, 2019 5:55 am

Ah, got it. Thanks.

Who is online

Users browsing this forum: No registered users and 71 guests