Wemos Mini and a TTP223 Capacitive Touch Sensor

In this example we will connect a TTP223 Capacitive Touch Sensor to our Wemos Mini. The TTP223 is a touch pad detector IC which offers 1 touch key.

ttp223

About the TTP223

The TTP223 is a touch pad detector IC which offers 1 touch key. The touching detection IC is designed for replacing traditional direct button key with diverse pad size. Low power consumption and wide operating voltage are the contact key features for DC or AC application.

FEATURES

Operating voltage 2.0V~5.5V
Operating current @VDD=3V, no load, SLRFTB=1
At low power mode typical 1.5uA, maximum 3.0uA
At fast mode typical 3.5uA, maximum 7.0uA
@VDD=3V, no load, SLRFTB=0
At low power mode typical 2.0uA, maximum 4.0uA
At fast mode typical 6.5uA, maximum 13.0uA
The response time max about 60mS at fast mode, 220mS at low power mode @VDD=3V
Sensitivity can adjust by the capacitance(0~50pF) outside
Have two kinds of sampling length by pad option(SLRFTB pin)
Stable touching detection of human body for replacing traditional direct switch key
Provides Fast mode and Low Power mode selection by pad option(LPMB pin)
Provides direct mode、toggle mode by pad option(TOG pin)
Open drain mode by bonding option, OPDO pin is open drain output,
Q pin is CMOS output
All output modes can be selected active high or active low by pad option(AHLB pin)
Have the maximum on time 100sec by pad option(MOTB pin)
Have external power on reset pin(RST pin)
After power-on have about 0.5sec stable-time, during the time do not touch the key pad,
And the function is disabled
Auto calibration for life
And the re-calibration period is about 4.0sec, when key has not be touched

Parts List

Here are the parts I used

Name Links
Wemos Mini
TTP223
Connecting cables

 

Connection

The TTP223 Capacitive Touch Sensor has to be connected to Wemos Mini as follows:

Vcc to 3v3
Gnd to Gnd
SIG to digital pin 0

 

Code

 

#define touchPin D0 // Pin for capactitive touch sensor
 
void setup() 
{
  Serial.begin(9600); 
  pinMode(touchPin, INPUT);
}
 
void loop() 
{
  int touchValue = digitalRead(touchPin);
  if (touchValue == HIGH)
  {
    Serial.println("TOUCHED");
  }
  else
  {
    Serial.println("not touched");
  } 
  delay(500);
  
}

 

 

Testing

Open the serial monitor and touch the sensor

not touched
not touched
TOUCHED
TOUCHED
TOUCHED
not touched
not touched
TOUCHED
TOUCHED
not touched
not touched