ESP32 module, wake_on_touch, wake_on_ext1

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
tahouse
Posts: 1
Joined: Mon Aug 20, 2018 8:07 pm

ESP32 module, wake_on_touch, wake_on_ext1

Post by tahouse » Mon Aug 20, 2018 8:28 pm

Hi there,

I'm running MicroPython v1.9.4-409-g434975def and have successfully used a Pin irq to wake from deep sleep and can confirm the wake reason:

[code]
import machine
from machine import Pin, TouchPad, deepsleep
import time

wake = Pin(14, mode = Pin.IN, pull = Pin.PULL_DOWN)
wake.irq(trigger=Pin.WAKE_HIGH, wake = machine.DEEPSLEEP)

time.sleep(5)
deepsleep(5*1000)
[/code]

after bringing Pin 14 line up to 3V3
[code]
Reset cause: DEEPSLEEP_RESET
Wake reason: PIN_WAKE/EXT0_WAKE
[/code]

Now I'm trying to do the same but with a TouchPad input:

[code]

from machine import Pin, TouchPad, deepsleep
import time
import esp32

wake = Pin(14, mode = Pin.IN)
touch = TouchPad(wake)
touch.config(500)
esp32.wake_on_touch(True)

time.sleep(5)
deepsleep(5*1000)
[/code]
(after 5 seconds and touching/untouching wire to Pin 14)
[code]
Reset cause: DEEPSLEEP_RESET
Wake reason: TIMER_WAKE
[/code]

The range of my touch.read() values are around 700 when untouched, and down to around 100 when touched. I've tried adjusting the touch.config to various settings but I cannot get my ESP32 to wake from touch.. only from timer in this mode.

Lastly,
I've tried using wake_on_ext1
[code]
import machine
from machine import Pin, TouchPad
import time
import esp32
wake = Pin(14, mode = Pin.IN, pull = Pin.PULL_DOWN)
esp32.wake_on_ext1(pins = [wake], level = Pin.WAKE_HIGH)

time.sleep(5)
deepsleep(5*1000)
[/code]

But this resets immediately regardless of whether I bring Pin 14 high or not (not in touch mode, mind you).
[code]
Reset cause: DEEPSLEEP_RESET
Wake reason: EXT1_WAKE
[/code]

I've browsed through the esp32 module code, but I'm not sure if any of the wake modes work?

Any ideas?

andermutu99
Posts: 18
Joined: Thu Sep 27, 2018 10:19 am

Re: ESP32 module, wake_on_touch, wake_on_ext1

Post by andermutu99 » Fri Nov 02, 2018 10:56 am

Hi;

I am interested in wake up ESP32 from touch pin. Have you found a solution?

Thanks.

andermutu99
Posts: 18
Joined: Thu Sep 27, 2018 10:19 am

Re: ESP32 module, wake_on_touch, wake_on_ext1

Post by andermutu99 » Fri Nov 02, 2018 5:46 pm

andermutu99 wrote:
Fri Nov 02, 2018 10:56 am
Hi;

I am interested in wake up ESP32 from touch pin. Have you found a solution?

Thanks.
I have the same problem that ESP32 resets immediately, however it worked sometimes (I have a video). But now it does not work, and the board resets after deep sleep. Any help is highly appreciated.

import machine
from machine import Pin, TouchPad
import time
import esp32
wake = Pin(4, mode = Pin.IN, pull = Pin.PULL_DOWN)
esp32.wake_on_ext1(pins = [wake], level = Pin.WAKE_HIGH)


time.sleep(5)
machine.deepsleep(10000)

Thanks.

fid
Posts: 1
Joined: Sun Jan 20, 2019 2:33 am

Re: ESP32 module, wake_on_touch, wake_on_ext1

Post by fid » Sun Jan 20, 2019 2:47 am

andermutu99 wrote:
Fri Nov 02, 2018 5:46 pm
andermutu99 wrote:
Fri Nov 02, 2018 10:56 am
Hi;

I am interested in wake up ESP32 from touch pin. Have you found a solution?

Thanks.
I have the same problem that ESP32 resets immediately, however it worked sometimes (I have a video). But now it does not work, and the board resets after deep sleep. Any help is highly appreciated.

import machine
from machine import Pin, TouchPad
import time
import esp32
wake = Pin(4, mode = Pin.IN, pull = Pin.PULL_DOWN)
esp32.wake_on_ext1(pins = [wake], level = Pin.WAKE_HIGH)


time.sleep(5)
machine.deepsleep(10000)

Thanks.
I was looking for information for a few hours about raising from deep sleep using a touch pin. I solved it with your code and by taking out the 10000 in the last line of your code. It now reads: machine.deepsleep()
Here's what I uploaded to the ESP32:

import machine
from machine import Pin, TouchPad
import time
import esp32
wake = Pin(4, mode = Pin.IN, pull = Pin.PULL_DOWN)
esp32.wake_on_ext1(pins = [wake], level = Pin.WAKE_HIGH)

print('Entering Deep Sleep in 10 seconds.')
time.sleep(10)
print('Time is up. Going to sleep')
machine.deepsleep()

I did put ten seconds into the sleep command so I had time to stop the code from running. That way I can upload something else. I don't have any wire attached to the module. I have to touch the actual pin.

Thank you!
fid

tecdroid
Posts: 27
Joined: Thu Apr 08, 2021 6:22 am

Re: ESP32 module, wake_on_touch, wake_on_ext1

Post by tecdroid » Wed Jan 12, 2022 8:08 am

old post, I know..
.. but i was looking for deep sleep mechanisms on esp32 and tried that code (watch one post up)
(in particular, pin 4 pulldown activated, wake_on_ext1 with all high)
directly after machine.deepsleep(), my esp reboots.
does anyone have an idea, why?

marcidy
Posts: 133
Joined: Sat Dec 12, 2020 11:07 pm

Re: ESP32 module, wake_on_touch, wake_on_ext1

Post by marcidy » Wed Jan 12, 2022 9:26 am

deep sleep turns the cpu off, so it must be (re-)started. light sleep does not turn the cpu off. use light sleep if you don't want a restart.

User avatar
karfas
Posts: 193
Joined: Sat Jan 16, 2021 12:53 pm
Location: Vienna, Austria

Re: ESP32 module, wake_on_touch, wake_on_ext1

Post by karfas » Wed Jan 12, 2022 12:48 pm

tecdroid wrote:
Wed Jan 12, 2022 8:08 am
old post, I know..
directly after machine.deepsleep(), my esp reboots.
does anyone have an idea, why?
The problem with old threads (and the code you find there) is, well, they are old :D .

I assume the ESP goes to deep sleep and wakes up immediate - this looks like a reboot.

Maybe you should try to activate wake_on_touch() with the handy function described in https://docs.micropython.org/en/latest/ ... esp32.html ?
A quick google search got me to https://microcontrollerslab.com/micropy ... p-sources/ - there you will also find a touch wakeup example.
A few hours of debugging might save you from minutes of reading the documentation! :D
My repositories: https://github.com/karfas

Post Reply