Wake from Sleep on Touch Input

Give it a try, it costs you nothing !
Post Reply
SteanX
Posts: 39
Joined: Sat Jun 19, 2021 10:33 pm
Has thanked: 17 times
Been thanked: 6 times

Wake from Sleep on Touch Input

Post by SteanX »

Would be awesome if wake on touch input could be included sometime in the future?

I would think modifying SLEEP value [, pin, level] so that level could be either 0,1 (as before) or the threshold (as in the touchAttachInterrupt(pin, callback, Threshold) ESP-Arduino function). It would be even more awesome if BAS.RESETREASON could reflect ESP_SLEEP_WAKEUP_TOUCHPAD and also perhaps if there were a function or a BAS variable that could tell you which pin caused the wakeup, either touch or otherwise?

Of course, just a request and only if you consider it useful and have the time :-)
SteanX
Posts: 39
Joined: Sat Jun 19, 2021 10:33 pm
Has thanked: 17 times
Been thanked: 6 times

Re: Wake from Sleep on Touch Input

Post by SteanX »

So, in addition to wake from touch, I've encountered a situation where I could also benefit from wake on multiple RTC pins. I found a nice article on this topic at https://lastminuteengineers.com/esp32-d ... up-sources with some code examples using Arduino IDE. While that is useful, of course I'd much prefer to do this from Annex32.

Seeing that my previous feature request for wake on touch did not manage to elicit even a single comment, it's obviously not something that many people thought might be useful. Being able to wake from multiple pins might perhaps be of more value? :-)

As always, of course it is just a request and totally subject to whether you consider it to be useful enough to spend time on? But it would make my day for battery projects...
User avatar
cicciocb
Site Admin
Posts: 2060
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1358 times
Contact:

Re: Wake from Sleep on Touch Input

Post by cicciocb »

HI StanX,
unfortunately the activity on the forum is not really significative and not valuable to have a real feedback.

I'll try to implement this in a next release
SteanX
Posts: 39
Joined: Sat Jun 19, 2021 10:33 pm
Has thanked: 17 times
Been thanked: 6 times

Re: Wake from Sleep on Touch Input

Post by SteanX »

Thanks Francesco, much appreciated!
User avatar
cicciocb
Site Admin
Posts: 2060
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1358 times
Contact:

Re: Wake from Sleep on Touch Input

Post by cicciocb »

I've just updated the version 1.52.2 for the ESP32 that contains the syntax changes as you suggested for the capacitive touch.

In the command SLEEP value [, pin, level], if level > 1 this will enable the capacitive touch with "level" representing the threshold value.

In addition, I included a new function, BAS.WAKEUPREASON that returns the cause of the wakeup from deep sleep.

This is an extract of the coming help:
SLEEP value [, pin, level]
Optionally, this command can be also used to wake up the module using the capacitive touch on an input pin.
In this case the command SLEEP maintains the same syntax but level defines the threshold value for the pin.
Only the following pins can be used for that purpose (capacitive touch) : 0, 2, 4, 12, 13, 14, 15, 27 32, 33
Level must be > 1 to enable the touch (0 and 1 are reserved for the wake up on Low or Wake up on High).
Example
' Sleeps for 3600 seconds (1 Hour) or until the pin 15 is touched
SLEEP 3600, 15, 40 ' Threshold at 40



BAS.WAKEUPREASON
Returns the reason for the wake up if the module was in deep sleep
The reason is defined in the table below
VALUE | REASON
------------------
0 Unknown
1 N/A
2 EXT0 - Input Pin
3 EXT1
4 Timer
5 Touch - Touch pin
6 ULP
7 GPIO (in light sleep only)
8 UART (in light sleep only)
9 WIFI (in light sleep only)
10 COCPU interrupt
11 COCPU crash
12 BT (in light sleep only)
SteanX
Posts: 39
Joined: Sat Jun 19, 2021 10:33 pm
Has thanked: 17 times
Been thanked: 6 times

Re: Wake from Sleep on Touch Input

Post by SteanX »

That is awesome Francesco, thank you so much. I will try and test tomorrow and provide feedback?

You also never fail to whet my appetite ey :
6 : ULP!!!

You must know what I am going to be asking for next :-) :-)

Thanks so much for your efforts!
SteanX
Posts: 39
Joined: Sat Jun 19, 2021 10:33 pm
Has thanked: 17 times
Been thanked: 6 times

Re: Wake from Sleep on Touch Input

Post by SteanX »

OK, so I was too tempted to wait, so quickly flashed a classic ESP32 with this firmware and tested.
Works great :D. Thanks Francesco!
Willi55
Posts: 21
Joined: Mon Apr 12, 2021 4:57 pm
Has thanked: 14 times
Been thanked: 1 time

Re: Wake from Sleep on Touch Input

Post by Willi55 »

Is it conceivable to also make this function available for the ESP32-S2.
This function would be very helpful for my current project.
Post Reply