Page 1 of 1

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

Posted: Sat Apr 17, 2021 2:08 pm
by ellisjr
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.

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

Posted: Sat Apr 17, 2021 6:51 pm
by karfas
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

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

Posted: Sat Apr 17, 2021 7:02 pm
by ellisjr
Ah, OK, yes. Will do. At least I haven't missed something obvious! :lol:

Thanks for the pointer to the underlying code.

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

Posted: Tue Apr 20, 2021 12:17 am
by karfas
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?

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

Posted: Sun Apr 25, 2021 12:48 pm
by ellisjr
I will try this out as soon as I can... thanks!