This post will describe how to control a GoPro camera (usually mounted on a gimbal), via a Raspberry Pi with a USB WiFi dongle. 

3689649827?profile=original

The ideal Raspberry PI for this setup is the A+ model because it is small and has the needed single USB port for the WiFi dongle. 

Parts List:

1 GoPro Camera 

1 Raspberry PI (suggest A+ model, but any PI will work)

1 USB WiFi dongle (PI approved) Suggest this one: AirLink N150

2 Jumper wires or 1 servo header that can plug into 1/10th center pins (with center power pin removed)

1 APM or PixHawk board

Of course, all of this is mounted on your Quad or Plane or whatever. On my hexicopter, the PI is powered by one of the ESCs UBEC outputs, where I cut a micro-usb cable and soldered the 'red' and 'black' wires to the power output of the UBEC of the same color. The other two USB wires are not used.

Setup:

Step 1: Enable the GoPro WiFi access:

The first step in making all of this work is to configure your GoPro camera to accept a WiFi connection. The camera is actually a WiFI access point. 

The details on how to setup your camera is here. If you can connect the GoPro App to the camera, then you can connect the Raspberry PI. You should verify that the GoPro WiFi is working with the GoPro App BEFORE proceeding to connect the PI. You can pick a unique access point name for your camera and use the same name in the Raspberry PI configuration when connecting to the camera with the PI.

Step 2: Connect the Raspberry PI to the GoPro Camera's WiFi:

Once you have established the camera's access point and assigned a name and password, you can make an entry in your PI's network configuration file to configure the connection.

From a shell prompt type the command:  sudo nano /etc/network/interfaces

Add some lines to the file as follows:

allow-hotplug wlan0

iface wlan0 inet dhcp
wpa-ssid "mygopro"
wpa-psk "mypassword"



Reboot the PI and it should automatically connect to the GoPro.

Step 3: Communicate with the GoPro

The GoPro camera should have the standard IP address of 10.5.5.9. If you can ping this address, you have successfully connected to the GoPro so now you are ready to send it commands.

The list of commands are here.  The camera is controlled by sending HTTP request commands in the form of a header string. 

for example, this string turns the camera on:

http://10.5.5.9/bacpac/PW?t="wifipassword"&p=%01"

Where 'wifipassword' is the password you set when configuring your GoPro.

You can experiment with sending commands with a web browser to get familiar with how to control the camera with web requests or write your own scripts.

Step 4: Use a Python Script to Control the Camera

Attached is a sample python script that will listen for a signal on GPIO pin 5 on the PI header, and send a request to the camera to take a picture when triggered.

gopro.py

To use the code, start the python script after connecting to the camera with the following command:

sudo python3 gopro.py -photoMode

This will start the script with the camera set to take pictures. If you want it to trigger a video instead, leave out the '-photoMode' option.

Step 5: Configuring APM or Pixhawk to send the signal to the PI

To use this setup with the APM or PixHawk control board, you need to connect the output of the 'relay' pin (A9 on the APM), to the GPIO pin 5 on the PI (or the pin of your choice).  The script is configured to use GPIO pin 5.

Here is a picture of the APM board from This link

3689649845?profile=original

The PI pinout is here

3689649876?profile=original

Connect Pin 29 (GPIO 5) on the PI to A9 (S) on the APM, and GND pin 30 on the PI, to GND A9 (-) on the APM.  Check the link on the APM website for the PixHawk settings for the relay output pins as I have not used PixHawk (yet).

Step 6: Configure your Radio to Trigger the Camera

In Mission Planner, you will need to select which channel on your radio to assign to trigger the camera input. 

This link describes how to configure the shutter.

3689649750?profile=original

Select "Relay" for the Shutter output (not RC10 as shown in the above image example).

Then set the Ch7 option to "Camera" as shown here:

3689649897?profile=original

This can also be set on the "Advanced Parameters" setup area.

Step 7: Start Script on Boot:

To make all of this automatic, you can configure your PI to always connect to the GoPro and start the script when the PI boots. Or you can do it manually when you want to fly. 

To make it automatic, you can modify your '/etc/rc.local' file to make the script start on boot. Here is a sample rc.local file:

rc.local

Once you have completed all of these steps, you should be able to trigger the camera to take a picture with a switch assigned to Ch7 on your radio. 

If you want to GeoTag your images, you can follow the instructions at the ArduCopter GeoTagging page.

Happy flying.

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • I was able to get my new RPI in and running.  I've connected to the APM and it will trigger the GoPro constantly (every quarter second).  How do I get it to fire every 2 seconds?  I'm not worried if the plane is fly or not, I just want the APM to trigger the camera every 2 seconds. (Currently I just turn the cameras on Multi-Shot, 2 sec interval but I want the APM to trigger for better georeferencing.)

    I do not have the Ch7_OPT as shown in the blog above.  Maybe that's for Copters only.  I have APM:Plane.  I also don't understand why it says to change the "Shutter" to "Relay".  Seems like this would be RC9 since the RPI is connected to RC9.  Thanks.

  • @Patrick, thanks a lot again ^^

  • Patrick, I was able to get the Python code working after reviewing other Python code.  Although I didn't use the ping command, I was able to get the RPI to activate the shutter upon boot of the RPI.  I was attempting to test using the APM to trigger the camera via the RPI but ran into another issue.  I believe my RPI A+ is bad now as I cannot get video from it. Maybe static discharge, not sure, but trying to troubleshoot now.   I'm having another shipped to me tomorrow just in case.  

  • @Richard,  when you log into the Raspberry PI, can you ping the camera at 10.5.5.9?  

  • @Kyomo Jung.   You can configure the RPi to forward a specific port to another IP address, it's not necessary to make it act as a router.  I am out of town at the moment but I can send you a script on setting up the forwarding as soon as I get back to my desk.

  • Has anyone had any luck getting this to work yet?  I'm getting close but having all sorts of issues with the Python 'gopro.py' code.  I am not a programmer although I've done a little in the past.  I had hoped to just copy/paste the code and go with it (except to set the wifi password).  Any help would be appreciated or if you have the gopro.py code working, sending a copy would be even better. :) Thanks in advance.

  • @Patrick, thanks so much for sharing. You told  "

    The ip address should be the address of your RPi  with port 8080 forwarded to  10.5.5.9:8080 If you also forward port 80, you can directly control the GoPro using the utility here: http://cam-do.com/WiGo/" and it seems like Rpi acts as a router. I googled how to implement it but only thing I found is how to access Rpi Server from outside. It'll be very appreciated if you give a link or how to do to me. Thanks in advance Patrick.

  • @Marc,  it will depend on which version of the kernel you are using. Unfortunately, you can't just install a module built on one kernel into another version.  If you have the build tools installed, try the 'make' command from a terminal window and see if it builds the driver.  

  • @Patrick,

    Compiling the driver is out of my competence. I downloaded the archive from github and installed the latest GCC but I do not know what to do with all the files.

    If you can post the archive ready to "sudo make install", I should manage to do it.

    Thanks,

    Marc

  • I will have a look,

    Thanks,

    Marc

This reply was deleted.