All things Raspberry Pi and Time Lapse

Posts tagged ‘canon’

Finished and Uploaded!!

The video of the compilation of over 3 months is edited and uploaded! It has been 3 months since I setup the Canon PowerShot camera and Raspberry Pi in the greenhouse to watch the plants grow. And grow they did! The greenhouse starts out empty and in 15 seconds the plants are ceiling height. It was just under 90 frames total because some of the frames were too dark to use. And unfortunately some of the current images are pretty dark. But it worked!! And now I know what to change so that the images are not as dark for next time. Let me know what you think in the comments!

https://vimeo.com/57635944

 

Now I am looking at setting up for a year – as was my original goal…

 

Back up and running

It is all setup again – as of Saturday – and should be taking pictures. Here is a shot of what it looks like now. All of the tomato plants have been removed and the new ones will be planted soon.

Something that started to concern me was Daylight Savings time. This would be a problem if the camera changed time and then the power went out. The raspberry pi would pull the new time and it would be an hour off of what it was before. I contacted Canon about this potential issue. And they tried to sell me one of their newer cameras that has this feature. But they said that the Canon Powershot A510 does not have this feature. I could not find this option on the SX100 either. However this is a good thing as it means I am safe from having to worry about that. It will definitely be something to think about in the future however.

I changed the way the scripts were written and so I will post them and the updated crontab hopefully sometime early next week.

Problem Solved!

I now know what the problem with the time lapse setup was. For some reason Canon decided to put every like 100 pictures into a new folders and name the folders 157CANON and 158CANON and so on. So it was leaving these pictures on the camera card and not downloading them onto my card. This causes a problem because the card (in the camera) filled up and then it stopped taking pictures. That makes sense why it wont take a picture when the card is full, but it doesn’t make sense why Canon operates this way. However this is the easy part of the problem. The harder part was getting it to take a picture again. I would reformat the SD card using the cameras reformat option and then try to take a picture from gphoto2. It would give an “unspecified error” and that was not very helpful in figuring out the problem. The solution (which took me forever to figure out) was that the first picture has to be physically taken from the camera. After that first picture is taken by actually pushing the physical button on the camera, then gphoto2 will take pictures just fine.

So the solution is to make sure that I take that first picture and then make sure that the SD card does not fill up. This is possible to achieve from gphoto2 because it is possible to naviagate into the sd card that is in the camera by issueing the command

gphoto2 –shell

and then some* of the regular linux commands work. I say * because very few work and those that do have minor quirks. The main command “cd” works like normal, but there are some issues with tab completion. I wrote this script that uses a here document to actually execute the commands. This was the only way I could figure out how to get it to work. This script is not finalized because I think I will actually want to save the pictures that it is leaving in this folder until I can be certain that it is downloading the same picture onto the Raspberry Pi. (UPDATE) I setup and let it shoot for a day as a test and I confirmed that it is starting a new folder every 100 pictures. And it is NOT saving a copy of it to the Raspberry Pi. It takes the 100th picture and leaves it on the card. And leaves it in the terrible naming format as well.

#!/bin/bash
# jamesmiller
To be updated….

Hopefully going to install the project back in the greenhouse this weekend!!

Update… And its not good…

I went to check on how the time lapse setup was working. And it was not. It worked for not quite a week and then stopped taking pictures for some reason. So I brought it home and have been working to see what was wrong. And so far I cant figure it out. I cannot get the camera to take a picture using gphoto2 anymore. I tried a whole new installation of Arch (I kept the previous one separate) and it still wont take a picture. The other camera that I had bought previously (Canon Powershot SX100) will work just fine though. So that would lead me to believe that the Powershot A510 wont work. However, the camera will still take a picture just fine when it is disconnected from the Raspberry Pi and functioning like a regular camera.

So now I am not sure what to try. It seems like it is a problem with the camera, but the camera will still take a picture so it didnt completely die. Anyone have any suggestions?

Time Lapse shot on Canon S2IS

This is my Vimeo video link that I shot about half of a year ago. I setup my Canon Powershot S2 IS under our orange tree shooting the clouds that were particularly awesome that day. This is the result!

 

The second one is one that I shot using the same camera of some ice cubes melting. This one provides what I think of as a time lapse perfect opportunity. There would be no other way to capture this!

 

http://vimeo.com/36116642

http://vimeo.com/36520044

Raspberry Pi – how to set the system clock using a Canon Camera

Now that I have my Raspberry Pi I wrote and tested the script to set the time on the Raspberry Pi using my Canon Powershot A510. This is a follow up of my previous post. This is tested and works with a Canon Powershot A510 but it may work with other Canon Cameras, however some may require a little modification to the script.

#!/bin/bash
# jamesmiller
# 2012-07-16
# this script works with the Canon Powershot A510
# other models may or may not work
#
# use gphoto2 to get the camera time
camera_time=`gphoto2 –summary | grep -i “unix time” | cut -d ” ” -f4`
# for some reason I had to subtract some time to get it to be correct
camera_time=$(($camera_time – 3592))
# convert UNIX time to readable time
time=`date -d @$camera_time`
# the next four (4) lines cut the timestamp into specific parts so
# that it can be used when setting the time
b=`echo $time | cut -d ” ” -f2`
c=`echo $time | cut -d ” ” -f3`
d=`echo $time | cut -d ” ” -f4`
f=`echo $time | cut -d ” ” -f6`
# this sets the variable real_time equal to the values from gphoto2
# and puts them in the correct order
real_time=`echo $c $b $f $d`
# set the system time equal to the time from gphoto2
date -s “$real_time”

And this script is put into a cron job that is set to run at startup using these details here.

@reboot /path/to/script

If the power goes out and the camera and the Raspberry Pi shut down, when the power comes back the camera should startup faster than the Raspberry Pi and when the script runs it can set the time correctly. The camera has a small battery to keep time, and it will last for a long time with no power and still keep time.

Everything is setup outside my window taking pictures of our garden today. This is my chance to test and get all of the bugs worked out before I setup for a long period of time. Already I have changed several things and I updated the scripts post to reflect these changes.

I will probably post pictures of the setup tomorrow along with the time lapse that it is taking today.

RaspLapse Update

It was a little disappointing yesterday because my Raspberry Pi was supposed to ship from Newark/Element14 and it didn’t happen. The new ship date is July 5th July 12. But since this is the second third (or third fourth? I am losing track…) time they have moved the ship date I am not expecting it to ship on the 5th 12th of July.

An update on the Canon Powershot A510 is necessary as well. When the camera arrived it would not keep the date/time when the batteries were removed. This lead me to believe that the date/time battery was dead. After searching online I confirmed my suspicions. So I bought a pack of them from Amazon. It is really important that the camera can keep time when the power is off so when the Raspberry Pi starts it can get the time from the camera. And now with the new battery that will be possible.

Really looking forward to getting the Raspberry Pi and start testing! (Maybe someday I will get one….)

 

EDIT (June 02) – Just finished an online chat with Newark/Element 14 asking about the ship date being moved farther and farther back. His reply was that there was an unexpected development issue and it pushed ship dates back about 1-2 weeks.

Plan B

The Canon Powershot S2 IS will not fit in the enclosure with the cables connected. So after thinking about the requirements for the camera, I decided that CHDK is not a requirement like I originally thought. I can do everything from gphoto2 using scripts. So I ordered a Canon Powershot A510 from Amazon that is much smaller and as near as I can tell will fit in the enclosure. Now just waiting for it to be delivered!

BOM (Bill of Materials)

Here is a list of the materials (that I have though of so far) needed for the year-long time lapse.

First thing is Location. Its all about location, location, location.

1. A RaspberryPi. This is to control the camera and tell it when to take a picture. It would be possible for the camera to take a picture at certain times, but with the Raspberry Pi there will be more control over when the pictures are taken. This should cost $45 after shipping + handling.

2. A power cable to power the Raspberry Pi. I am planning on using an HTC micro USB cable that is here on Amazon that is $4 after shipping + handling.

I ended up going with a Samsung power supply from Amazon because the HTC power supplies did not have good ratings and people said they were not made by HTC. So I am using that Samsung because it had good rating and it is working good.

3. A SD card to use for the Operating System for the Raspberry Pi and to store images from the camera as well. Amazon once again for about $7 after shipping + handling.

4. A camera that is supported by gphoto2 and also by CHDK for taking the photos. The Canon Powershot SX100 or SX110 are the best camera’s that are supported by both gphoto and CHDK. Here is the SX100 listed on Amazon. I got mine for $100 (used – very good condition – had 1500 shots on it when I got it) after shipping + handling. The Canon Powershot A510 should fit in the enclosure and has full support from gphoto2. I bought one from Amazon for $41 after shipping + handling.

5. The third item is a USB cable that connects the camera to the Raspberry Pi. This is also availble on Amazon and mine cost $12 after shipping + handling.

6. An AC power supply is also necessary to power the camera. Once again Amazon seems to be the best. This cost $15 after shipping + handling.

7. A housing for all of these components is a critical point for the survival of the camera in all kinds of weather. An enclosure made for security cameras seemed to be the best option. I originally looking into building myself one using a waterproof container and a bunch of pieces to make it all work. Then I found this enclosure (also Amazon) and it has a heater and a fan to regulate the temperature. And it is IP66 rated. This costs $47 after shipping + handling.

8. A power supply to power the heater/blower in the enclosure is available at Amazon. It is sold by the same supplier as the enclosure and is confirmed to work with this model of enclosure. This cost $36 after shipping + handling.

9. Silica gel is something that comes in packages and I will put several of  these packets in to reduce moisture.

10. A case to hold all of the power cables that plug into the power strip. This needs to be kept dry and it has to be in a separate case because the enclosure that holds the camera and Raspberry Pi is too small to hold all of this as well. This Sockit Box case from Amazon should do the job nicely! It costs $33 dollars which is a little expensive I thought, but it is a very important part of the project.

11. I bought some plastic screws and nuts to hold the Raspberry Pi in the enclosure and keep it from touching the metal sides. This I bought from my local Lowe’s store and it only cost $5 dollars for all of it.

Still need

A power supply for the enclosure. It does not come with one, but requires one for the heater/fan.

A power cord (120V) to be able to run to the enclosure to power all of the electronics.

Conclusion

At this point all of the materials cost $207 and I hope to keep it under $250 with the rest of the materials that are still needed. And no I am not trying to sell Amazon stuff, but they have been consistently the best price for the quality that I need.

Beginnings…

The goal of this project is to have several time lapse videos that show a scene over the course of a year. I am in the planning stage at this point, but have started buying the materials needed. The two main components are a Canon camera and a Raspberry Pi! More details to come…

Tag Cloud