Arduino passive IR trigger for Canon EOS

The other day I wanted to experiment with external triggers for my Canon EOS 550D camera. I stumpled upon a nice open source project called Arduino Camera Control from Oleg Mazurov, the creator of the USB Host Shield library for Arduino.

The Arduino Camera Control project depends on the USB Host Shield library and the USB Host Shield from Sparkfun. It supports Canon EOS and Powershot, as well as Nikon DSLRs and P&S cameras. My main objective was sending commands to the camera for capturing images. The library does much more than that but if you want more detailed information about the library, you should read the original article on [email protected].

In this post I want to show you how to use a passive infrared module for triggering the camera to take a picture. First off, the list of things you’ll need for this project.

Now let’s connect all the parts like shown in the Fritzing schematic.

Before you can upload this project’s sketch, you’ll need to install some libraries into your Arduino IDE.
Now depending on the USB Host Shield you are using, there are two variants of libraries you can install. If you are using the Sparkfun USB Host Shield then you’ll need to install the following two libraries into your Arduino libraries folder (..\arduino-0022\libraries\).

If you are using the USB Host Shield 2.0 from [email protected], then please install the ported versions of the libraries found here.

Now after installing the libraries you can copy the following Arduino sketch in a new sketch window and upload it to the board.
#include <inttypes.h>
#include <avr/pgmspace.h>
#include <Max3421e.h>
#include <Max3421e_constants.h>
#include <Max_LCD.h>
#include <Usb.h>
#include <ptp.h>
#include <canoneos.h>
#include <MemoryFree.h>
#define DEV_ADDR 1
// Canon EOS 400D
#define DATA_IN_EP 1
#define DATA_OUT_EP 2
#define INTERRUPT_EP 3
#define CONFIG_NUM 1
//PIR definitions and declarations
#define SLEEP_MODE_PIN 4
int val;
class CamStateHandlers : public PTPStateHandlers
bool stateConnected;
CamStateHandlers() : stateConnected(false) {};
virtual void OnDeviceDisconnectedState(PTP *ptp);
virtual void OnDeviceInitializedState(PTP *ptp);
} CamStates;
void CamStateHandlers::OnDeviceDisconnectedState(PTP *ptp)
if (stateConnected)
stateConnected = false;
Notify(PSTR("Camera disconnected\r\n"));
void CamStateHandlers::OnDeviceInitializedState(PTP *ptp)
if (!stateConnected)
stateConnected = true;
uint16_t rc = Eos.Capture();
if (rc != PTP_RC_OK)
Message(PSTR("Error: "), rc);
void setup()
Serial.begin( 115200 );
delay( 200 );
//PIR related
digitalWrite(SLEEP_MODE_PIN, HIGH);
void loop()
val = digitalRead(MOTION_DETECT_PIN);
//the ePIR sensor is active low so if motion is detected the output is low
if(val == LOW) {
Arduino passive IR trigger for Canon EOS SchematicThe sketch is essentially just an extended version of the EOSCapture example from the Arduino Camera Control library. What it does is to poll the PIR sensor for changes. The PIR sensor used here is active low, so if the PIR sensor is triggered the signal on the motion detect pin becomes low, meaning the voltage on the pin is dropping towards 0V. If that’s the case, the Eos.Task() function will be called which sends a control signal to the camera instructing it to take a picture. That’s all there is.

Now upload the sketch to the Arduino board and connect your Canon EOS camera to the USB Host Shield. Turn on the camera and try triggering a photo by waving your hand in front of the sensor. If the camera wasn’t properly recognized by the USB Host Shield, try to select the M-mode on the camera or try to push the capture button on the camera. The board needs to establish a session with the camera before sending command transactions. If your board is still connected to your computer open up the Serial Monitor within the Arduino IDE to see if a session was opened.


For more detail: Arduino passive IR trigger for Canon EOS

This Post / Project can also be found using search terms:

  • arduino projects for canon
  • canon eos arduino
Clip to Evernote

Leave a Comment

(Spamcheck Enabled)

Read previous post:
Arietta G25 - Low cost Linux embedded module
Arietta G25 – Low cost Linux embedded module

Main features CPU Atmel AT91SAM9G25 SoC (ARM9 @ 400Mhz) DDR2 Ram 128 or 256 MByte Power supply: 5VDC via microUSB...

Scroll to top