Controlling a GoPro Camera

Discussion in 'Parts & Components' started by GlassKnees, Sep 6, 2016.

  1. GlassKnees

    GlassKnees Well-Known Member

    I have a hexcopter that uses an APM 2.6 flight controller/autopilot and Tarot 2 axis gimbal/GoPro Hero4 camera. I can shoot nice aerial video when I remember to press the record button prior to takeoff, but I've wanted to shoot still photos. Unfortunately, the APM cannot control the shutter like it can with a Canon or similar cameras.

    Then I found a solution on the DIYDrones.com website - Patrick Duffy posted the article, "How to control a GoPro Camera on APM/Pixhawk with a Raspberry Pi using WiFi". Basically, the idea is to put the camera into WiFi mode, where you can then control the camera remotely, such as by using an app on an iPhone or similar device. The phone is paired to the camera and you can send commands, such as change mode and trigger the shutter or start/stop video recording. Patrick's solution involves using a Rapsberry Pi board with a WiFi dongle attached to it on a USB port, establishing a WiFi connection between the Raspberry Pi and the camera. Then hooking up a wire from pin 9 on the API servo rail to a GPIO pin on the R.P. board, you can trigger the camera using your transmitter.

    Of course, you can bypass using the R.P. board and directly control the camera via your phone, but it can get awkward trying to fly the aircraft and handling your iPhone at the same time. Also, the range is limited - I just tried flying my quadcopter while controlling the camera via my iPhone and I lost the WiFi connection at only about 100 feet or so.

    Here is a block diagram of the set up:

    [​IMG]

    I modified Patrick's diagram slightly in that I want to toggle between "photo" and "video" camera modes as well as trigger the shutter or record/stop videos. For changing the mode, I can run a wire directly from my receiver to the R.P. board. For triggering the shutter, I need to go through the APM because there will be times, when I want to shoot a series of overlapping stills for creating 3D models of the terrain I'm overflying.

    Besides, the hardware above, you need a Python script to run on the R.P. to listen in on the GPIO pins and send the appropriate http commands to the camera. To see what the script would look like, see: https://www.dropbox.com/s/xffbtvl94zizxcn/MyGoPro.py?dl=0

    I haven't received my R.P. board yet, so I haven't implemented the solution, but I expect to have it working in a day or two after it arrives.
     
    Last edited: Sep 6, 2016
  2. olesailor

    olesailor New Member

    Hello I am looking at performing this project. Quick question which pin on the PI and more info on the camera mode selection.
    Thank You
     
  3. GlassKnees

    GlassKnees Well-Known Member

    S
    Sorry the late response - saw an email notification on my iPad and meant to go to my computer to respond but kept forgetting to do so!

    Anyway, to answer your question as to which pin on the Pi to use - I used GPIO 5:

    [​IMG]

    I did not fully understand the whole thing when I started - I thought that I could change the camera settings, but the original author did not do this - he assumed that the camera would be in Photo mode. It is possible to control the camera settings remotely, but you need to assign a receiver channel for mode changing, pick a GPIO pin on the Pi to poll for the signal and you would have to alter the signal coming from the receiver to the Pi, something I decided not to pursue.

    Here is a picture of my setup:

    [​IMG]

    I did manage to get my script working and I was also able to get the pi to automatically connect to the camera upon power up. I configured the APM to trigger the camera, going through instructions and using Mission Planner. I also assigned a channel on my transmitter, and I was able to confirm that the APM received the shutter signal, but I never got an output signal from the APM to the Pi. At that point, I gave up.
     
  4. Grafik

    Grafik New Member

    Hi. I have a friend with a DJI Phantom 3, and he can control his camera via the gimbal in flight. I am interested in getting a gimbal and a GoPro for a Hubsan X4 I have, so that I can also control the camera in flight. Do you know of anything like this?
     
  5. GlassKnees

    GlassKnees Well-Known Member

    Sorry for the late response - I was out of town. I can't help with a Hubsan as it uses a different flight controller. I don't kow of anyone who has tried to mount a gimbaled camera on a Hubsan - sorry.
     
  6. Atico F

    Atico F New Member

    Hello glasskness,
    I would like to control one Gopro4 as you comment, using a Raspberri Pi Zero WIFI and Pixhawk. Could you update your dropbox link to download the Phyton script? I have not idea about phyton but I will try.

    Regards
     
    Last edited: Aug 8, 2018
  7. Carter7868

    Carter7868 Well-Known Member

Share This Page