Introduction: Smartphone Camera Remote!
Ever wanted to wirelessly control your camera? Perhaps you have an upcoming event that needs a photobooth, or maybe you just want to spy on your cat while you're at work. (You knew those goldfish weren't just disappearing...) This project will show you how to control certain features of a Canon camera through WiFi with the help of an Arduino and your smartphone! You won't even need any advanced coding skills--this Instructable makes use of several nifty hacks to make the process as streamlined as possible.
Before continuing on, make sure you have Java and the Arduino software environment already installed on your computer. For this project, I will be using a Windows computer.
If you like my project, please vote for me in the Tech Contest!
Alright, let's get started!
Step 1: General Outline
This Instructable consists of several parts. We will be installing CHDK, which stands for the Canon Hack Development Kit. It is used to enhance the capabilities of certain Canon cameras, and it also allows us to remotely control the shutter function of our camera. By supplying 3-5 volts to the USB port on the camera, we can control how our camera takes photos or videos. However, this method requires the user to be close to the camera and manually supply the voltage every time the user wants to take a picture.
The Arduino is capable of outputting 5V. By using a smartphone app called Blynk, we can wirelessly connect our phone to our Arduino and control when the Arduino outputs 5V. Blynk supports both Ethernet and WiFi; however, we will be using a computer to provide the WiFi connection for the Arduino. (You can use a WiFi shield built for Arduino, or similar hardware, but that's out of the scope for this project.)
For this project, you will need:
- Canon camera, with CHDK support (Check this page to see if your camera is supported)
- Arduino UNO, with accompanying computer cable
- Mini-USB to USB cable
I own a Canon A4000 camera, and we'll start by installing CHDK for it.
*No kittens were harmed in the making of this Instructable.
Step 2: Installing CHDK
For this step you will need:
- a formatted SD card
- and your computer.
CHDK is a firmware enhancement, and it is loaded into your camera's memory when you turn it on. We will be putting CHDK on the SD card and making it bootable for the camera.
Warning: while CHDK does not technically void your camera's warranty, use it at your own risk. It is considered safe, however, as it does not modify the original firmware of the camera in any way.
The easiest method of installing CHDK on your SD card is using a utility called Stick. Download the zip file for Stick, and unzip it to a convenient location. You can download Stick at this website.
Open the folder containing the unzipped files, and double click the file "stickx.cmd". Since I am running a 64-bit computer, this will let me run the Stick utility with admin privileges. You should see something like Picture 2.
Browse for a picture that you have taken with your particular camera, and make sure the option "Stable (1.3) CHDK (default)" is checked. If your camera is supported, then you should see something like Picture 3. Now click the "Download" button. Once the download finishes, you should see something like Picture 4. Insert your SD card into the computer, and click "Scan for Cards?". If your SD card was recognized, you should see something like Picture 5. Click "continue to Install Step", and right afterwards, click "Install CHDK".
If you've made it this far with no problems, congratulations! You're one step closer to making your camera awesome! You can now click "Safely Eject Card" and remove your SD card from your computer. The Stick utility will then notify you to put your SD card in the "Lock" position. (Usually, this is accomplished by sliding the little tab on the side of the SD card.) This is very important!
Step 3: Setting Up CHDK Settings
Insert your prepared SD card into your camera, and turn it on. You should see the CHDK splash screen, and then "No Image". Press the shutter button on your camera to exit Playback mode.
Now, depending on your certain camera model, the CHDK mode only appears with a certain button press. See this page for your particular camera. My A4000 requires me to hold the Playback button to access the alternate (<ALT>) CHDK mode, and a little red <ALT> indicator will show up at the bottom of the camera screen (See Picture 1). This is the mode that allows you to enhance your camera's capabilities--in order to return to normal camera operation, just press the same button to exit <ALT> mode.
Once your camera is in <ALT> mode, press the Menu button of your camera to access the CHDK Main Menu. Scroll down to "CHDK Settings" and select it. Scroll down to "Remote Parameters" and select it. You should now see a menu that looks like Picture 2. For now, we will set the camera to focus and take one picture when it receives a trigger from the Arduino. Using your camera's buttons, set the remote parameters to Enable Remote, Switch Type "OnePush", and Control Mode "Normal". (See Picture 3)
Now press the Menu key on your camera to exit the settings menu, and set your camera aside.
Step 4: Making the Modified USB Cable
In order for us to connect our Arduino to our camera, we'll need a USB cable compatible with our camera. My A4000 uses a mini USB cable, and I was lucky enough to have one laying around.
Start by snipping off the USB end of the cable (Picture 1). Use a sharp blade to strip off about 2" of the outer housing of the cable, exposing the protective wiring underneath. You can discard both this protective wiring and the aluminum foil that surrounds the 4 smaller wires. Using a wire stripper, carefully make an incision about 1/2" into the red wire, and manually remove the red sleeve. IMPORTANT: twist the sleeve while removing it to ensure no fraying occurs (Picture 5). Repeat the process for the black wire. You won't need the green or white wires for this project.
You should get something like Picture 7 when you're finished!
Step 5: Setting Up Blynk
Now, we need to set up the communication between our smartphone and our Arduino. Since I'll be using an Android phone, I downloaded the Blynk app from the Google Play Store. Launch the app, and create an account. Once you've created an account, log into the Blynk app, and you should see a screen that says "Create New Project" (Picture 1). Tap on it to name your project, and make sure "Arduino UNO" is chosen as the hardware model. You'll also notice an "Auth Token" with a long string of letters and numbers. Email this to yourself--we'll need it later to sync our Arduino and Blynk app together. When you're done, tap "Create" (Picture 2).
Blynk is essentially a blank canvas for adding "widgets" that can control or monitor our Arduino. We'll be using it simply to tell our Arduino to output 5V whenever we want to take a picture. First, tap the plus icon in the upper right hand corner. You'll see a menu with many different "widgets"--tap on the "Button" under Controllers. A Button "widget" will now show up on your app screen. Tap on it so we can modify the button's settings.
On this screen (Picture 3), you can rename your Button, change its color, select the Arduino pin that the Button will control, and set the Button's mode. We're only interested in the pin and mode. Tap on "PIN" and choose "Digital D13", and make sure the Mode is set to "PUSH" (Picture 4 & 5). When you're done, tap the back button. You're all done setting up Blynk! Let's move on to the Arduino portion.
Step 6: Setting Up Arduino
Assuming you already have it installed on your laptop, launch the Arduino IDE. For this step, we will need to install additional libraries in order for the Blynk smartphone app to connect with our computer. (For more information on libraries, you can check out this Arduino page.)
Download the required library from the Blynk website, and save it somewhere convenient. In the Arduino IDE, click Sketch → Import Library → Add Library... and browse to where you saved the Blynk library. Double click the zip file and the library should automatically be imported. When you click Sketch → Import Library again, the blynk library should be at the bottom of the list. (See Picture 1.)
Navigate to File → Examples → blynk-library-0.3.0 → BoardsAndShields and click on Arduino_Serial_USB (Picture 2). A new window should pop up. Select all of the text in the example and copy it to the original Arduino window, and then close the example. Navigate to File → Save As... and save your sketch somewhere convenient. I called mine WiFi Camera Project.
Step 7: Linking Arduino and Blynk Together
The example code that we just copied gives us instructions to connect our Arduino to Blynk. First, retrieve the "Auth Token" that you emailed to yourself. Copy and paste it where the code says "YourAuthToken", but make sure not to remove the quotation marks (Picture 1). Connect your Arduino to your computer and upload the sketch.
Now navigate to the folder where Arduino stores its libraries. Mine is located in the Documents folder of my computer. Find the blynk-library-0.3.0 folder and double click it (Picture 2). Find the scripts folder, right click the "blynk-ser.bat" file, and click on "Edit". You should see something that looks like this at the beginning:
REM === Edit these lines to match your need ===
By default, the communication between the laptop and the Arduino occurs through the COM1 port. We need to make sure that this line of code matches the port that our Arduino is actually connected to. In the Arduino IDE, click Tools → Serial Port, and see what serial port your Arduino is using. Mine, for example, is using COM3. Therefore, we need to change the line of code to the following (See Picture 3):
Save the file, close the window, and now double click on the "blynk-ser.bat" file. A command prompt like in Picture 4 should pop up. So far, so good! Now, go back to your Blynk app, and tap the Play icon in the upper right hand corner. When you tap (or hold) on the Button widget that you have made, the LED light next to pin 13 on your Arduino should light up. If it does, congrats! You've just finished the software part of this project.
Note: You will need to have the command prompt window open in order for this to work.
Step 8: Test It Out!
Alright, let's bring all of the components of this project together! Connect the red wire to Pin 13 of the Arduino, and connect the black wire to the GND pin (See Picture 1). Now connect the other end of the cable (for me, it's the mini USB end) to your camera.
Now, if your Blynk app is still running (if not, just press the Play icon again in the corner), tap and hold the Button widget. This lets the Arduino know to output 5V at Pin 13. As long as you keep pressing the Button widget, there will be a 5V output at this pin. Given the CHDK settings that we set earlier, your camera should now have tried to focus on whatever is in front of it. When you release the Button widget, your camera should take a picture!
"OnePush" and "Normal" CHDK settings determine how the camera takes the picture. When a 5V signal is received, the camera simulates the shutter button being half-pressed. When the 5V signal is stopped (as in when you stop pressing the Button widget), the camera simulates a full press of the shutter button, therefore taking a photo. The next step explains some more useful settings for remote operation.
Step 9: Extra Tips With CHDK
CHDK allows you to tweak a lot of camera settings, and there's even quite a bunch for remote camera operation. Perhaps you don't want to hold down the Button widget to focus, and then release it to take a picture. Maybe you want the camera to take a picture as soon as you tap the widget. Well, CHDK has a setting just for that! Keep the Switch Type to "OnePush", but change the Control Mode to "Quick". Now, your camera will focus, set the exposure, and shoot all-in-one once you press the Button widget.
CHDK also allows you to remotely start video recording! Again, keep Switch Type to "OnePush", but change the Control Mode to "Video". Now, once you press the Button widget, the camera will start filming! You can tap the widget again to stop filming. For more tweaks, check out this page to see what other remote features you can use.
Thanks for reading, and happy picture taking!
Participated in the