{"id":1550,"date":"2021-05-08T14:17:43","date_gmt":"2021-05-08T13:17:43","guid":{"rendered":"https:\/\/matthewolden.co.uk\/?p=1550"},"modified":"2021-05-08T14:17:43","modified_gmt":"2021-05-08T13:17:43","slug":"sensors-and-arduinos","status":"publish","type":"post","link":"https:\/\/matthewolden.co.uk\/?p=1550","title":{"rendered":"sensors and arduino&#8217;s"},"content":{"rendered":"<p>Getting stuff in like light sensors, pressure sensors and switches, and getting stuff out like LEDS and motors is a fairly easy job using a raspberry pi and an arduino. Theres a lot of different things to learn, and remember , and i would suggest going on a short how to use an arduino course. The guide here is a general how-to guide and will list different resources for you to investigate further.<\/p>\n<p>The raspberry pi can do what a arduino can do with out an arduino, but having an external board you can plug in and out is a more convenient way to deal with sensors.<\/p>\n<p style=\"text-align: center;\"><strong>the arduino<\/strong><\/p>\n<p><a href=\"https:\/\/www.arduino.cc\/\">heres the arduino website<\/a><\/p>\n<p>Arduino come in many flavours and styles, there&#8217;s also <a href=\"https:\/\/hobby-store.co.uk\/arduino\/arduino-uno-r3-atmega328-ch340-clone.html?gclid=CjwKCAjwvuGJBhB1EiwACU1AiTqW5zFXS_Gq4nln5hD1oLmwRRaueqrwJjpMFjgsU4Avlqa34QTkRhoCgYoQAvD_BwE\">much cheaper knock off versions<\/a> available too (although these sometimes need a bit of &#8220;fiddling&#8221;) i would suggest for your first arduino project buy an <a href=\"https:\/\/store.arduino.cc\/products\/arduino-uno-rev3\">UNO<\/a>.<\/p>\n<p style=\"text-align: center;\"><strong>preparing your arduino for pure data<\/strong><\/p>\n<p>before you can use your arduino you have to install standard firmata on it. <a href=\"https:\/\/www.instructables.com\/Arduino-Installing-Standard-Firmata\/\">Pretty easy if you follow these instructions<\/a><\/p>\n<p style=\"text-align: center;\"><strong>preparing pure data for the arduino<\/strong><\/p>\n<p><a href=\"https:\/\/matthewolden.co.uk\/?p=1471\">the floss instructions<\/a> have the basics of pduino and is a good place to\u00a0reference.meanwhile&#8230;&#8230;<\/p>\n<p>In a terminal window on the pi type<\/p>\n<p>sudo apt-get install pd-comport<\/p>\n<p>tihs will install the external comport into your library if you dont haave it already.<\/p>\n<p>Attach your arduino to one of the pi&#8217;s usb ports, then open pd. we need to download the pduino external, then point pd path to it.<\/p>\n<p><a href=\"https:\/\/matthewolden.co.uk.dream.website\/wp-content\/uploads\/2021\/05\/Untitledoopofg-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1554\" src=\"https:\/\/matthewolden.co.uk.dream.website\/wp-content\/uploads\/2021\/05\/Untitledoopofg-1-1024x638.jpg\" alt=\"Untitledoopofg\" width=\"660\" height=\"411\" \/><\/a><\/p>\n<p><a href=\"https:\/\/matthewolden.co.uk.dream.website\/wp-content\/uploads\/2021\/05\/pduinopath-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1555\" src=\"https:\/\/matthewolden.co.uk.dream.website\/wp-content\/uploads\/2021\/05\/pduinopath-1-817x1024.jpg\" alt=\"pduinopath\" width=\"660\" height=\"827\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>now we can open the pduino help patch from the browser<\/p>\n<p><a href=\"https:\/\/matthewolden.co.uk.dream.website\/wp-content\/uploads\/2021\/05\/jjjjjjjj-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1558\" src=\"https:\/\/matthewolden.co.uk.dream.website\/wp-content\/uploads\/2021\/05\/jjjjjjjj-1-1024x855.jpg\" alt=\"jjjjjjjj\" width=\"660\" height=\"551\" \/><\/a><\/p>\n<p>if we&#8217;re lucky it&#8217;ll open the arduino up first time (the StandardFirmata.ino 2.5 message gives it away) and we can see the details of the arduino in the pd window. If it doesn&#8217;t show up click the message box marked &#8220;devices&#8221; and all the devices and their\u00a0device numbers are listed in the pure data window (you can see mine listed as serial line device\u00a01 (\/dev\/tty\/USB0)),\u00a0type this number in the &#8220;enter the number of your serial device&#8221; number box and the arduino will get recognised. Now its time to attach sensors.<\/p>\n<p style=\"text-align: center;\"><strong>Sensors<\/strong><\/p>\n<p>lots of different sensors do lots of different things, and theres a few ways of wiring up different sensors, they plug into the arduino in different ways. A good place to start would be to purchase a <a href=\"https:\/\/www.amazon.co.uk\/ELEGOO-Upgraded-Tutorial-Compatible-MEGA2560\/dp\/B01M3TOXZN\/ref=sr_1_1_sspa?adgrpid=102668976934&amp;dchild=1&amp;gclid=CjwKCAjwvuGJBhB1EiwACU1AiX8l0ftPSMsN0IeIiW2o4FvDIb_JunMtu6Xtm1fOabw0Cwis1FEnMBoCaZ0QAvD_BwE&amp;hvadid=446777142707&amp;hvdev=c&amp;hvlocphy=9045632&amp;hvnetw=g&amp;hvqmt=e&amp;hvrand=11474862211472544261&amp;hvtargid=kwd-296157458319&amp;hydadcr=19079_1751909&amp;keywords=37+sensor+kit&amp;qid=1631110730&amp;sr=8-1-spons&amp;psc=1&amp;spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUFGNklCNTRWWTQ4TEwmZW5jcnlwdGVkSWQ9QTA0NjU4MDNKR0hEVFdTTVFZVVEmZW5jcnlwdGVkQWRJZD1BMDQ2NTMxNzFOTjJXOEYxTVQ3R0cmd2lkZ2V0TmFtZT1zcF9hdGYmYWN0aW9uPWNsaWNrUmVkaXJlY3QmZG9Ob3RMb2dDbGljaz10cnVl\">sensor kit like this.<\/a>\u00a0which comes with a <a href=\"https:\/\/images-eu.ssl-images-amazon.com\/images\/I\/C1lrpIfADaS.pdf\">detailed pdf<\/a>.<\/p>\n<p>heres a couple of the pages, showing you the knock sensor and how to wire it\u00a0 up. We don&#8217;t need all the information (it goes on to give a program to use it on an arduino &#8211; but we&#8217;ll be using the pi and arduino), we just need to know what pins do what and how to wire it to the arduino.<\/p>\n<p><a href=\"https:\/\/matthewolden.co.uk.dream.website\/wp-content\/uploads\/2021\/05\/Untitl-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1560\" src=\"https:\/\/matthewolden.co.uk.dream.website\/wp-content\/uploads\/2021\/05\/Untitl-1-1024x797.jpg\" alt=\"Untitl\" width=\"660\" height=\"513\" \/><\/a><\/p>\n<p><a href=\"https:\/\/matthewolden.co.uk.dream.website\/wp-content\/uploads\/2021\/05\/Untitled-2iiiiiiiiiii-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1561\" src=\"https:\/\/matthewolden.co.uk.dream.website\/wp-content\/uploads\/2021\/05\/Untitled-2iiiiiiiiiii-1-1024x997.jpg\" alt=\"Untitled 2iiiiiiiiiii\" width=\"660\" height=\"642\" \/><\/a><\/p>\n<p>the pin with the info on it (the signal) goes to arduino digital pin 3<\/p>\n<p>we can interrogate this pin to find out what is happening .Go to the pd_INPUT_DIGITAL box and double click, which will bring up this interface. In set pin mode click the circle with 3 above it to turn the pin on, and now the number 3 cross below should light up each time we get a knock.<\/p>\n<p><a href=\"https:\/\/matthewolden.co.uk.dream.website\/wp-content\/uploads\/2021\/05\/digitalin-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1562\" src=\"https:\/\/matthewolden.co.uk.dream.website\/wp-content\/uploads\/2021\/05\/digitalin-1-1024x465.jpg\" alt=\"digitalin\" width=\"660\" height=\"299\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>digital pins IN gives us an on and off (like a switch) that we can monitor, digital pins\u00a0OUT give us an on and off that could turn on a LED ,motor or circuit.<\/p>\n<p>analogue pins IN give us a range of values, something like a light or temperature sensor, similarly at PWM out give us a sliding scale so we can fade up an led or slow down a motor.<\/p>\n<p>Theres also output-servo settings that can precision control servo motors.<\/p>\n<p>here you can see an analogue sensor for humidity testing wired in. See how its now connected to the first analogue in<\/p>\n<p><a href=\"https:\/\/matthewolden.co.uk.dream.website\/wp-content\/uploads\/2021\/05\/humid-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1564\" src=\"https:\/\/matthewolden.co.uk.dream.website\/wp-content\/uploads\/2021\/05\/humid-1-1024x560.jpg\" alt=\"humid\" width=\"660\" height=\"360\" \/><\/a><\/p>\n<p>with pdunio i open ANALOG_INPUTS and click on the 14th circle marked A0. That turns on the input for analogue 0 and we can see it being monitored underneath.<\/p>\n<p><a href=\"https:\/\/matthewolden.co.uk.dream.website\/wp-content\/uploads\/2021\/05\/dhdhd-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1565\" src=\"https:\/\/matthewolden.co.uk.dream.website\/wp-content\/uploads\/2021\/05\/dhdhd-1-1024x517.jpg\" alt=\"dhdhd\" width=\"660\" height=\"333\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Getting stuff in like light sensors, pressure sensors and switches, and getting stuff out like LEDS and motors is a fairly easy job using a raspberry pi and an arduino. Theres a lot of different things to learn, and remember , and i would suggest going on a short how &#8230;<\/p>\n","protected":false},"author":2,"featured_media":1551,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-1550","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-pd-on-a-pi","column","fourcol","has-thumbnail"],"_links":{"self":[{"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1550","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1550"}],"version-history":[{"count":0,"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1550\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=\/wp\/v2\/media\/1551"}],"wp:attachment":[{"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1550"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1550"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/matthewolden.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1550"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}