Skip to content

Add touch sleep wakeup API #7439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 9, 2022
Merged

Conversation

P-R-O-C-H-Y
Copy link
Member

@P-R-O-C-H-Y P-R-O-C-H-Y commented Nov 7, 2022

Description of Change

As reported in the issue #7431 , the example DeepSleep/TouchWakeUp.ino is not working for ESP32-S2 and ESP32-S3. For these chips setting touch pad as wake up source needs different calls than ESP32.
So this new function works with all chips.
void touchSleepWakeUpEnable(uint8_t pin, touch_value_t threshold);

I have updated the example to work using this new function and made it work on all chips + updated docs.

Tests scenarios

Tested on ESP32, ESP32-S2 and ESP32-S3 with the updated TouchWakeUp.ino example.

Related links

Closes #7431

@P-R-O-C-H-Y P-R-O-C-H-Y added the Area: Peripherals API Relates to peripheral's APIs. label Nov 7, 2022
@P-R-O-C-H-Y P-R-O-C-H-Y requested a review from SuGlider November 7, 2022 13:50
@P-R-O-C-H-Y P-R-O-C-H-Y self-assigned this Nov 7, 2022
@VojtechBartoska VojtechBartoska added this to the 2.0.6 milestone Nov 7, 2022
@SuGlider
Copy link
Collaborator

SuGlider commented Nov 8, 2022

Very good, @P-R-O-C-H-Y !! I liked it!

@VojtechBartoska VojtechBartoska added the Status: Pending Merge Pull Request is ready to be merged label Nov 8, 2022
#define THRESHOLD 30000 /* Lower the value, more the sensitivity */
#else //CONFIG_IDF_TARGET_ESP32S3 + default for other chips (to be adjusted) */
#define THRESHOLD 80000 /* Lower the value, more the sensitivity */
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested it and it works better with this setup:

ESP32 -> Threshold = 40
S2/S3 -> Threshold = 1000

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For ESP32 we do have threshold 40.
But for S2/S3 it cannot be that small. Normal reading is higher that this value.
For S2 if the pad is touched, reading from touchRead is above 45k. For S3 its above 95k

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is actually the delta, not the reading value itself.
It worked better (faster when touching the S2/S3 pad) when I changed it to 1,000
You can try it to check it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested that a bit now, and managed to change it to 5000. That worked the best for me.
The 1000 was too much sensitive. I have attached the Dupont cable to the pin and it triggered even if I touched the rubber part of the cable, not the wire.
The 5000 triggers immediately I touch the wire :)

//Configure Touchpad as wakeup source
esp_sleep_enable_touchpad_wakeup();
//Setup sleep wakeup on Touch Pad 3 (GPIO15 for ESP32) / (GPIO3 for ESP32-S2 and S3)
touchSleepWakeUpEnable(T3,THRESHOLD);
Copy link
Collaborator

@SuGlider SuGlider Nov 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested it adding 2 touch pin to the sketch:

touchSleepWakeUpEnable(T2,THRESHOLD);
touchSleepWakeUpEnable(T7,THRESHOLD);

ESP32 wakes up with both and reports the right pin.
S2/S3 only wakes up with the last Touch Pad used in touchSleepWakeUpEnable(), in the example above, it means the the SoC only wakes up when touching GPIO7.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add more pins for wakeup to the example?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe... when it is an ESP32 only. Just to demonstrate it?!
Also, maybe, add commentaries about the limitation for the S2/S3 in the sketch?
Just a few suggestions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added both :)

  • Demontration for ESP32
  • Comment in header about limitation

@SuGlider
Copy link
Collaborator

SuGlider commented Nov 8, 2022

@P-R-O-C-H-Y - It seems there is a problem with S2/S3 when the sketch uses more than 1 touchpad for waking up. It works fine with ESP32, but not with S2/S3.

@P-R-O-C-H-Y
Copy link
Member Author

@P-R-O-C-H-Y - It seems there is a problem with S2/S3 when the sketch uses more than 1 touchpad for waking up. It works fine with ESP32, but not with S2/S3.

@SuGlider I think S2/S3 can have only 1 touchpad for waking up. I have read about that in IDF docs. Maybe will be good if thats true to add a note in our docs too.

@P-R-O-C-H-Y
Copy link
Member Author

@SuGlider Link to docs link

@SuGlider
Copy link
Collaborator

SuGlider commented Nov 8, 2022

@SuGlider Link to docs link

Correct, I see that. This is valid for the S2 and S3. Please add a note to the documentation. Thanks!

@P-R-O-C-H-Y
Copy link
Member Author

@SuGlider Docs updated with the note.

@SuGlider SuGlider merged commit 7a76ade into espressif:master Nov 9, 2022
@rubenfrolic
Copy link

How do I get this to work in Arduino IDE? I tried to find a 2.0.5 dev version of the core. but can't find it. But need to update the core for this to work

@rubenfrolic
Copy link

Seems like it got it to work using the manual installation process: https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html

@P-R-O-C-H-Y P-R-O-C-H-Y deleted the Touch_sleep_wakeup branch November 16, 2022 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Peripherals API Relates to peripheral's APIs. Status: Pending Merge Pull Request is ready to be merged
Projects
Development

Successfully merging this pull request may close these issues.

ESP32-S3 touch wake up from deep sleep problem
5 participants