Pi In The Sky + GoPro

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.  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).

I’ve tried various other camera options with the Pi.  Webcams aren’t any sharper than the Pi camera, and USB cameras (e.g. a Sony compact, Gitup Git2) aren’t reliable for long periods.  So I was interested when a couple of other HABbers mentioned a Python library for connecting wirelessly to a GoPro camera.

Wireless Connection

The first task is to get a Pi connected to a GoPro.  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.  With that done these details can be added to the wireless setup on the Pi.  To do that, edit this file:

sudo vi /etc/wpa_supplicant/wpa_supplicant.conf

and add this to the end:

pairwise=CCMP TKIP

Replacing the SSID and password with those you used in setting up the camera.

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.  Remember to have the GoPro on, with wireless enabled, before the Pi boots.

PITS Software

Install this using the usual instructions, though you can leave the Pi camera disabled.

In pisky.txt set the “camera=” line to be:


Python Dependencies

Run the following commands:

sudo apt install libturbojpeg0-dev libjpeg-dev python3-pip
sudo pip3 install goprocam
sudo pip3 install cffi
sudo pip3 install jpegtran-cffi

Python Script

A sample script gopro.py is supplied.  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:

sudo ./camera &

with these:

sleep 10
sudo python3 gopro.py &


To test, run the camera script manually, with the tracker program running in another terminal window (e.g. another ssh session).  To run the tracker:

cd ~/pits/tracker
sudo ./tracker

and to run the script:

cd ~/pits/tracker
sudo python3 gopro.py

If the script crashes with error “ValueError: unknown url type:” “, then the GoPro has no SD card – insert and format one – or the card is full.

If the script crashes with error “FileNotFoundError: [Errno 2] No such file or directory: ‘\t./process_image” then that means that the tracker was previously configured for the Pi camera; delete those and try again.

You can leave a response, or trackback from your own site.

Leave a Reply

Subscribe to RSS Feed Follow me on Twitter!