{"id":5157,"date":"2021-07-18T02:34:56","date_gmt":"2021-07-18T02:34:56","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=5157"},"modified":"2021-07-18T02:34:56","modified_gmt":"2021-07-18T02:34:56","slug":"raspberry-pi-how-to-get-gpio-outputs-for-reed-relay-hall-effect","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/raspberry-pi-how-to-get-gpio-outputs-for-reed-relay-hall-effect","title":{"rendered":"Raspberry Pi &#8211; How to get GPIO Outputs for Reed Relay \\ Hall Effect"},"content":{"rendered":"<p>Recently received my first Raspberry Pie and needed to get input sensors, especially a reed switch and also testing a Hall Effect Sensor<\/p><p><strong>Reed Switch with Hardware Pull Down ( Resistors )\u00a0<\/strong><\/p><p><img decoding=\"async\" src=\"https:\/\/www.rs-online.com\/designspark\/rel-assets\/dsauto\/temp\/uploaded\/external_pull-down.jpg?w=1042\" alt=\"What inputs can I use with my Raspberry Pi? Part 1 - Switches and  logic-level sensors\" \/><\/p><p>On the Pie this looks like<\/p><p>&nbsp;<\/p><p id=\"BBORJSa\"><img decoding=\"async\" src=\"https:\/\/www.digikey.com\/-\/media\/MakerIO\/Images\/blogs\/2018\/How%20To%20Use%20GPIO%20on%20the%20Raspberry%20Pi%20with%20C\/Featured-image.jpg?la=en-US&amp;ts=833891f6-59d8-466f-b438-55add7cbd410\" alt=\"How To Use GPIO on the Raspberry Pi with C++\" \/><\/p><p><strong>Reed Switch with Internal Pull Down Resistor\u00a0<\/strong><\/p><p>see below , gpios 0-8 are pulled high, the rest are pulled low. They are all inputs. Those initial power on states can not be changed &#8211; it&#8217;s wired into the SoC. So if you are wanting to use below make sure you use GPIO over 8 so it can withstand a reboot<\/p><p id=\"ZXUgvNi\"><img loading=\"lazy\" decoding=\"async\" width=\"1091\" height=\"537\" class=\"alignnone size-full wp-image-5208  img-responsive\" src=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/07\/img_60f3907b70067.png\" alt=\"\" srcset=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/07\/img_60f3907b70067.png 1091w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/07\/img_60f3907b70067-300x148.png 300w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/07\/img_60f3907b70067-1024x504.png 1024w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/07\/img_60f3907b70067-768x378.png 768w\" sizes=\"auto, (max-width: 1091px) 100vw, 1091px\" \/><\/p><p><strong>Hall Effect Sensor with Hardware Pull Down ( Resistors )\u00a0<\/strong><\/p><p>This has three pins ( Extra Digital Out )\u00a0 so needs to be Wired differently , we just need to protect the GPIO Pins<\/p><p>&nbsp;<\/p><p id=\"KcpSftk\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-5207 img-responsive\" src=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/07\/halleffect.jpg\" alt=\"\" width=\"2000\" height=\"1334\" srcset=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/07\/halleffect.jpg 2000w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/07\/halleffect-300x200.jpg 300w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/07\/halleffect-1024x683.jpg 1024w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/07\/halleffect-768x512.jpg 768w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/07\/halleffect-1536x1025.jpg 1536w\" sizes=\"auto, (max-width: 2000px) 100vw, 2000px\" \/><\/p><p>&nbsp;<\/p><p id=\"VWlsYqB\"><img loading=\"lazy\" decoding=\"async\" width=\"977\" height=\"660\" class=\"alignnone size-full wp-image-5205  img-responsive\" src=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/07\/img_60f3859c8b487.png\" alt=\"\" srcset=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/07\/img_60f3859c8b487.png 977w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/07\/img_60f3859c8b487-300x203.png 300w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/07\/img_60f3859c8b487-768x519.png 768w\" sizes=\"auto, (max-width: 977px) 100vw, 977px\" \/><\/p><p>I used GPIO&#8217;s 4,5,6<\/p><p>#enables GPIO 4<br \/>echo 4 &gt; \/sys\/class\/gpio\/export<br \/><br \/>#marks 4 as input ( not Output )<br \/>sudo echo in &gt; \/sys\/class\/gpio\/gpio4\/direction<br \/><br \/>#Configure the gpios to trigger an interrupt on both edge ( An edge is the name of a transition from <a href=\"https:\/\/sourceforge.net\/p\/raspberry-gpio-python\/wiki\/Inputs\/\">HIGH to LOW (<em>falling edge<\/em>) ) &#8211; LOW to HIGH (rising edge)<\/a>.<br \/>echo both &gt; \/sys\/class\/gpio\/gpio4\/edge<\/p><p>#<code dir=\"ltr\" translate=\"no\"><a href=\"https:\/\/developer.android.com\/reference\/com\/google\/android\/things\/pio\/Gpio#setActiveType(int)\">ActiveType<\/a><\/code>\u00a0constant to select active high, which means that logical\u00a0<code dir=\"ltr\" translate=\"no\">true<\/code> corresponds with high voltage. \u00a0active low, which means that logical\u00a0<code dir=\"ltr\" translate=\"no\">true<\/code> corresponds with low voltage. \u00a00 (false) or 1 (true)<\/p><p>echo 0 &gt; \/sys\/class\/gpio\/gpio4\/active_low<\/p><p><strong>How to read the current value of GPIO<\/strong><\/p><p>cat \/sys\/class\/gpio\/gpio4\/value<\/p><p>raspi-gpio get 4<\/p><p><strong>How to set GPIO Pull Down\u00a0<\/strong><\/p><p>On Boot gpios 0-8 are pulled high, the rest are pulled low. They are all inputs. Those initial power on states can not be changed &#8211; it&#8217;s wired into the SoC<\/p><p>raspi-gpio set 4 pd<\/p><p>pu set GPIO in-pad pull up<br \/>pd set GPIO pin-pad pull down<\/p><p>&nbsp;<\/p><p>&nbsp;<\/p><p>&nbsp;<\/p><pre>\u00a0<\/pre>","protected":false},"excerpt":{"rendered":"<p>Recently received my first Raspberry Pie and needed to get input sensors, especially a reed switch and also testing a Hall Effect SensorReed Switch with Hardware Pull [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3542,3541,3538,3540,3544,3543,3545,3539],"class_list":["post-5157","post","type-post","status-publish","format-standard","hentry","category-research","tag-bread-board","tag-edges","tag-gpio","tag-hall-effect","tag-pull-down","tag-pull-up","tag-rapsberry-pi","tag-reed-switch"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/5157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=5157"}],"version-history":[{"count":5,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/5157\/revisions"}],"predecessor-version":[{"id":5209,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/5157\/revisions\/5209"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=5157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=5157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=5157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}