Close

ESP32, MicroPython, TTP223 GPIOs and deepsleep

A project log for MicroPython on T-Wristband (Lilygo / TTGO)

Making all the features of T-Wristband work in MicroPython

aryaArya 04/05/2020 at 19:290 Comments

When you refer to the T-Wristband schematic, you'll see that not only the touch button (GPIO33) is controlled by a separate TTP223 chip (and not ESP32 built-in touch peripheral), but the TTP223 chip is also powered from an ESP32 GPIO. This means you need to make the "TTP223 power" GPIO (25) into an output and make sure it's still an output during deepsleep. How to do this in MicroPython? Here's a minimal example:

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

touch_en_p = 25
touch_p = 33

touch = Pin(touch_p, Pin.IN)
Pin(touch_en_p, Pin.OUT, Pin.PULL_HOLD, value=1)

esp32.wake_on_ext0(pin=touch, level=esp32.WAKEUP_ANY_HIGH)
print("Will sleep in 5 seconds")
sleep(5)
print("Going to sleep")
deepsleep() 

The PULL_HOLD and value=1 are what's responsible for the "make sure the TTP223 stays powered on" task.

Discussions