{"id":291,"date":"2018-08-12T17:45:32","date_gmt":"2018-08-12T09:45:32","guid":{"rendered":"https:\/\/www.techcoil.com\/blog\/?p=291"},"modified":"2018-08-26T22:32:20","modified_gmt":"2018-08-26T14:32:20","slug":"building-a-raspberry-pi-3-prototype-camera-that-takes-a-picture-at-the-press-of-a-button","status":"publish","type":"post","link":"https:\/\/www.techcoil.com\/blog\/building-a-raspberry-pi-3-prototype-camera-that-takes-a-picture-at-the-press-of-a-button\/","title":{"rendered":"Building a Raspberry Pi 3 prototype camera that takes a picture at the press of a button"},"content":{"rendered":"<p>A fun way to test your <a href=\"https:\/\/www.amazon.com\/Raspberry-Pi-Camera-Module-Megapixel\/dp\/B01ER2SKFS\/ref=as_li_ss_tl?ie=UTF8&linkCode=ll1&tag=clivsperswebs-20&linkId=bdb375909b217e2816352837676a3d63\" rel=\"noopener\" target=\"_blank\">Raspberry Pi Camera<\/a> on your <a href=\"https:\/\/www.amazon.com\/RS-Components-Raspberry-Pi-Motherboard\/dp\/B07BFH96M3\/ref=as_li_ss_tl?ie=UTF8&linkCode=ll1&tag=clivsperswebs-20&linkId=84a7793bbdc25a87ab07fda5b5cccb25\" rel=\"noopener\" target=\"_blank\">Raspberry Pi 3<\/a> is to build a prototype that takes a picture at the press of a button. Through such an activity, we will be able to experience:<\/p>\n<ul>\n<li>connecting a button to the GPIO ports on a Raspberry Pi.<\/li>\n<li>setting up a camera through the CSI interface of a Raspberry Pi.<\/li>\n<li>preparing an operating system, such as Raspbian Stretch Lite , for running Raspberry Pi projects.<\/li>\n<li>coding a Python 3 script that interacts with the GPIO port and camera on a Raspberry Pi.<\/li>\n<li>running a Python 3 script when Raspberry Pi powers on.<\/li>\n<\/ul>\n<p>Given these points, this post shows how you can build a Raspberry Pi 3 prototype camera that takes a picture at the press of a button.<\/p>\n<h2>Suggested bill of materials for this Raspberry Pi 3 project<\/h2>\n<p>In case you need some reference on <a href=\"https:\/\/www.techcoil.com\/raspberry-pi-3-buying-guide\/\" rel=\"noopener\" target=\"_blank\">what you can buy for this Raspberry Pi 3 project<\/a>, the following is a suggested bill of materials for you:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.amazon.com\/CanaKit-Raspberry-Power-Supply-Listed\/dp\/B07BC6WH7V\/ref=as_li_ss_tl?ie=UTF8&linkCode=ll1&tag=clivsperswebs-20&linkId=93e416c849f934c6b7cc8ff1648098c2\" rel=\"noopener\" target=\"_blank\">CanaKit Raspberry Pi 3 B+ (B Plus) with 2.5A Power Supply (UL Listed)<\/a><\/li>\n<li><a href=\"https:\/\/www.amazon.com\/Sandisk-Ultra-Micro-UHS-I-Adapter\/dp\/B073JWXGNT\/\/ref=as_li_ss_tl?ie=UTF8&linkCode=ll1&tag=clivsperswebs-20&linkId=f1a242a1e4d5eba8dea23f1007ef067b\" rel=\"noopener\" target=\"_blank\">Sandisk Ultra 32GB Micro SDHC UHS-I Card with Adapter<\/a><\/li>\n<li><a href=\"https:\/\/www.amazon.com\/Raspberry-Pi-Camera-Module-Megapixel\/dp\/B01ER2SKFS\/ref=as_li_ss_tl?&imprToken=ZjGErXUOekA9YDI0TdGRAA&slotNum=51&ie=UTF8&qid=1521185176&sr=8-3&keywords=raspi+camera&linkCode=ll1&tag=clivsperswebs-20&linkId=116232694cd106b9d3e0c99dc6a6dfd6\" rel=\"noopener\" target=\"_blank\">Raspberry Pi Camera Module V2 - 8 Megapixel,1080p<\/a><\/li>\n<li>A push button, two male-to-female jumper wires and a breadboard from an electronic kit like <a href=\"https:\/\/www.amazon.com\/REXQualis-Electronics-tie-points-Breadboard-Potentiometer\/dp\/B073ZC68QG\/ref=as_li_ss_tl?s=electronics&ie=UTF8&qid=1531988360&sr=1-4&tag=clivsperswebs-20\" rel=\"noopener\" target=\"_blank\">REXQualis Electronics Component Fun Kit<\/a><\/li>\n<li><a href=\"https:\/\/www.amazon.com\/Official-Original-Raspberry-Model-White\/dp\/B01CCPKCSK\/ref=as_li_ss_tl?&imprToken=tCbs8mgp8f2f4SwcP0EdCA&slotNum=22&ie=UTF8&qid=1520171364&sr=8-1&linkCode=ll1&tag=clivsperswebs-20&linkId=a07a33c3f7db1e0d9c4cb8d1987b11bb\" rel=\"noopener\" target=\"_blank\">Official Raspberry Pi 3 Case - Red\/White<\/a> (Optional)<\/li>\n<\/ul>\n<form action=\"https:\/\/www.amazon.com\/gp\/aws\/cart\/add.html\" method=\"GET\" target=\"_blank\"><input name=\"AssociateTag\" type=\"hidden\" value=\"clivsperswebs-20\"><input name=\"SubscriptionId\" type=\"hidden\" value=\"[AKIAIMND5UBCQU2HRSUA]\"><input name=\"ASIN.1\" type=\"hidden\" value=\"B07BC6WH7V\"><input name=\"Quantity.1\" type=\"hidden\" value=\"1\"><input name=\"ASIN.2\" type=\"hidden\" value=\"B073JWXGNT\"><input name=\"Quantity.2\" type=\"hidden\" value=\"1\"><input name=\"ASIN.3\" type=\"hidden\" value=\"B01ER2SKFS\"><input name=\"Quantity.3\" type=\"hidden\" value=\"1\"><input name=\"ASIN.4\" type=\"hidden\" value=\"B073ZC68QG\"><input name=\"Quantity.4\" type=\"hidden\" value=\"1\"><input name=\"ASIN.5\" type=\"hidden\" value=\"B01CCPKCSK\"><input name=\"Quantity.5\" type=\"hidden\" value=\"1\"><br \/>\n<input class=\"external_link\" type=\"submit\" alt=\"Buy from Amazon.com\" name=\"add\" value=\"Add these items to your Amazon cart\"><\/form>\n<h2>Connecting the push button to the GPIO ports on your Raspberry Pi 3 via the breadboard<\/h2>\n<p>For the purpose of this guide, let's use <strong>GPIO 4<\/strong> and one of the ground pins of your Raspberry Pi 3 to detect button presses. The following diagram shows how you can wire the push button to a Raspberry Pi 3 via a breadboard:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/Fritzing-screenshot-of-button-connected-to-gpio-4-and-gnd-of-Rpi-3.gif\" alt=\"Fritzing screenshot of button connected to gpio 4 and gnd of Rpi 3\" \/><\/p>\n<p>If you want to connect your push button to other GPIO pins on your Raspberry Pi 3, you can <a href=\"https:\/\/www.techcoil.com\/blog\/helpful-gpio-pinout-resources-that-you-can-reference-while-connecting-sensors-to-your-raspberry-pi-3\/\" rel=\"noopener\" target=\"_blank\">checkout these GPIO Pinout resources<\/a> to help you do so. <\/p>\n<h3>How should the button be inserted onto the breadboard<\/h3>\n<p>The following diagram shows a push button that is partially inserted:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/Push-button-partially-inserted-into-breadboard.jpg\" alt=\"Push button partially inserted into breadboard\"\/><\/p>\n<p>This is how the legs of the push button be positioned when you insert it onto the breadboard. <\/p>\n<p>Fully insert the push button into the breadboard before continuing with the tutorial:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/Push-button-fully-inserted-into-breadboard.jpg\" alt=\"Push button fully inserted into breadboard\" \/> <\/p>\n<h2>Connecting the Raspberry Pi Camera Module to your Raspberry Pi 3<\/h2>\n<p>After you had connected your push button to your Raspberry Pi 3, proceed to <a href=\"https:\/\/www.techcoil.com\/blog\/connect-raspberry-pi-camera-module-raspberry-pi-2-raspberry-pi-3\/\" rel=\"noopener\" target=\"_blank\">connect the Raspberry Pi Camera Module to your Raspberry Pi 3<\/a>.<\/p>\n<p>After connecting the Raspberry Pi Camera Module to your Raspberry Pi 3, your setup should look like this:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/Raspberry-Pi-3-connected-to-push-button-and-camera-module.jpg\" alt=\"Raspberry Pi 3 connected to push button and camera module\" \/><\/p>\n<h2>Setting up Raspbian Stretch Lite with SSH server enabled on your microSD card<\/h2>\n<p>Once you had connected the camera and button to your Raspberry Pi 3, proceed to <a href=\"https:\/\/www.techcoil.com\/blog\/how-to-setup-raspbian-stretch-lite-with-ssh-server-enabled-on-your-microsd-card\/\" rel=\"noopener\" target=\"_blank\">setup Raspbian Stretch Lite with SSH server enabled on your microSD card<\/a>. Doing so will allow you to SSH into your Raspbian Stretch Lite to perform further configurations in this post.<\/p>\n<h2>Starting the Raspbian Stretch Lite operating system<\/h2>\n<p>Next, connect one end of the RJ45 cable to the RJ45 port on the Raspberry Pi 3 board and the other end of the cable to one of the switch port of your <a href=\"https:\/\/www.amazon.com\/s\/ref=as_li_ss_tl?imprToken=fGvnEk8Vp4eyKgSQbw2xag&slotNum=6&url=search-alias=aps&field-keywords=home+router&linkCode=ll2&tag=clivsperswebs-20&linkId=363428883879d0fc3a49dd1714843c2d\" rel=\"noopener\" target=\"_blank\">home router<\/a>. After that, connect the micro USB power supply to the Raspberry Pi 3 board and a wall socket. Turn on the power socket to supply power to the Raspberry Pi 3 board.<\/p>\n<h2>Getting into Raspbian Stretch Lite and updating it<\/h2>\n<p>After you had started your Raspbian Stretch Lite, SSH into your Raspberry Pi 3 with a computer that is connected to the same network as your Raspberry Pi 3.<\/p>\n<p>Suppose your router had given your Raspberry Pi 3 <strong>192.168.1.123<\/strong> as the IP address, you will run the following command from your terminal program to get into Raspbian Stretch Lite:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nssh pi@192.168.1.123\r\n<\/pre>\n<p>When Raspbian Stretch Lite prompts for a password, enter <strong>raspberry<\/strong>.<\/p>\n<p>Once you had gotten into Raspbian Stretch Lite, run the following command to update it: <\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo apt-get update\r\n<\/pre>\n<h2>Enabling the camera on Raspbian Stretch Lite<\/h2>\n<p>Before we can use the camera on Raspbian Stretch Lite, we need to enable it. Therefore, <a href=\"https:\/\/www.techcoil.com\/blog\/how-to-enable-raspberry-pi-camera-on-raspbian-stretch-lite\/\" rel=\"noopener\" target=\"_blank\">follow this guide to enable Raspberry Pi Camera on Raspbian Stretch Lite<\/a>.<\/p>\n<h2>Installing Virtualenv on Raspbian Stretch Lite<\/h2>\n<p><a href=\"https:\/\/virtualenv.pypa.io\/en\/stable\/\" rel=\"noopener\" target=\"_blank\">Virtualenv<\/a> is a tool that allows us to create isolated environments in the same machine. This is useful when you have to run multiple applications with conflicting python dependencies on your Raspberry Pi 3.<\/p>\n<p>Therefore to be able to use the same Raspberry Pi 3 to try out other projects, we will be using Virtualenv to create an environment to run our Python 3 script. <\/p>\n<p>To install Virtualenv, run the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo apt-get install virtualenv -y\r\n<\/pre>\n<h2>Installing Supervisor<\/h2>\n<p>When we want our Python 3 script to start at boot time and constantly listen for button presses, we can use <a href=\"http:\/\/supervisord.org\/\" rel=\"noopener\" target=\"_blank\">Supervisor<\/a> to help us monitor and control the process that will run our Python 3 script.<\/p>\n<p>In order to install Supervisor, we need to run the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo apt-get install supervisor -y\r\n<\/pre>\n<h2>Coding a Python 3 script that interacts with the GPIO ports on a Raspberry Pi<\/h2>\n<p>After installing Supervisor, we can proceed to code a simple Python 3 script that will:<\/p>\n<ul>\n<li>Listen for button presses.<\/li>\n<li>Take a picture with the camera when the button is pressed.<\/li>\n<\/ul>\n<p>Given these points, let's use <code>nano<\/code> to create a Python script at <code>\/home\/pi\/run.py<\/code>:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nnano \/home\/pi\/run.py\r\n<\/pre>\n<p>Once the editor starts, copy the following Python 3 codes into the editor:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nfrom gpiozero import Button\r\nfrom picamera import PiCamera\r\nfrom signal import pause\r\n\r\nimport time\r\n\r\ncamera = PiCamera()\r\n\r\ndef take_picture_with_camera():\r\n\r\n    image_path = '\/home\/pi\/images\/image_%s.jpg' % int(round(time.time() * 1000))\r\n    camera.capture(image_path)\r\n    print('Took photo')\r\n\r\nbutton = Button(4)\r\nbutton.when_pressed = take_picture_with_camera\r\n\r\npause()\r\n<\/pre>\n<p>After that, type <strong>Ctrl-X<\/strong> and then <strong>Y<\/strong> to save the file.<\/p>\n<p>In the Python 3 script, we first import the libraries that we are going to use. After that, we create an instance of <a href=\"http:\/\/picamera.readthedocs.io\/en\/release-1.10\/api_camera.html#picamera\" rel=\"noopener\" target=\"_blank\"><code>PiCamera<\/code><\/a> for interfacing with the Raspberry Pi Camera module.<\/p>\n<h3>Python 3 codes to take picture with Raspberry Pi Camera<\/h3>\n<p>Once we had created an instance of <code>PiCamera<\/code>, we define a function: <code>take_picture_with_camera<\/code>. <\/p>\n<p>Inside <code>take_picture_with_camera<\/code>, we use <\/p>\n<ul>\n<li><code>time.time()<\/code> to define an image path to save the picture that the camera will capture later,<\/li>\n<li><code>camera.capture(image_path)<\/code> to take a picture with the camera and save the image to the path defined by image_path,<\/li>\n<\/ul>\n<h3>Python 3 codes to listen for button presses<\/h3>\n<p>After defining the function, we went ahead to create an instance of <a href=\"https:\/\/gpiozero.readthedocs.io\/en\/stable\/api_input.html#button\" rel=\"noopener\" target=\"_blank\">Button<\/a> that will listen to voltage changes on <strong>GPIO 4<\/strong>.<\/p>\n<p>Once we had created an instance of the button, we assign <code>take_picture_with_camera<\/code> to <code>button.when_pressed<\/code>. As a result of this, <code>take_picture_with_camera<\/code> will be called when the push button is pressed.<\/p>\n<p>Finally, we pause the Python 3 script to stop it from terminating. <\/p>\n<h2>Creating a virtual environment to run the Python 3 script<\/h2>\n<p>Next, let's create a virtual environment to run the Python 3 script. In order to do so, we will run the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nvirtualenv -p python3 \/home\/pi\/rpi-cam-prototype-env\r\n<\/pre>\n<p>After that, we get into the virtual environment by running the following command:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nsource \/home\/pi\/rpi-cam-prototype-env\/bin\/activate\r\n<\/pre>\n<p>Once you gotten into the virtual environment, run the following commands to install the Python dependencies for the Python 3 script:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\npip install gpiozero==1.4.1 picamera==1.13 RPi.GPIO==0.6.3\r\n<\/pre>\n<p>When pip finishes the installations, you will be able to run your Python 3 script within the virtual environment.<\/p>\n<h2>Testing your Python 3 script<\/h2>\n<p>After you had prepared the virtual environment for your Python 3 script, create the <code>\/home\/pi\/images<\/code> folder:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmkdir \/home\/pi\/images\r\n<\/pre>\n<p>When the folder is created, run your Python script with the following commands:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncd \/home\/pi\r\npython run.py\r\n<\/pre>\n<p>You will notice that after you ran the commands, the terminal pauses. In addition, the LED on the Raspberry Pi Camera lights up. This indicates that your Python 3 script is ready to listen for button presses. <\/p>\n<p>Given that, whenever you press the push button, you will find an image being created inside the <code>\/home\/pi\/images<\/code> folder.<\/p>\n<h2>Running the Python 3 script when your Raspberry Pi 3 powers on<\/h2>\n<p>When you want your Python 3 script to run whenever your Raspberry Pi 3 is turned on, you can depend on Supervisor. This section will show how you can to get Supervisor to run your Python 3 script whenever your Raspberry Pi 3 is turned on.<\/p>\n<p>Firstly, let's create a shell script that will activate the virtual environment that we had created earlier and run our Python 3 script within that virtual environment.<\/p>\n<p>To do so, we use <code>nano<\/code> to create a shell script at <code>\/home\/pi\/run.sh<\/code><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nnano \/home\/pi\/run.sh\r\n<\/pre>\n<p>Once the editor loads, write the following content into the editor:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n!#\/bin\/bash\r\nsource .\/rpi-cam-prototype-env\/bin\/activate\r\npython run.py\r\ndeactivate\r\n<\/pre>\n<p>After you had included the content, type <strong>Ctrl-X<\/strong> and then <strong>Y<\/strong> to save the file.<\/p>\n<p>Afterwards, make the shell script executable by running the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo chmod 744 \/home\/pi\/run.sh\r\n<\/pre>\n<p>To get Supervisor to start our Python 3 script so that we can take pictures with our Raspberry Pi 3 prototype, we first create a configuration file at <code>\/etc\/supervisor\/conf.d\/rpi3-camera-prototype.conf<\/code>:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo nano \/etc\/supervisor\/conf.d\/rpi3-camera-prototype.conf\r\n<\/pre>\n<p>After <code>nano<\/code> loads, copy the following configuration codes into the editor:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&#x5B;program:rpi3-camera-prototype]\r\ndirectory=\/home\/pi\r\ncommand=\/bin\/bash -E -c .\/run.sh\r\nautostart=true\r\nautorestart=true\r\nstopsignal=INT\r\nstopasgroup=true\r\nkillasgroup=true\r\nuser=pi\r\n<\/pre>\n<p>Once you had written the configurations into the editor, run the following command to restart Supervisor:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo systemctl restart supervisor.service\r\n<\/pre>\n<p>When Supervisor runs again, it will take the configurations that you had created earlier and run your Python 3 script.<\/p>\n<p>With that, whenever you power on your Raspberry Pi 3, you will be able to take pictures with your Raspberry Pi camera by pushing the button.<\/p>\n<h2>Further enhancement: Perform image compression on the pictures from your Python 3 script<\/h2>\n<p>You may have noticed that the images that you Raspberry Pi camera took are pretty big, each of them takes more than 150 KB.<\/p>\n<p>In case you are extending the prototype to <a href=\"https:\/\/www.techcoil.com\/blog\/how-to-upload-a-file-and-some-data-through-http-multipart-in-python-3-using-the-requests-library\/\" rel=\"noopener\" target=\"_blank\">send the pictures to a server endpoint<\/a>, you may want to compress the pictures before sending it, especially when you <a href=\"https:\/\/www.techcoil.com\/blog\/how-to-connect-your-raspberry-pi-to-your-iphone-wifi-hotspot-via-raspbian-stretch-lite\/\" rel=\"noopener\" target=\"_blank\">connect your Raspbian Stretch Lite to your iPhone Personal WiFi hotspot<\/a>. <\/p>\n<p>In such a situation, you may want to <a href=\"https:\/\/www.techcoil.com\/blog\/how-to-use-python-3-pillow-on-raspbian-stretch-lite-to-compress-your-jpeg-image\/\" rel=\"noopener\" target=\"_blank\">use Python 3 Pillow on Raspbian Stretch Lite to compress your jpeg images<\/a>. <\/p>\n<p>To keep this tutorial short, I will leave it to you to figure out how to modify the Python 3 script to compress your pictures with <a href=\"https:\/\/pillow.readthedocs.io\/en\/latest\/\" rel=\"noopener\" target=\"_blank\">Pillow<\/a>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/Building-a-Raspberry-Pi-3-prototype-camera-that-takes-a-picture-at-the-press-of-a-button.jpg\" alt=\"Building a Raspberry Pi 3 prototype camera that takes a picture at the press of a button\" \/><\/p>\n\n      <ul id=\"social-sharing-buttons-list\">\n        <li class=\"facebook\">\n          <a href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fwp.me%2Fp245TQ-4H\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n            <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Facebook.png\" alt=\"Facebook icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"twitter\">\n          <a href=\"https:\/\/twitter.com\/intent\/tweet?text=&url=https%3A%2F%2Fwp.me%2Fp245TQ-4H&via=Techcoil_com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Twitter.png\" alt=\"Twitter icon\"> Tweet\n          <\/a>\n        <\/li>\n        <li class=\"linkedin\">\n          <a href=\"https:\/\/www.linkedin.com\/shareArticle?mini=1&title=&url=https%3A%2F%2Fwp.me%2Fp245TQ-4H&source=https:\/\/www.techcoil.com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/linkedin.png\" alt=\"Linkedin icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"pinterest\">\n          <a href=\"https:\/\/pinterest.com\/pin\/create\/button\/?url=https%3A%2F%2Fwww.techcoil.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F291&description=\" class=\"pin-it-button\" target=\"_blank\" role=\"button\" rel=\"nofollow\" count-layout=\"horizontal\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Pinterest.png\" alt=\"Pinterest icon\"> Save\n          <\/a>\n        <\/li>\n      <\/ul>\n    ","protected":false},"excerpt":{"rendered":"<p>A fun way to test your <a href=\"https:\/\/www.amazon.com\/Raspberry-Pi-Camera-Module-Megapixel\/dp\/B01ER2SKFS\/ref=as_li_ss_tl?ie=UTF8&#038;linkCode=ll1&#038;tag=clivsperswebs-20&#038;linkId=bdb375909b217e2816352837676a3d63\" rel=\"noopener\" target=\"_blank\">Raspberry Pi Camera<\/a> on your <a href=\"https:\/\/www.amazon.com\/RS-Components-Raspberry-Pi-Motherboard\/dp\/B07BFH96M3\/ref=as_li_ss_tl?ie=UTF8&#038;linkCode=ll1&#038;tag=clivsperswebs-20&#038;linkId=84a7793bbdc25a87ab07fda5b5cccb25\" rel=\"noopener\" target=\"_blank\">Raspberry Pi 3<\/a> is to build a prototype that takes a picture at the press of a button. Through such an activity, we will be able to experience:<\/p>\n<ul>\n<li>connecting a button to the GPIO ports on a Raspberry Pi.<\/li>\n<li>setting up a camera through the CSI interface of a Raspberry Pi.<\/li>\n<li>preparing an operating system, such as Raspbian Stretch Lite , for running Raspberry Pi projects.<\/li>\n<li>coding a Python 3 script that interacts with the GPIO port and camera on a Raspberry Pi.<\/li>\n<li>running a Python 3 script when Raspberry Pi powers on.<\/li>\n<\/ul>\n<p>Given these points, this post shows how you can build a Raspberry Pi 3 prototype camera that takes a picture at the press of a button.<\/p>\n","protected":false},"author":1,"featured_media":1117,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"footnotes":""},"categories":[375,4],"tags":[226,233,240,308,410,412,445],"jetpack_featured_media_url":"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/Raspberry-Pi-3-connected-to-push-button-and-camera-module.jpg","jetpack_shortlink":"https:\/\/wp.me\/p245TQ-4H","jetpack-related-posts":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/291"}],"collection":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/comments?post=291"}],"version-history":[{"count":0,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/291\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media\/1117"}],"wp:attachment":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media?parent=291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/categories?post=291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/tags?post=291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}