{"id":16780,"date":"2021-06-12T15:09:24","date_gmt":"2021-06-12T19:09:24","guid":{"rendered":"https:\/\/scruss.com\/blog\/?p=16780"},"modified":"2021-06-12T15:12:54","modified_gmt":"2021-06-12T19:12:54","slug":"raspberry-pi-pico-with-ttp223-touch-sensor","status":"publish","type":"post","link":"https:\/\/scruss.com\/blog\/2021\/06\/12\/raspberry-pi-pico-with-ttp223-touch-sensor\/","title":{"rendered":"Raspberry Pi Pico with TTP223 Touch Sensor"},"content":{"rendered":"\n<p>This is almost too trivial to write up, as the TTP223 does exactly what you&#8217;d expect it to do with no other components.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"948\" height=\"877\" src=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/06\/Pico-ttp223_bb.png\" alt=\"breadboard with Raspberry Pi Pico and small blue capacitive touch sensor\" class=\"wp-image-16781\" srcset=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/06\/Pico-ttp223_bb.png 948w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/06\/Pico-ttp223_bb-320x296.png 320w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/06\/Pico-ttp223_bb-160x148.png 160w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/06\/Pico-ttp223_bb-768x710.png 768w\" sizes=\"auto, (max-width: 948px) 100vw, 948px\" \/><figcaption>TTP223 sensor board connected to GP22 \/ physical pin 29<\/figcaption><\/figure>\n\n\n\n<p>Breakout boards for the TTP223 capacitive touch sensor come in a whole variety of sizes. The ones I got from <a href=\"https:\/\/www.simcoe-diy.ca\/\">Simcoe DIY<\/a> are <a href=\"https:\/\/www.simcoe-diy.ca\/product-page\/2pcs-ttp223-capacitive-touch-sensor-module-switch-mini\">much smaller<\/a>, have a different connection order, and don&#8217;t have an indicator LED. What they all give you, though, is a single touch\/proximity switch for about $1.50<\/p>\n\n\n\n<p>Trivial code to light the Raspberry Pi Pico&#8217;s LED when a touch event is detected looks like this:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport machine\ntouch = machine.Pin(22, machine.Pin.IN)\nled = machine.Pin(25, machine.Pin.OUT)\n\nwhile True:\n    led.value(touch.value())\n<\/pre><\/div>\n\n\n<p>For the default configuration, the sensor&#8217;s output goes high while a touch is detected, then goes low. This might not be the ideal configuration for you, so these sensor boards have a couple of solder links you can modify:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>Active Low<\/strong> \u00e2\u20ac\u201d sometimes you want a switch to indicate a touch with a low \/ 0 V signal. On the boards I have, the <strong>A<\/strong> link controls that: put a blob of solder across it to reverse the switch&#8217;s sense.<br><\/li><li><strong>Toggle<\/strong> \u00e2\u20ac\u201d if you want the output to stay latched at one level until you touch it again, a blob of solder across the <strong>T<\/strong> link will do that. Unlike a mechanical switch, this won&#8217;t stay latched after a power cycle, though.<\/li><\/ol>\n\n\n\n<p>And that&#8217;s all it does. Sometimes it&#8217;s nice to have a sensor that does exactly one thing perfectly well.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is almost too trivial to write up, as the TTP223 does exactly what you&#8217;d expect it to do with no other components. Breakout boards for the TTP223 capacitive touch sensor come in a whole variety of sizes. The ones I got from Simcoe DIY are much smaller, have a different connection order, and don&#8217;t [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Raspberry Pi Pico with TTP223 Touch Sensor: almost trivially easy single-input touch sensor","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[2],"tags":[3094,3258,2510,1746,3277],"class_list":["post-16780","post","type-post","status-publish","format-standard","hentry","category-goatee-stroking-musing-or-something","tag-micropython","tag-pico","tag-raspberrypi","tag-switch","tag-touch"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pQNZZ-4mE","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/16780","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/comments?post=16780"}],"version-history":[{"count":1,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/16780\/revisions"}],"predecessor-version":[{"id":16782,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/16780\/revisions\/16782"}],"wp:attachment":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/media?parent=16780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/categories?post=16780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/tags?post=16780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}