{"id":2335,"date":"2019-07-04T20:54:36","date_gmt":"2019-07-04T20:54:36","guid":{"rendered":"http:\/\/www.daveakerman.com\/?p=2335"},"modified":"2019-07-04T20:54:36","modified_gmt":"2019-07-04T20:54:36","slug":"pi-in-the-sky-gopro","status":"publish","type":"post","link":"https:\/\/www.daveakerman.com\/?p=2335","title":{"rendered":"Pi In The Sky + GoPro"},"content":{"rendered":"<p>Although the Pi camera is a very good option for live imaging from a Raspberry Pi tracker, it does have its limitations -mainly due to its plastic lens which is a moderate wide angle and not as sharp as some.\u00a0 There are alternative lenses to try and some are very good, but they can mist up as the payload goes through clouds (but clear further up).<\/p>\n<p>I&#8217;ve tried various other camera options with the Pi.\u00a0 Webcams aren&#8217;t any sharper than the Pi camera, and USB cameras (e.g. a Sony compact, Gitup Git2) aren&#8217;t reliable for long periods.\u00a0 So I was interested when a couple of other HABbers mentioned a Python library for connecting wirelessly to a GoPro camera.<\/p>\n<h2>Wireless Connection<\/h2>\n<p>The first task is to get a Pi connected to a GoPro.\u00a0 The GoPro (Hero 4 Silver in my case) is set up as a wireless access point, using the GoPro Android app to set the camera name (SSID) and password.\u00a0 With that done these details can be added to the wireless setup on the Pi.\u00a0 To do that, edit this file:<\/p>\n<pre>sudo vi \/etc\/wpa_supplicant\/wpa_supplicant.conf<\/pre>\n<p>and add this to the end:<\/p>\n<pre>network={\nssid=\"gopro-SSID\"\nscan_ssid=1\nproto=RSN\nkey_mgmt=WPA-PSK\npairwise=CCMP TKIP\ngroup=CCMP TKIP\npsk=\"gopro-password\"\n}<\/pre>\n<p>Replacing the SSID and password with those you used in setting up the camera.<\/p>\n<p>You can use a Pi Zero W which is small, light and has reliable built-in wireless networking, or a Pi 3 A+, but the latter uses more power and will get hotter.\u00a0 Remember to have the GoPro on, with wireless enabled, before the Pi boots.<\/p>\n<h2>PITS Software<\/h2>\n<p>Install this using the usual instructions, though you can leave the Pi camera disabled.<\/p>\n<p>In pisky.txt set the &#8220;camera=&#8221; line to be:<\/p>\n<pre>CAMERA=P<\/pre>\n<h2>Python Dependencies<\/h2>\n<p>Run the following commands:<\/p>\n<pre>sudo apt install libturbojpeg0-dev libjpeg-dev python3-pip\nsudo pip3 install goprocam\nsudo pip3 install cffi\nsudo pip3 install jpegtran-cffi<\/pre>\n<h2>Python Script<\/h2>\n<p>A sample script gopro.py is supplied.\u00a0 This replaces the usual camera script so you should edit the startup script so that it runs the Python script not the old one; i.e. replace this line:<\/p>\n<pre>sudo .\/camera &amp;<\/pre>\n<p>with these:<\/p>\n<pre>sleep 10\nsudo python3 gopro.py &amp;<\/pre>\n<h2>Testing<\/h2>\n<p>To test, run the camera script manually, with the tracker program running in another terminal window (e.g. another ssh session).\u00a0 To run the tracker:<\/p>\n<pre>cd ~\/pits\/tracker\nsudo .\/tracker<\/pre>\n<p>and to run the script:<\/p>\n<pre>cd ~\/pits\/tracker\nsudo python3 gopro.py<\/pre>\n<p>If the script crashes with error &#8220;ValueError: unknown url type:&#8221; &#8220;, then the GoPro has no SD card &#8211; insert and format one &#8211; or the card is full.<\/p>\n<p>If the script crashes with error &#8220;FileNotFoundError: [Errno 2] No such file or directory: &#8216;\\t.\/process_image&#8221; then that means that the tracker was previously configured for the Pi camera; delete those and try again.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Although the Pi camera is a very good option for live imaging from a Raspberry Pi tracker, it does have its limitations -mainly due to its plastic lens which is a moderate wide angle and not as sharp as some.\u00a0 There are alternative lenses to try and some are very [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[],"_links":{"self":[{"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/posts\/2335"}],"collection":[{"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2335"}],"version-history":[{"count":4,"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/posts\/2335\/revisions"}],"predecessor-version":[{"id":2574,"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/posts\/2335\/revisions\/2574"}],"wp:attachment":[{"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2335"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2335"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2335"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}