Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Connect the TTP223 module’s VCC to the Raspberry Pi’s 3.3 V pin, GND to a Pi ground pin, and SIG or OUT to a GPIO input such as GPIO17. In Python, read that input with GPIO Zero. Before relying on the result, check whether your particular breakout is configured for active-high or active-low output and for direct or toggle operation: those settings determine what a “pressed” event means.

What the TTP223 does

A TTP223 breakout is a capacitive touch switch. Touching its sensing area changes a digital signal on the module’s output pin; the Raspberry Pi reads that signal as a GPIO input. The Pi does not need to measure capacitance or use an analog-to-digital converter for this basic setup.

A typical module has three connections: VCC for power, GND for ground, and SIG or OUT for the digital signal. Freenove documents a 2.0–5.5 V supply range for its module. That range is a module supply specification, not permission to send a 5 V output into a Raspberry Pi GPIO. The Pi’s GPIO uses 3.3 V logic, so 3.3 V module power is the straightforward choice for a direct connection.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Think of the breakout as translating a touch into a binary state rather than a measurement of how hard or how long someone presses. The GPIO input sees one of two logic levels. Your Python program can react to a transition between those levels, but the meaning of that transition depends on the board’s polarity and mode. Direct mode generally corresponds to a finger being present or removed; toggle mode records a state change and can remain active after the finger has left.

#1 Best Overall
ALAMSCN 20PCS TTP223 Capacitive Touch Switch Button Sensor Module Self Locking for Arduino…
  • The module is based on a touch-sensing IC TTP223 capacitive touch switch module, it allows you to avoid the trouble of conventional push-type buttons.
  • Size: 15*11mm
  • Modes: jog, self-locking
  • Power Supply: 2.5V-5.5V
  • Package Include: 20PCS TTP223 Capacitive Touch Switch Sensor

Parts and pin mapping

You need a Raspberry Pi with its 40-pin header populated, a TTP223 breakout, and three jumper wires. A breadboard can make the connections easier to arrange, but the sensor itself only needs power, ground, and one signal wire. If you also want to demonstrate touch by lighting an LED, add an LED and a suitable current-limiting resistor; Freenove’s project parts list specifies 220 Ω for its LED example.

TTP223 pin Raspberry Pi connection Purpose
VCC 3.3 V, physical pin 1 or 17 Powers the breakout within the documented module range.
GND Any Pi ground, such as physical pin 6 Provides a shared electrical reference.
SIG or OUT GPIO17, physical pin 11, in this example Carries the module’s digital output to a GPIO input.

GPIO17 is the Broadcom (BCM) GPIO number used in code; physical pin 11 is the location on the header. These are two different numbering schemes. Raspberry Pi’s GPIO documentation explains the header and GPIO behavior, including the distinction between GPIO numbers and physical pin positions.

Use the physical pin references only to locate the header connections. In code, the GPIO Zero example below uses the BCM number, 17, not the physical pin number, 11. This distinction is an easy source of mistakes because both numbers are valid ways to describe a pin, but they refer to different numbering systems. If you choose a different GPIO, verify both its BCM name for the program and its physical header location for the wire.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

GPIO Zero is included by default in Raspberry Pi OS according to Raspberry Pi’s hardware documentation, which makes it a convenient starting point for this project. The sensor itself does not require an LED or breadboard. Those are optional additions: a breadboard helps organize the circuit, while an LED gives the software an output to control in addition to printing a message.

Wire the module safely

  1. Power down the Pi before wiring. This reduces the chance of accidentally shorting pins while arranging jumper wires.
  2. Identify the breakout pins from its labels or documentation. Pin order varies between boards, so do not assume that VCC, GND, and SIG appear in a particular left-to-right order.
  3. Connect VCC to Pi 3.3 V. Use physical pin 1 or 17 on a standard 40-pin header.
  4. Connect GND to a Pi ground pin. Physical pin 6 is one example. The sensor and Pi must share ground for the signal to be read correctly.
  5. Connect SIG or OUT to GPIO17. In this example, that is physical pin 11. Leave the GPIO configured as an input; do not connect the output to a Pi power pin.
  6. Check each connection before powering up. Confirm the module’s pin labels, the Pi’s physical pin locations, and that the breakout is powered from 3.3 V for this direct-wiring arrangement.

Take a moment to trace each wire from one end to the other rather than relying on wire color. The important details are the labeled module pin, the Pi’s physical connection, and the GPIO number used in your program. In particular, make sure the signal wire lands on GPIO17’s physical location, pin 11, rather than on a nearby power or ground pin.

There is no need to connect the sensor’s output to an LED or to another GPIO merely to test touch detection. First verify the three-wire input circuit and the Python response. Keeping the first test to power, ground, and signal makes it easier to identify a pin-mapping or configuration problem before adding another component.

Read touch events with GPIO Zero

Raspberry Pi documentation says GPIO Zero is included by default in Raspberry Pi OS. For a breakout configured for direct, active-high operation, use the following program:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from gpiozero import Button
from signal import pause

touch = Button(17, pull_up=False)
touch.when_pressed = lambda: print("Touched")
touch.when_released = lambda: print("Released")
pause()

Run the script while the sensor is connected. Touching the sensing surface should print Touched; removing your finger should print Released. This interpretation assumes the output is high when touched and low while idle, as in Freenove’s common active-high example. The callback names describe GPIO Zero’s logical button state; they do not independently confirm how a board’s configuration pads are set.

The Button object is being used as a convenient digital input, not because the module is a mechanical pushbutton. The callback assignments tell GPIO Zero what to do when it sees the input enter or leave its configured active state. pause() keeps the program running so those callbacks can respond to transitions. If the script starts and immediately reports a touch, or if touching the pad seems to release it, do not assume the sensor is defective: check the active state and output mode first.

Keep the signal wire connected to the input pin named in the program. If you move SIG/OUT from GPIO17 to another GPIO, change the number passed to Button as well. The GPIO Zero constructor uses BCM numbering here, so changing it to the physical header number would not be an equivalent substitution.

Rank #2
5PCS TTP223 Capacitive Touch Switch Module TTP223B Digital Touch Sensor Module Capacitive Touch Sensor Switch
  • Capacitive type touch switch module The module is based on a touch detection IC (TTP223B)'s. Under normal conditions, the module output low, low-power mode to mode; touch of a finger when the corresponding position, the module will output high, the mode is switched to fast mode; when for 12 seconds without touching, the mode and switch to low power mode.
  • For Jog type: the initial state is low, high touch, do not touch is low (similar touch of a button feature)
  • Power supply for 2 ~ 5.5V DC
  • Control Interface: A total of three pins (GND, VCC, SIG), GND to ground, VCC is the power supply, SIG digital signal output pin;
  • Power Indicator: Green LED, power on the right that is shiny;

If the output is active-low

For an active-low breakout, the signal is low in its active state. Set the button’s active state accordingly rather than treating a low signal as idle. For example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from gpiozero import Button
from signal import pause

touch = Button(17, pull_up=True, active_state=False)
touch.when_pressed = lambda: print("Touched")
touch.when_released = lambda: print("Released")
pause()

Here, GPIO Zero treats a low input as the active or pressed state. Check the breakout documentation and its actual output behavior before choosing the polarity; configuration options and labels are not necessarily identical across manufacturers.

Polarity and mode answer different questions. Polarity tells you whether the active state appears as a high or low logic level. Mode tells you whether that state follows the current touch or remains latched until another touch. You may need to account for both at once: an active-low module can also be configured for toggle operation. Choose the GPIO Zero active state to match the polarity, then interpret transitions according to the selected mode.

If the board is in toggle mode

Some TTP223 breakouts can be configured so each touch changes the output state and leaves it there. That is different from direct operation, where the output follows the current touch. In toggle mode, GPIO Zero’s pressed and released callbacks still report input-state transitions, but they do not mean that a finger has just touched or left the pad. Interpret them as changes in the latched output. If your application needs to know whether the user is currently touching the pad, choose direct operation if the breakout supports it.

For example, in direct mode the expected sequence is an active transition when you touch the pad and an inactive transition when you release it. In toggle mode, a touch can cause an active transition that persists after release; a later touch causes the output to change again. A program that assumes every active interval corresponds to a finger physically on the pad will therefore behave differently than intended. Confirm what the board is configured to do before deciding how the application should respond.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Polling instead of callbacks

Callbacks are useful when an action should happen as soon as the input changes. Another approach is to read the GPIO repeatedly and respond to changes in the value. This can make the state-checking logic explicit, especially if the program already has a loop that performs other work. The polling approach still depends on the same wiring, numbering, polarity, and mode checks; it does not solve a mismatched board configuration.

A Raspi.cc project example uses the RPi.GPIO library, BCM numbering, GPIO18 as a sensor input, and GPIO23 as an LED output. Treat that as an illustrative project pattern, not a guarantee that this library is preferred on every current Raspberry Pi OS release. For a polling version, use the GPIO library selected for the installed operating system, configure the chosen sensor pin as an input, and compare its current value with the previous value so the program can detect changes rather than repeatedly acting on an unchanged level.

If you adapt a project that uses GPIO18 and GPIO23, map those BCM numbers to the corresponding physical header positions before moving the wires. Do not copy GPIO17’s physical pin number, 11, into code as though it were a BCM number. The Raspi.cc example illustrates a separate pin choice from the GPIO Zero example in this article, so keep each code example’s wiring and numbering paired together.

Add an LED response

To turn touch into a visible output, connect an LED and a current-limiting resistor in series between an output GPIO and ground, observing the LED’s polarity. Choose a separate GPIO output—for example, GPIO27—and keep the sensor’s SIG connection on GPIO17. The resistor is essential; Freenove’s LED parts list uses 220 Ω for its project. Do not connect an LED directly between a GPIO pin and ground.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

With GPIO Zero, an LED callback can be added to the direct active-high example:

Rank #3
Lonely Binary 12-Pack TTP223 Capacitive Touch Sensor for C++ & ESP32
  • 【PACK OF 12 MODULES】12 TTP223 touch sensor modules for prototyping, repairs, or multiple projects — suitable for hobbyists, makers, and educators.
  • 【GOLD EDITION ENIG FINISH】Immersion gold (ENIG) plating for good conductivity and corrosion resistance. Lead-free, RoHS-compliant manufacturing.
  • 【WIDE VOLTAGE COMPATIBILITY】Supports both 3.3V and 5V MCU systems — works with Raspberry Pi Pico, ESP32, ESP32-S3, and other microcontroller projects.
  • 【CAPACITIVE TOUCH SENSITIVITY】Single-channel TTP223 IC for touch detection — replaces mechanical buttons in IoT devices, smart switches, lamps, and interactive electronics.
  • 【EASY INTEGRATION】Compact size with clear pinouts (VCC, GND, I/O) and low power consumption for DIY applications.
from gpiozero import Button, LED
from signal import pause

touch = Button(17, pull_up=False)
led = LED(27)

touch.when_pressed = led.on
touch.when_released = led.off
pause()

This assumes the sensor’s active state is high and the LED circuit is wired to match GPIO Zero’s LED output behavior. If your sensor is active-low, configure the input’s active state as shown above. If it is in toggle mode, the LED will follow the latched output state rather than the duration of a finger touch.

The LED is an optional output demonstration; it does not change how the TTP223 is read. The sensor stays on an input GPIO, while the LED uses a different GPIO configured as an output. In the example, that means GPIO17 reads the module and GPIO27 controls the LED. Keeping those roles separate makes it easier to diagnose whether a fault is in the sensor input path or the LED output circuit.

Use the resistor in series with the LED, not as a replacement for connecting the LED with the correct polarity. Follow the actual LED’s orientation and the board layout when building the circuit. The source parts list identifies 220 Ω as the resistor value in its LED project, but that is a cited example rather than a universal value for every possible LED and wiring design.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understand polarity and mode before troubleshooting

“TTP223 module” does not identify one universal breakout layout or default configuration. Manufacturer information for the TTP223N family describes selectable output characteristics, and one retailer’s board documentation shows four combinations covering high/low polarity and no-lock/self-lock behavior. Those examples demonstrate why a module’s settings must be verified on the actual board rather than inferred from another product listing.

  • Active-high: the output goes high in its active state. In a direct configuration, that is commonly while the sensing surface is touched.
  • Active-low: the output goes low in its active state. The software’s logical active state must be inverted to match.
  • Direct or no-lock: the output follows the touch state: active while touched and inactive when released.
  • Toggle or self-lock: a touch changes the output, which remains in its new state until another touch changes it again.

Board documentation may use different names for these settings, and solder pads, jumpers, or other configuration features differ by breakout. Inspect the module and its documentation; do not copy a pad-bridging pattern from a visually similar board unless its instructions match.

When inspecting a board, look for its own pin labels and any markings or instructions for configuration pads or jumpers. The TTP223N family information and an individual retailer’s product page show that configuration choices exist, but they do not establish one universal physical layout or default state for all modules. If the module came with a product page or printed guide, use that exact reference to identify how its output is configured.

These characteristics are useful to compare before buying as well as when troubleshooting. A board that clearly labels VCC, GND, and OUT and documents its active level and mode is easier to connect and program than one whose settings are unclear. Check whether the board supports direct/no-lock, toggle/self-lock, or both, and whether those choices are controlled by documented pads or jumpers. The module name alone does not settle these details.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshoot common problems

The program reports touch continuously

  • Check whether the module is active-low while the code assumes active-high, or vice versa.
  • Check whether the breakout is in toggle mode. A latched active output can remain asserted after a touch.
  • Verify that SIG or OUT is connected to the GPIO you configured and that the module’s GND is connected to Pi ground.

Separate the diagnosis into three questions: is the module powered from the intended pin, is the signal reaching the GPIO named in the code, and does the software’s active-state definition match the board? If the wiring is correct but the logical interpretation is reversed, change the input configuration or the board setting rather than moving the wire to a power pin. If the output remains active after a brief touch, check for toggle/self-lock operation before concluding that the sensor is stuck.

Touch events never appear

  • Confirm that VCC and GND are connected to the module’s labeled power pins and that the signal wire is on GPIO17 in this example.
  • Confirm that GPIO17 is configured as an input and that the code uses BCM numbering. The example’s GPIO17 is physical header pin 11; entering 11 in the code would select a different GPIO-numbering interpretation.
  • Check the breakout’s active polarity and mode settings, then adjust the code’s active state or the board configuration to match.
  • Make sure the sensing area is accessible and that the selected connection really is SIG or OUT, not a power pin.

Also verify that the script’s pin choice still matches the physical wire after any changes to the example. If you use GPIO18 or another pin instead, update both the code and the wiring plan. A mismatch can look like a sensor problem even though the program is simply reading a different GPIO.

The GPIO reading appears unreliable

  • Recheck the ground connection and signal-pin mapping.
  • Make sure the signal is connected to an input rather than a power pin or an output configured to drive the line.
  • Check that the module is powered at 3.3 V for this direct Pi connection and that the selected GPIO and physical header pin have not been confused.

Do not mix up a physical header location with a GPIO name while checking the circuit. For the worked example, follow the chain from the module’s SIG/OUT label to physical pin 11, then confirm that the software reads BCM GPIO17. Likewise, follow GND to a Pi ground pin and verify that the power wire is on 3.3 V, not a 5 V pin.

Rank #4
D-FLIFE 100pcs TTP223 Touch Switch Module Capacitive Sensor Switch DIY for Arduino Raspberry Pi
  • 100pcs TTP223 Capacitive Switch Button Module Self-Lock Switch Button Module High Low Level Output
  • TTP223 Capacitive Switch Button Module
  • The power supply of the TTP223 touch switch button module is 2.5 to 5.5V.
  • These TTP223 touch switch button modules are made of CCL with premium quality and long service life.

The module was powered from 5 V

Do not connect its output directly to a Pi GPIO unless you know that the exact breakout circuit limits the signal to a safe level. A module’s allowed supply range does not establish that its output is safe for 3.3 V logic. For the standard direct connection described here, use the Pi’s 3.3 V supply. If the module has already been powered from 5 V, disconnect it and check its specific circuit and documentation before reconnecting SIG to the Pi.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The Freenove guide’s 2.0–5.5 V range describes that module’s supply specification. It should not be generalized to every TTP223 breakout, and it does not remove the need to protect the Pi’s GPIO from an unsafe signal level. For a beginner’s direct connection, powering the module from 3.3 V avoids relying on undocumented output circuitry. Confirm the exact board’s supply and output guidance before using a different arrangement.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What to check when choosing a breakout

Since breakout layouts and configuration options vary, compare the board’s documented details rather than relying on the TTP223 name alone.

  • Pin labels and order: find the module’s VCC, GND, and SIG/OUT labels and confirm their physical order.
  • Supply range: verify the documented operating voltage. The Freenove module is specified for 2.0–5.5 V, but other breakouts may have different documentation.
  • Output polarity: determine whether the active state is high or low and set the software to match.
  • Operating mode: check whether the board supports direct/no-lock operation, toggle/self-lock operation, or both.
  • Configuration method: look for documented solder pads, jumpers, or other settings and follow instructions for that exact board.

Also consider what the project needs. For a touch-to-print demonstration or an LED that should light only while the pad is touched, direct operation is the intuitive choice if available. For a project that should retain an on/off state after a brief touch, toggle operation may suit the intended behavior, provided the code treats the output as a latched state. These are behavioral choices, not evidence that one configuration is universal.

Product listings and project parts lists can help identify the central component—a TTP223 touch sensor module—and optional supporting items such as a breadboard and jumper wires. Check each listing’s pin labels, voltage range, default polarity, and mode features before ordering. No single universal breakout layout or default is established by the cited sources, and prices or availability are not specified here.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Using these details, the basic setup stays simple: a 3.3 V supply, shared ground, one GPIO input, and Python that matches the breakout’s output behavior.

Frequently asked questions

Does the TTP223 need an analog input?

No. For this basic Raspberry Pi project, the module presents a digital output that the Pi reads as a GPIO input. The host program responds to the output state; it does not need to measure capacitance or convert an analog value.

Can I power the module from 5 V?

The cited Freenove module has a documented 2.0–5.5 V supply range, but that is not enough to establish that its output is safe to connect directly to a Pi GPIO. For a straightforward direct connection, use the Pi’s 3.3 V rail. Check the documentation for the exact breakout before using another supply voltage.

Why does GPIO Zero say “Touched” as soon as the program starts?

Check the module’s polarity and mode, then check the signal wire, ground, and GPIO number. An active-low board may be interpreted as active-high, or a toggle-mode board may be latched active. Confirm that SIG/OUT reaches the pin named in the code and configure the input to match the module.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What is the difference between GPIO17 and physical pin 11?

GPIO17 is a BCM GPIO number used in the code example. Physical pin 11 is the location of that GPIO on the 40-pin header. They are not interchangeable numbering schemes: the example uses Button(17) in code and connects the wire to physical pin 11.

Best Value
HiLetgo 10pcs TTP223B Capacitive Touch Switch Module Touch Sensor Switch Digital Capacitive Touch Sensor Switch DC 2~5.5V
  • This is the "momentary" variety of the touch sensor - touch and it turns on, release and it turns off.
  • Positive and negative can be used as a touch surface,can replace the traditional touch button.
  • Four M2 screws positioning holes for easy installation.Module can be installed in such as surface plastic, glass of non-metallic materials.
  • In addition to the thin paper ( non-metallic ) covering the surface of the module , as long as the correct location of the touch , you can make hidden in the walls, desktops and other parts of buttons.
  • The module is based on a touch-sensing IC (TTP223B) capacitive touch switch module. In the normal state, the module output low, low power consumption; When a finger touches the corresponding position, the module output high, if not touched for 12 seconds, switch to low-power mode.

Do I need an LED, resistor, or breadboard?

Not to read the touch sensor. The sensor needs VCC, GND, and one signal connection. A breadboard is optional for arranging connections. An LED is also optional; if you add one as an output demonstration, use a current-limiting resistor in series. Freenove’s LED project list specifies a 220 Ω resistor.

Can I use a different TTP223 breakout?

Yes, but verify that board’s own pin order, supply range, polarity, direct or toggle behavior, and configuration instructions. Breakouts that use the same sensor name do not necessarily share the same layout or default settings.