Arduino passive IR trigger for Canon EOS

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 Circuits@Home.

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.

IR trigger for Canon EOS

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 Circuits@Home, 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
#define MOTION_DETECT_PIN 2
int val;
class CamStateHandlers : public PTPStateHandlers
{
bool stateConnected;
public:
CamStateHandlers() : stateConnected(false) {};
virtual void OnDeviceDisconnectedState(PTP *ptp);
virtual void OnDeviceInitializedState(PTP *ptp);
} CamStates;
CanonEOS Eos(DEV_ADDR, DATA_IN_EP, DATA_OUT_EP, INTERRUPT_EP, CONFIG_NUM, &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);
delay(1000);
}
void setup()
{
Serial.begin( 115200 );
Serial.println("Start");
Eos.Setup();
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) {
Eos.Task();}}
 IR trigger for Canon EOS Schematic

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

 

Read more: Arduino passive IR trigger for Canon EOS

Leave a Comment

Your email address will not be published. Required fields are marked *