Setting up your own Raspberry Pi controlled time lapse camera!
Here is step by step instructions on setting up the Raspberry Pi for a time lapse rig. These are my notes from the posts on my blog but in one concise tutorial. This is what I have learned has worked. I recommend you check out my blog articles for more information regarding the problems I ran into when setting this up the first time. These are the steps that I took as of January 2013 when I created this tutorial format. As software gets updated some of the steps may change slightly, but it should be possible to figure out how to get around that. You will need several items.
1. Raspberry Pi
2. SD Card (preferably 4GB or greater)
3. MicroSD power cable
4. Ethernet cable
5. Video cable (HDMI or adapter) for first connections
6. Keyboard for first connections
6. Camera (I used a Canon PowerShot A510 or A520) But any camera on this list should work.
7. Camera to USB cable to connect to Raspberry Pi.
8. Wall power for Camera for permanent power solution.
9. Case and other accessories
More information is avaible at my blog post here about the specifics.
Note: I am not responsible for any action you take. These steps worked for me without problem. But if you figure out what each command does before you run it, then you will learn a lot about the process of setting this up. Otherwise when something breaks you may not know what to do to fix it.
Step 1. Download the Operating System image and verify its authenticity.
Download Arch Linux ARM from http://www.raspberrypi.org/downloads. It should be around 200mb. The default username is “root” and the default password is “root” (without the quotes). The reason I am using Arch is twofold. One is that I am going to be running this without a graphical desktop. Since no one is going to be logged in for most of the time, there is no reason for the Raspberry Pi to have a graphical user interface. The second reason is originally I could not get gphoto2 to install correctly and recognize the camera using the Raspbian image. That may have changed, but because of reason number one I am going to stick with Arch.
After the image has downloaded you should check the integrity. I performed the next command under Linux to check the integrity.
Here are instructions for checking the integrity on other operating systems.
Check out this article for great instructions and introduction to Arch Linux.
Step 2. Write image file to SD card.
I performed the next steps on Linux, however this lifehacker article has good instructions for Windows and OSX as well. On that article only steps 1 and 2 are useful. Step three in their article has information reguarding the Raspbian image. I copyied the downloaded file to a new folder and then changed directories into that folder. The next command was run to extract the image file from the zipped folder.
Now you should have a .img file in that folder. That is the image file that we will use to write to the SD card. I recommend using Gparted to remove all previous partitions from the SD card. (This WILL remove all data from the SD card. Make a backup before doing this if you have data on the SD card that you want.) Right click on the partitions (make sure you have the right device first by checking that it is around 4GB) and choose delete. You may have to unmount the device before you can perform this action. You should then have one item listed and it should be listed as unallocated. Click apply to remove all partitions. Check the device name, it should be something like /dev/mmcblk0. The next command is very critical that its correct. It could wipe all data from another drive if not input correctly. The best option would be to boot into windows and use the tools there if that is better. Root (or sudo) is required to run the next command. The SD card should be unmounted before running this command.
dd bs=1M if=/path/to/image of=/dev/sdcard
The dd command is used to write the image to the SD card. The “bs” is specifying a block size. The “if” is the input file (the image file in this case) and the “of” is the output file (the SD card in this example). This process can take awhile and nothing may be printed to the screen till after its finished.
Step 3. Booting and changing the password
After it finished copying I removed the SD card from the computer and plugged it into the Raspberry Pi. Then I plugged in the HDMI and the Ethernet cable. Next was the power cable. It booted right up and I logged in using the before mentioned username and password (root and root). The best option is to change the password right now. Enter “passwd” at the commnand line and it will ask you for a new password, and then to reconfirm the password. Now that that is changed we can move on to the next steps.
Step 4. Checking and installing software and changing the hostname.
Edit the mirrorlist to make some mirrors available to the package manager. This allows the package manager to know where to go when searching for updates.
Some might prefer using nano instead of vi. If so, substitute “nano” for “vi” in the previous example. Remove the “#” in front of one or two of the locations nearest you. The next step is to update pacman and all of the packages. This process could take awhile.
Press “y” then enter if prompted to accept that it is ok to download and install these packages. Then enter the next command to install gphoto2.
pacman -S gphoto2
Once again press “y” then enter to accept the installation. Then the next command is to get openssh running. This is the server part that we will be connecting to later to download the images.
pacman -Sy openssh
Press “y” then enter to accept. The next command is “ifconfig” as that will find your IP address. Make a note of the IP address. I also like to change the hostname to something recognizable. The command below will accomplish that, but the Raspberry Pi will have to be rebooted before it will show.
hostnamectl set-hostname newhostname
Step 5. Rebooting and connecting via ssh from another computer.
At this point I turned off the Raspberry Pi and disconnected the keyboard, and unplugged the HDMI cable. I also plugged in the camera cable into the USB but did not connect it to the camera yet. I left the Ethernet cable plugged in so that from that computer I can login via ssh. From my other computer that is connected via Ethernet to the Raspberry Pi I entered the next command to login. Note that the IP address may be different.
It may ask you if you trust the identity and if you still want to connected. Type “yes” and hit enter. Then enter the new password that was created in a previous step. If all goes well you should be logged in to the Raspberry Pi from another computer! You can tell that you are by checking the command prompt. It should say something like “[root@yournewhostname ~]#” and then you know you are logged in to the Raspberry Pi.
Step 6. Checking to make sure that gphoto2 is working and can connect to the camera.
Now that everything is installed connect the camera cable that is plugged into the USB port on the Raspberry Pi into the camera (that is turned off and is plugged into wall power or has fresh batteries). For some reason the camera needs to be in “review” mode. Some cameras this is set by the dial and others it is set by a slider on the back. Then press the power button. The camera may put the lens out and then retract the lens right away. From the command prompt on the raspberry pi enter the following command to ensure that gphoto2 is installed and that it is connected to the camera. NOTE: (wordpress does not recognize a double dash. All gphoto2 commands are in this format “gphoto2 dash dash command” even though it looks like one long dash)
A lot of useful information can be gleaned from what it prints out. Another command for more information is this.
That will print out what the camera is capable of setting from the command line. Now it is time to test that it can take a picture and download that picture to the Raspberry Pi.
The camera lens should extract and it should take a picture. From the command line if you enter ‘ls’ there should be an image file there. That is good news if there is!
Step 7. Scripts
More on this to come soon!