{"id":16887,"date":"2021-10-25T09:09:47","date_gmt":"2021-10-25T13:09:47","guid":{"rendered":"https:\/\/scruss.com\/blog\/?p=16887"},"modified":"2021-10-25T09:09:47","modified_gmt":"2021-10-25T13:09:47","slug":"modding-an-adafruit-pir-for-3-3-volts","status":"publish","type":"post","link":"https:\/\/scruss.com\/blog\/2021\/10\/25\/modding-an-adafruit-pir-for-3-3-volts\/","title":{"rendered":"Modding an Adafruit PIR for 3.3 volts"},"content":{"rendered":"\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"759\" src=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/10\/PXL_20211025_112346311-1024x759.jpg\" alt=\"green circuit board covered in surface mount components. A grey wire has been soldered to the output pin of the SOT-89 package 7133-1 voltage regulator\" class=\"wp-image-16888\" srcset=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/10\/PXL_20211025_112346311-1024x759.jpg 1024w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/10\/PXL_20211025_112346311-320x237.jpg 320w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/10\/PXL_20211025_112346311-160x119.jpg 160w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/10\/PXL_20211025_112346311-768x569.jpg 768w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/10\/PXL_20211025_112346311.jpg 1516w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>slightly dodgy soldering of a grey jumper wire to the V<sub>out<\/sub> pin of the PIR&#8217;s voltage regulator<\/figcaption><\/figure><\/div>\n\n\n\n<p>Consider the <a href=\"https:\/\/www.adafruit.com\/product\/189\">Adafruit PIR (motion) sensor<\/a> (aka <a href=\"https:\/\/elmwoodelectronics.ca\/products\/pir-motion-sensor\">PIR Motion Sensor<\/a>, if you&#8217;re in Canada). Simple, reliable device, but only runs from a 5 V supply. Yes, there are smaller PIRs that run off 3.3 V, but if this is what you have, you need to do some soldering. Annoyingly, the sensor on the board is a 3.3 V part, but the carrier was designed in Olden Tymes when King 5 V ruled.<\/p>\n\n\n\n<p>You can <em>try<\/em> powering it from 3.3 V, but it&#8217;ll go all off on its own randomly as its own power supply won&#8217;t be supplying enough voltage. There are a couple of sites on how to modify these PIRs that either describe old kit you can&#8217;t get any more, or do it completely wrongly. Just <a href=\"https:\/\/forums.adafruit.com\/viewtopic.php?f=19&amp;t=45260#p226688\">one post on the Adafruit support forum gets it right<\/a>.<\/p>\n\n\n\n<p>One way of doing this is to provide 3.3 V directly to the output pin of the voltage regulator, and ignore the 5 V power line entirely. The regulator&#8217;s a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Small-outline_transistor#SOT89-3\">SOT89-3<\/a> part that looks a bit like this:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"163\" height=\"223\" src=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/10\/Screenshot-from-2021-10-25-08-29-03.png\" alt=\"71xx-1 SOT-89 package outline, with three pins at the bottom and one large ground tab (connected to centre pin, but not visible) at the top\" class=\"wp-image-16889\" srcset=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/10\/Screenshot-from-2021-10-25-08-29-03.png 163w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/10\/Screenshot-from-2021-10-25-08-29-03-117x160.png 117w\" sizes=\"auto, (max-width: 163px) 100vw, 163px\" \/><figcaption>wee leggy thing<\/figcaption><\/figure><\/div>\n\n\n\n<p>In the photo above, it&#8217;s flipped over. Whichever way it&#8217;s oriented, we want to put power directly into the V<sub>out<\/sub> pin. There may be easier points to solder this to than a tiny surface mount pin (almost definitely one of the capacitors) but this has held for me.<\/p>\n\n\n\n<p>How to use it in MicroPython? Like the <a href=\"https:\/\/scruss.com\/blog\/2021\/06\/12\/raspberry-pi-pico-with-ttp223-touch-sensor\/\">TTP223 capacitive touch sensor<\/a>s I looked at before, a PIR gives a simple off\/on output, so you can use something like this:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfrom machine import Pin\nfrom time import sleep_ms\n\npir = Pin(21, Pin.IN)\n\nwhile True:\n    print(&quot;&#x5B;&quot;, pir.value(), &quot;]&quot;)\n    sleep_ms(1000)\n<\/pre><\/div>\n\n\n<p><em>value()<\/em> will return 1 if there&#8217;s movement, 0 if not. There are trigger time and sensitivity potentiometers to fiddle with on the board if you need to tweak the output.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"529\" height=\"444\" src=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/10\/Screenshot-from-2021-10-25-08-59-17.png\" alt=\"line graph showing output signal going from 0 to 1, back down to 0 and ending at one over a period of about 20 seconds\" class=\"wp-image-16890\" srcset=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/10\/Screenshot-from-2021-10-25-08-59-17.png 529w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/10\/Screenshot-from-2021-10-25-08-59-17-320x269.png 320w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2021\/10\/Screenshot-from-2021-10-25-08-59-17-160x134.png 160w\" sizes=\"auto, (max-width: 529px) 100vw, 529px\" \/><figcaption>Thonny plotter output showing a couple of movement detections. High output (on my device) stays up for about 4 seconds, so you can be pretty leisurely about polling PIRs<\/figcaption><\/figure><\/div>\n\n\n\n<p>Just remember: <strong>don&#8217;t connect the 5 V power line<\/strong> if you make this mod. I&#8217;m not responsible for any smoke emitted if you do \u00e2\u20ac\u201d but I can always <a href=\"https:\/\/elmwoodelectronics.ca\/products\/pir-motion-sensor\">sell you a replacement<\/a> \u00e2\u20ac\u00a6<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Consider the Adafruit PIR (motion) sensor (aka PIR Motion Sensor, if you&#8217;re in Canada). Simple, reliable device, but only runs from a 5 V supply. Yes, there are smaller PIRs that run off 3.3 V, but if this is what you have, you need to do some soldering. Annoyingly, the sensor on the board is [&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":"Modding an Adafruit PIR for 3.3 volts: could I be making a motion-activated neep lantern?","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":[2208,3094,3296,3102,2268],"class_list":["post-16887","post","type-post","status-publish","format-standard","hentry","category-goatee-stroking-musing-or-something","tag-electronics","tag-micropython","tag-pir","tag-sensors","tag-solder"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pQNZZ-4on","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/16887","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=16887"}],"version-history":[{"count":2,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/16887\/revisions"}],"predecessor-version":[{"id":16892,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/16887\/revisions\/16892"}],"wp:attachment":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/media?parent=16887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/categories?post=16887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/tags?post=16887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}