10PCS TTP223 Capacitive Touch Switch β€” Self-Locking Buttons for ESP32 (Touch Dimmer)

Pack of 10 Γ— TTP223 capacitive touch switch modules with self-locking (latch) behaviour. Perfect for touch-controlled lighting panels, dimmers, smart-home panels and ESP32/Arduino projects.


10PCS TTP223 Capacitive Touch Switch Self Locking Button Module ESP32


Possible Uses & Project Ideas


1-Image Wiring Diagram

Simple wiring showing one touch module controlling a MOSFET-driven LED strip via ESP32 PWM. For mains lighting use a proper dimmable driver and qualified wiring.

TTP223 Touch Module VCC GND OUT ESP32 Dev Board 3.3V GND GPIO14 (touch IN) GPIO16 (PWM β†’ MOSFET Gate) MOSFET Gate ← GPIO16 LED Strip 5V β†’ +5V, GND β†’ GND, DIN β†’ (if applicable) Note: For mains lighting use a proper dimmable driver and qualified mains wiring.

ESPHome Dimmer (Short press = toggle, Long press = dim/brighten)

Paste the following into an ESPHome device YAML (ESP32). This example uses a touch module on GPIO14 and a PWM output on GPIO16 to drive a MOSFET / LED driver. It implements short/long press logic: short press toggles light; long press ramps brightness while held.

ESPHome YAML β€” Touch Dimmer
esphome:
  name: touch_dimmer
  platform: ESP32
  board: esp32dev

wifi:
  ssid: "YOUR_SSID"
  password: "YOUR_PASSWORD"

logger:
api:
ota:

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO14
      mode: INPUT
    name: "Touch Button"
    id: touch_btn
    filters:
      - delayed_on: 10ms
      - delayed_off: 10ms

# PWM output as light
output:
  - platform: ledc
    pin: GPIO16
    id: pwm_output
    frequency: 1000 Hz
    channel: 0

light:
  - platform: monochromatic
    name: "Touch Dimmer Light"
    output: pwm_output
    id: dimmer_light
    default_transition_length: 0s

globals:
  - id: press_start
    type: unsigned long
    restore_value: no
    initial_value: '0'
  - id: long_press_ms
    type: int
    restore_value: no
    initial_value: '600'   # ms threshold for long press

# Interval check to implement short vs long press behavior
interval:
  - interval: 100ms
    then:
      - lambda: |-
          bool pressed = id(touch_btn).state;
          static bool was_pressed = false;
          static bool long_mode = false;
          static int ramp_dir = 1;

          if (pressed && !was_pressed) {
            id(press_start) = millis();
            long_mode = false;
          } else if (!pressed && was_pressed) {
            unsigned long duration = millis() - id(press_start);
            if (duration < id(long_press_ms)) {
              // short press β€” toggle
              if (id(dimmer_light).state) {
                id(dimmer_light).turn_off();
              } else {
                id(dimmer_light).turn_on();
                // ensure brightness at least 50% when turning on
                id(dimmer_light).turn_on().set_level(0.5);
              }
            } else {
              // released after long press β€” stop ramping
              long_mode = false;
            }
          }

          // if held long enough, enter ramp mode
          if (pressed && (millis() - id(press_start) > id(long_press_ms))) {
            long_mode = true;
          }

          // ramp logic when in long_mode and light is ON
          if (long_mode && id(dimmer_light).state) {
            float lvl = id(dimmer_light).current_values.get_brightness(); // 0..1
            // direction alternates at endpoints
            if (lvl >= 0.98) ramp_dir = -1;
            if (lvl <= 0.02) ramp_dir = 1;
            lvl += ramp_dir * 0.01; // step
            if (lvl < 0) lvl = 0;
            if (lvl > 1) lvl = 1;
            id(dimmer_light).turn_on().set_level(lvl);
          }

          was_pressed = pressed;
  

Notes: - Adjust long_press_ms and ramp speed to taste. - This YAML requires ESPHome release with ledc LEDC output (ESP32). For ESP8266 adapt to pwm output.


WLED Touch-Dimmer Integration

Below are two practical ways to integrate touch buttons with WLED:

  1. Home Assistant bridge (recommended if you use Home Assistant)
    - Add the ESPHome device (above) to Home Assistant. It exposes light.touch_dimmer_light. - Create automations or use a direct script to call the WLED light (via light.turn_on with brightness) whenever the ESPHome dimmer changes level or when long-press ramp events occur. - Advantages: reliable, uses Home Assistant service calls (no custom HTTP code).
  2. Direct HTTP/MQTT calls to WLED (no Home Assistant)
    - WLED supports a JSON HTTP API and MQTT. From ESPHome you can:
    • Use the http_request component (ESPHome) to POST JSON to http://WLED_IP/json/state to set "on":true and "bri":N where N is 0–255.
    • Or publish to the WLED MQTT topic to set brightness (configure WLED MQTT first).
    - Example ESPHome snippet (HTTP) β€” call HTTP request on brightness change:
    # (Pseudo-example) Use ESPHome http_request to set WLED brightness
    # Replace WLED_IP and port as needed. See WLED docs for exact endpoint details.
    http_request:
      useragent: esphome-touchdimmer
    
    # In automations: call a lambda to run an http_request.post with JSON payload:
    # {"on":true,"bri":128}
    
    - Note: exact HTTP endpoint and JSON schema depend on WLED version; prefer Home Assistant bridge for simplicity unless you are familiar with WLED API.

Quick Arduino / FastLED Note

If you run a custom FastLED sketch on the ESP32 (no WLED), the ESPHome dimmer approach can be adapted: read the TTP223 input and implement short/long press logic in your sketch to call FastLED.setBrightness() or update PWM output.


What’s Included


Item Specifics


Shipping & Returns


Safety & Final Notes

Compact, reliable touch buttons β€” excellent value for building modern touch panels and smart-lighting interfaces.