Connecting TTP223B Touch Module to Esp8266
In the realm of DIY electronics, adding touch-sensitive controls to your projects can elevate functionality and user experience. One such component, the TTP223B touch module, offers a simple and effective way to incorporate touch sensing into your projects. In this guide, we’ll walk through the process of connecting a TTP223B touch module to a Wemos D1 Mini, a popular and versatile microcontroller board based on the ESP8266.
Understanding the Components
TTP223B Touch Module: This module is a capacitive touch sensor module based on a touch detection IC (TTP223B). It requires minimal external components and offers stable and reliable touch detection.
Wemos D1 Mini: The Wemos D1 Mini is a small yet powerful microcontroller board based on the ESP8266 chipset. It comes with built-in Wi-Fi capabilities, making it ideal for IoT projects and rapid prototyping.
Components Needed
- ESP8266 Development Board (such as NodeMCU) (Affiliate) – https://s.click.aliexpress.com/e/_DD3JQhj
- TTP223B Touch Module (Affiliate) – https://s.click.aliexpress.com/e/_DmHc9F3
- Breadboard and jumper wires (Affiliate) – https://s.click.aliexpress.com/e/_Dl5kuk1
Wiring Diagram
Before we start connecting the components, let’s understand the pinouts of both the TTP223B module and the Wemos D1 Mini:
TTP223B Module Pinout:
- VCC: Power supply (3.3V – 5V)
- GND: Ground
- OUT: Digital output signal (HIGH when touched, LOW when not touched)
Wemos D1 Mini Pinout:
- 3V3: 3.3V power output
- GND: Ground
- D1 (GPIO5): Digital pin for data transmission (can be changed if needed)
Wiring Instructions:
- Connect the VCC pin of the TTP223B module to the 3V3 pin of the Wemos D1 Mini.
- Connect the GND pin of the TTP223B module to any GND pin on the Wemos D1 Mini.
- Connect the OUT pin of the TTP223B module to the D1 (GPIO5) pin of the Wemos D1 Mini.
Code Implementation
// Define the pin for the touch module const int touchPin = D1; // D1 (GPIO5) pin on Wemos D1 Mini void setup() { // Initialize Serial communication for debugging Serial.begin(115200); // Set the touch pin as input pinMode(touchPin, INPUT); } void loop() { // Read the state of the touch pin int touchState = digitalRead(touchPin); // Print the touch state (1 for touched, 0 for not touched) Serial.println(touchState); // Add a small delay to avoid flooding the Serial monitor delay(500); }
Testing the Setup
- Connect your Wemos D1 Mini to your computer via USB.
- Open the Arduino IDE and paste the above code into a new sketch.
- Select the correct board (Wemos D1 Mini) and COM port from the Tools menu.
- Upload the sketch to your Wemos D1 Mini.
- Open the Serial Monitor (Tools > Serial Monitor) to view the output.
Conclusion
You’ve successfully connected a TTP223B touch module to a Wemos D1 Mini and tested its functionality using a simple Arduino sketch. From here, you can integrate touch sensing into your projects, whether it’s controlling LEDs, triggering actions, or any other creative application.