Home

Awesome

MicroPython TTP223

Using a TTP223 1-key capacitive touch module with MicroPython.

I was going to write a driver for this module, but it's pretty much just a drop in replacement for a push button. No driver needed.

The module features 3 pins, VCC, I/O and GND and has a red LED which illuminates when a touch is detected and the I/O pin goes HIGH.

It's sensitive enough to detect my finger around 3mm away from the touch pad.

demo

Examples

Basic usage

from machine import Pin
import time

d3 = Pin('D3', Pin.IN, Pin.PULL_DOWN)

while True:
    print(d3.value())
    time.sleep_ms(100)

Using interrupts

from machine import Pin

d3 = Pin('D3', Pin.IN, Pin.PULL_DOWN)
d4 = Pin('D4', Pin.IN, Pin.PULL_DOWN)

def touch(pin):
    print('Touched {}'.format(pin.name()))

d3.irq(touch, Pin.IRQ_FALLING)
d4.irq(touch, Pin.IRQ_FALLING)

Trigger mode

There are 2 pads A and B which can be bridged with a dab of solder to change the trigger mode.

Pad APad BDescription
OpenOpenMomentary, High TTL level output (default)
ShortOpenMomentary, Low TTL level output
OpenShortLatching, High TTL level output
ShortShortLatching, Low TTL level output

Parts

Connections

STM32F407VET6TTP223 Capacitive Touch Module
3V3 (or 5V)VCC
D3 (any pin)I/O
GNDGND

Links

License

Licensed under the MIT License.