Having set a pin as a Touch input, how do I turn that OFF?

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
ellisjr
Posts: 23
Joined: Sun May 17, 2020 8:30 pm

Having set a pin as a Touch input, how do I turn that OFF?

Post by ellisjr » Sat Apr 17, 2021 2:08 pm

So, I have a touch pin that works well, but to save power, I want to turn it off, i.e. turn it back to an unassigned pin, or anything really to stop the ESP32 wasting power putting the touch sense signals on that pin.

Whatever I do seems to cause the touch pin to trigger and so immediately wake up my ESP32 from deepsleep:
  • I have tried setting the variable to which I assigned the TouchPad() to None.
  • I have tried assigning that pin as an INPUT
  • I have tried assigning that pin an OUTPUT
However, it seems, once a TouchPad, always a TouchPad, which I'm sure is a common scenario, but as usual, I want to do something different :roll:

Any thoughts, anyone? Hopefully I've missed something simple.
John Ellis
What cannot go wrong, will. What definitely cannot go wrong absolutely will... :roll:

Online
karfas
Posts: 18
Joined: Sat Jan 16, 2021 12:53 pm

Re: Having set a pin as a Touch input, how do I turn that OFF?

Post by karfas » Sat Apr 17, 2021 6:51 pm

You can't in current micropython.

In ports/esp32/machine_touchpad.c I find in mtp_make_new()

Code: Select all

   static int initialized = 0;
    if (!initialized) {
        touch_pad_init();
        touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER);
        initialized = 1;
    }
However, nowhere I can find the corresponding touch_pad_deinit() - which, I assume, will turn off the touch function according to https://docs.espressif.com/projects/esp ... ad_deinitv

Maybe you should report a bug.

Regards,

Thomas

ellisjr
Posts: 23
Joined: Sun May 17, 2020 8:30 pm

Re: Having set a pin as a Touch input, how do I turn that OFF?

Post by ellisjr » Sat Apr 17, 2021 7:02 pm

Ah, OK, yes. Will do. At least I haven't missed something obvious! :lol:

Thanks for the pointer to the underlying code.
John Ellis
What cannot go wrong, will. What definitely cannot go wrong absolutely will... :roll:

Online
karfas
Posts: 18
Joined: Sat Jan 16, 2021 12:53 pm

Re: Having set a pin as a Touch input, how do I turn that OFF?

Post by karfas » Tue Apr 20, 2021 12:17 am

Found (by accident) the esp32.wake_on_touch() function.
Maybe wake_on_touch(False) will at least suppress the wake-up, even when it doesn't completely disables the touch sensors?

ellisjr
Posts: 23
Joined: Sun May 17, 2020 8:30 pm

Re: Having set a pin as a Touch input, how do I turn that OFF?

Post by ellisjr » Sun Apr 25, 2021 12:48 pm

I will try this out as soon as I can... thanks!
John Ellis
What cannot go wrong, will. What definitely cannot go wrong absolutely will... :roll:

Post Reply