Introduction to the TTP223 Capacitive Touch Module for Arduino

Introduction to the TTP223 Capacitive Touch Module for Arduino

In this tutorial, we will explore the TTP223 capacitive touch module and how it can be integrated with an Arduino to create a touch-sensitive switch. The TTP223 is a simple and effective module that allows you to turn on or off devices such as relays or lights with just a touch. This project will demonstrate how to connect the module and write a basic Arduino program to read touch inputs and control an output device. The code and wiring for this project will be explained in detail so that you can replicate the setup easily. For visual learners, I recommend watching the associated video tutorial for clarification on the setup and coding process (in video at 03:15).

Hardware Explained

The TTP223 capacitive touch module is a compact and easy-to-use device that detects touch inputs through capacitive sensing. It has a single output pin that goes high when the touch is detected, making it ideal for applications where you want to control electronics with a simple touch. The module operates at a supply voltage of 2.0 to 5.5 volts, which makes it compatible with most Arduino boards. The module typically has a few pins: VCC for power, GND for ground, and the output pin that sends a signal when a touch is detected. This output pin can be connected to a digital input pin on the Arduino, allowing you to read the touch status easily. The TTP223 module is especially useful in projects where a physical switch is not desirable.

Datasheet Details

ManufacturerSeeed Studio
Part numberTTP223
Logic/IO voltage2.0 – 5.5 V
Supply voltage2.0 – 5.5 V
Output current20 mA max
Peak current30 mA
Operating temperature-40 to 85 °C
PackageTO-220

  • Ensure proper voltage supply (2.0 – 5.5 V) to avoid damaging the module.
  • The output pin can be connected to any digital pin on the Arduino.
  • Connect the GND pin to the Arduino ground.
  • Keep the module away from sources of electrical noise to avoid false triggering.
  • Use pull-up resistors if necessary for stable readings.

Wiring Instructions

To wire the TTP223 capacitive touch module to your Arduino, start by connecting the VCC pin on the module to the 5V pin on the Arduino. Next, connect the GND pin on the module to one of the GND pins on the Arduino. The output pin of the TTP223, which sends the touch signal, should be connected to a digital pin on the Arduino, for example, pin 2. If you are using a relay with the touch module, connect the relay control pin to another digital pin, such as pin 8. Ensure that the relay's power supply is connected correctly, as per its specifications. If you are using multiple touch modules, you can connect additional output pins to other digital pins on the Arduino and repeat the wiring process accordingly.

Code Examples & Walkthrough

The following code snippet initializes the pins and sets up the serial communication. The variable touchPin is connected to the output of the TTP223 module, while relayPin controls the relay.

int touchPin = 2; // connect output from TTP223 to this
int relayPin = 8; // Connected to relay

void setup() {
  Serial.begin(9600);
  pinMode(touchPin, INPUT); 
  pinMode(relayPin, OUTPUT);
}
This code initializes the touch module and relay pin, preparing them for use in the loop function. The Serial.begin(9600) command sets the baud rate for serial communication, allowing you to monitor the touch status via the Serial Monitor. In the loop, the program checks the status of the touch input and toggles the relay accordingly. If the touch is detected, it prints "Touched" to the Serial Monitor and turns the relay on.

void loop() {
  val = digitalRead(touchPin); 
  if(val == 1) {
    Serial.println("Touched");
    digitalWrite(relayPin, LOW); // turn relay ON
  }
  delay(100);
}
This excerpt demonstrates how the touch input is read and processed. The digitalRead(touchPin) function checks if the touch has been detected. If it has, the relay is activated by setting relayPin to LOW.

Demonstration / What to Expect

When you run the code and touch the TTP223 module, you should see "Touched" printed in the Serial Monitor, indicating that the touch was detected. The relay connected to relayPin will also activate, allowing you to control any device connected to it. Be mindful of the debounce effect; if you touch the sensor too quickly, it may register multiple touches. For a more complex setup, you can add multiple TTP223 modules to control different devices. Each module can be wired to a separate input pin and managed in the same loop function, allowing for versatile control of multiple outputs (in video at 10:45).

Video Timestamps

  • 00:00 - Introduction to the TTP223 Module
  • 03:15 - Wiring Instructions
  • 05:30 - Code Walkthrough
  • 10:45 - Demonstration of the Touch Module
8-The source code for the TTP223 touch module for Arduino
Язык: C++
9-The source code for the TTP223 touch module for Arduino for a two-touch module
Язык: C++
Скопировано!

Ресурсы и ссылки

Ресурсов пока нет.

Файлы📁

Нет доступных файлов.