-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Conversation
Very good, @P-R-O-C-H-Y !! I liked it! |
#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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
@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. |
@SuGlider Docs updated with the note. |
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 |
Seems like it got it to work using the manual installation process: https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html |
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