APM to CHDK Camera Link Tutorial

[Edit 12/31/2015: Note for Pixhawk users that Canon cameras require a 5V pulse to trigger so a voltage step-up from Pixhawk's 3.3V output is required. See compatible cable and link to more instructions here.]

ArduPilot Camera Tie-In Tutorial

This tutorial will show you how to get your CHDK-enabled camera connected to your ArduPilot Mega (APM) without buying any extra hardware or decoding PWM outputs. You might want to make this connection to take advantage of the camera trigger function based on distance covered, to ensure a certain overlap and to avoid excessively high overlap. This modification is not necessary, if you have a CHDK camera and want to keep it simple, you won’t gain much by switching to this method right away.

For this tutorial, I’ll use an SX260 HS but this should work equally well on any CHDK-supported Canon Powershot camera. You’ll need just the supplies below to make the cable. The SX260 uses a USB Mini-B connector. Most Powershot cameras come with a USB cable, you can just use that one to be safe.

APM CHDK Connection

If you don’t have a crimp tool to attach the servo connector, just take a spare servo wire and solder the wires together instead.

We’ll only be using the Mini-B side of this cable, so measure whatever length you need from that end depending on how your camera and autopilot mount in your airframe. I’ve measured out about 14″ and cut the cable completely through. Inside are four wires, we only need the red and black wire so cut away the green and white wires. Strip the ends of the red and black wires.


If you have the crimp tool, crimp and insert the wires into the first and third positions of a 3-position header. If you don’t have the crimp tool, solder these two wires to the ground and signal wires of a spare servo wire. Insert the ground wire into the side with an arrow so you can tell which wire is which later on.


Cover the connector with heatshrink. Be careful with the hot air near the connector as it can cause the locking plastic pieces in the receptacle to deform.

CHDK Cable

Now plug this cable into pin A9 on the side row of APM. The text doesn’t line up exactly so be sure to count rows. SPI takes two rows, then A11 and A10 are two more so there should be 4 rows of free pins, then our new connector.

APM Relay Pin A9

If you already have CHDK installed, just install the script file (right click, save link as) into the scripts directory on your SD card. If not, follow instructions for installing CHDK from the page corresponding to your camera atthe CHDK wiki. Load up CHDK and go into the menu then navigate to Miscellaneous Stuff -> Remote Parameters and make sure the Enable Remote setting is checked.


Now connect to your APM and open the Full Parameters List in the Config/Tuning tab. Set the parameters as following:

  • CAM_TRIGG_DIST: Depending on overlap required.. be sure to keep in mind the normal downwind speed of your plane as well as the maximum rate at which the camera can take pictures. For the SX260 and the E382 that’s once every 2.7 seconds and about 18m/s. I plan to operate below those condition in most cases but I do like to get as many pictures as possible, so I set my distance to 49 (meters).
  • RELAY_PIN: 13



All that’s left is to test it out. Load the E38_APM.bas script file like any normal CHDK script and start running it. If you can get a 3d fix inside, you can test it on your lab bench just using USB power. Just set the CAM_TRIGG_DIST to 1 or 2 meters and let your plane sit on the desk. Small movements between GPS readings will cause the distance value to count up slowly and it should trigger the shutter every few seconds.

If your camera lens closes and opens instead of taking a picture, make sure the CHDK remote enable setting saved properly. If nothing happens at all, take your APM outside and walk around to make sure you are getting some distance covered.

Original Post

E-mail me when people leave their comments –

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

Join diydrones


  • hi jeff,

    i can trigger shoot using RC ch7   . pin using A9 APM as relay. same cable as yours.

    if the camera pointing near object it works which is chdk focus and shooting,

    problem now if the object is far away. the trigger just focus only not shooting.

    am i missing the setting?


  • For those who still have the lens to expand / retract for each pic, pls note that the new version of CHDK seems to be facing problems about saving parameters.

    In other terms, you change the relevant parameter, lens stop from expanding / retracting, then you switch the camera off, and when it is on again, you are left with the same lens problem... So as a quick fix just go back to the same relevant paramater and re-press OK...

  • Finally got around to making a cable. I have my APM sitting on my desk in the house with CAM_TRIGG_DIST set at 2 meters. The GPS is moving around quite a bit, so it's taking plenty of pictures. I'm running ArduCopter V3.1.2.

    Thanks a bunch Jeff :)

  • When will  this be available in the ArduCopter Firmware?

  • Nice script @Jeff! It's worked great on my tests so far!
    I'm not sure if this is the right forum to put in requests but I agree with @Hernan that if a power down cam function was available via a rc switch signal or special waypoint number then that would be the last function needed for simple mapping missions.
  • You might want to check this tutorial for other options:


  • Hi Javier, I have the same camera (Sony NEX7), and the TinySnapper (sony model).  I just received my 3DR X8.  I am trying to figure out how to setup the same thing.  I would like to use the UAV for photogrammetry work, using the Mission Planner Survey tool.  Did you figure out how to get the TinySnapper and APM to work?  Did you use A8 port on the APM board? What did you set the trigger method to be?  

    Although I don't have a gimbal (just temporally hard mounting the camera on to the airframe for testing), I was thinking I could use the Shutter function in the Gimbal hardware setup page.. and use the TriggerMethod DO_DIGICAM-CONTROL from the survey tool.. 

    Let me know if you got your setup to work.. 

    Much thanks!


  • maybe this script will help http://chdk.wikia.com/wiki/KAP_%26_UAV_Exposure_Control_Script 

  • Hi, I want to use the CAM_TRIGG_DIST feature to trigger a Sony NEX 7 camera through an infrared shutter, and I wondering if this feature will work along with this kind of device using the relay option or I´ll need to use the servo type, using the same A9, or it's necessary to use the OUT8 port?. The device that I'll use is the TinySnapper from Little Smart Things (or any similar), that accept a 5v input signal. If any of you have another idea,  I'll appreciate any suggestions.


  • @Jeff,
    Do you normally fly in Tv mode with auto aperture?
    What are the recommended settings?
    Our photos from 69 meters are ok, but they are not as sharp as I think they could be.
This reply was deleted.