Growth Camera Setup

How to know if your coral is growing!

One of my biggest problems is impatience. My reef is in my living room and I see it for a couple hours each day. For this reason I never notice my coral growing, consequently I fiddle with things trying to get more growth, until I stumble across an old picture and I'm stunned to see how much things have changed. In order to track growth better I devised this little camera which takes pictures every day, I can then look back at the photos to see how things have changed.

Here is an example, this shot flips through 3 images that were taken 12 days apart. From the first to the last shot there is a 24 day gap:

Click to see a larger image

Pretty cool eh? Really helps with my growth OCD.

You can do this as well, it's made with a Raspberry Pi and the Raspberry Pi Cam, the total cost of the project is around $100. The Raspberry Pi runs Linux, a free open-source operating system. These instructions are designed for someone that has some understanding of the Raspberry Pi and Linux already, but if you are patient and you are willing to google some of the steps I skipped over then this can be done by anybody.

First, the setup. I used a Raspberry Pi B+ to do this, you don't need more power than that, but if I were to do this again I would use the faster Raspberry Pi 2.

Keep in mind, this is kind of a junky camera if you are looking for nice pictures with perfect white balance you will need to use something much better. Many DSLR cameras can be setup with a time-lapse feature to take pictures every 24 hours, and you would need a setup like that for perfect shots.

Here is the Raspberry Pi I used, cost $50 - I would use the current model if I did this again though.

Here is the Camera I used, cost $35 - Once again, I would use the newest model

I also used a small WiFi dongle, cost $9

Once you have Noobs installed on your SD Card you need to enable the camera, it is one of the options in the initial setup, or you can run the raspi-config program if the Pi is already set up to enable it. I would set a static IP address on the Wireless network card, or create a dhcp reservation on your router so that you can remote connect to this device and get the pictures off without touching it (and risking moving it).

Now you can take a sample picture. If you still have a monitor plugged in simply typing:

raspistill -o test.jpg

Into a Terminal window will show what the camera is seeing for a couple seconds on the screen then save the image as "test.jpg" in whatever folder you are in currently. If you have the GUI loaded you could open it and look at the image, if you are using the command line then we will look at that picture in a bit.

Now, Move back to your Windows PC, you will need to download a couple of tools to connect to your Raspberry Pi without touching it.

First is Putty, this will allow you to SSH into your device to change configurations and do tests:

Putty Download

Next is Win SCP, this program allows you to do file transfer over SSH and will allow you to recover your images:

Win SCP Download

With these tools installed, test that you can connect using the static IP you set up earlier. If all is good then we can move onto the physical setup of the camera.

At first, I used a Cell Phone mount to attach the camera to the side of the tank, but I found that the suction cup failed over time and it kept falling off. After a little while, I made an acrylic mount which bolts to the hood. This is much better.

Now that the device is all in place power it up, and connect through Putty. I am assuming that you no longer have a monitor connected. From this point on this device will be controlled remotely. From your home folder once again run this command in the putty terminal window:

raspistill -o test2.jpg

Now connect using WinSCP and navigate to your home folder if necessary. Copy the picture to your desktop and open it up. This will show you what kind of changes are necessary.

Camera Adjustments

    1. The first thing we need to deal with is that Red LED on the front of the camera board. It will reflect off your glass and ruin every picture. Some people have used electrical tape to turn it off, but it's better to shut it off in the system. Here is how that is done.
    2. Logged in as "PI" in putty type:
    3. sudo nano /boot/config.txt
    4. Scroll to the bottom of the file and add this line:
    5. disable_camera_led=1
    6. Don't forget to save before you exit, if you hit ctl x it will ask you if you want to save.
    7. If you need more through instructions on this step click here
    8. Change the orientation. If you find that the picture is upside down or sideways you can use these additional switches.
    9. -vf for vertical flip
    10. -hf for horizontal flip.
    11. For example if your picture is upside down and sideways you can run this command to take the picture correctly:
    12. raspistill -vf -hf -o test3.jpg
    13. I'm running that command myself.
    14. Click here for informaiton about all the useful camera switches and how to use them
    15. Now that your picture is oriented correctly it's time to change what you are taking a picture of. Take another shot using the proper command and copy it to your computer using WinSCP and open it up. Make a small adjustment to the camera and try again. Do this as many times as necessary until you are taking a picture of what you want.
    16. White Balance. This is really tricky to get correct, and mine is far from perfect, but the closer you are the better off your photography will be. The trick is to get it close enough that you can fix the rest in Photoshop. The way this is set in the Raspicam is you set the gain on the 3 primary colors, Green is set and you can't change it, but you can change Red and Blue relative to Green. We start with our command to get a picture in proper orientation, lets say that looks like this:
    17. raspistill -vf -hf -o test3.jpg
    18. Now we add a couple things, -awb off turns off auto white balance, -awbg num1,num2 sets the gain manually. We now have this command:
    19. raspistill -vf -hf -awb off -awbg 1.80,0.81 -o test.jpg
    20. That is the command I use, but for your lights you will need to play with those numbers to get the white balance correct. The only way to do this is take a single shot with a starting point, then adjust up and down to see what numbers look best. Move one at a time and you will get the hang of it. Sorry, I really wish I knew a better trick, but I don't.
    21. Once you find a command that works best for you, make note of it and move onto the next section.

Setting the Pi up to take pictures automatically

    1. First we need to create a script, in the Putty console create a directory in your home folder (this location is important because you have full permissions there), create a folder for all your images using this command:
    2. mkdir camera
    3. Now create a script for taking the images by using nano using this command:
    4. nano
    5. In nano write these three lines:
    6. #!/bin/bash
    7. DATE=$(date +"%Y-%m-%d_%H%M")
    8. raspistill -vf -hf -awb off -awbg 2.03,0.56 -o /home/pi/camera/$DATE.jpg
    9. The first line denotes it as a Bash Script, the second creates a variable named date so we don't overwrite each image with the next one, and the last line would be replaced with your command, and uses the vairable you created to give each shot a unique name.
    10. Now, save and exit Nano.
    11. The next step is to make your script executable. You can do that with this command:
    12. chmod 777
    13. That gives everyone full permission over that file.
    14. Finally, run your script with this command:
    15. ./
    16. It should take a picture, and in about 10 seconds you should have a new jpg file with a name that is simply the date it was taken. Copy this picture to your desktop using WinSCP and make sure everything looks good.
    17. If it does, congratulations! You now can take a picture with a single command!
    18. Now that we have a script to run the last step is to setup Crontab to run it automaticly. This will ensure that even if the Pi is restarted when it boots back up it will go right back to work. First enter Crontab by running the command:
    19. sudo crontab -e
    20. Move to the bottom of the file and enter this command, we will edit it for your specific instance in a min:
    21. 0,15,30,45 12,13,14,15,16,17,18,19,20 * * * /home/pi/camera/ 2>&1
    22. The spaces in this command are very important, what this does is take a picture:
    23. At 0 min, 15 min, 30 min, and 45 min of
    24. Hour 12, 13, 14, 15, 16, 17, 18, 19, 20
    25. Of every month, year etc.
    26. You will need to change this to match your lighting schedule and your path if you named things differently of course. The reason I take so many photos is I want to make a time lapse video eventually, plus it gives me enough shots to make sure I get a good one on any given day. You can change this if you like to take only one shot an hour, or take shots during only one hour per day if you want it to run longer without filling up your SD Card. I use a 16 gig one now to give myself more space.
    27. If you have trouble a quick google search of how to use Crontab will answer all your questions. The trick is to make Crontab run the script you created during the times you want to shoot.
    28. Now you test! Let it run during the times you should be getting pictures and use WinSCP to ensure your pictures are coming in. You can then copy them to your desktop, or do what I do which is wait until the card is almost full and copy them all in bulk.

What to do with the pictures once you have them

There are plenty of online GIF creators, just Google "Online GIF creator" and you will get a ton to choose from, but they are usually limited in picture quality, so I typically use Photoshop to to this. Though I post the "internet" quality image, I use the high res one to zoom in and inspect how things are progressing.

This is how to create a GIF in Photoshop CS6, but I have done the same thing in CS4

    1. Take your photos and save them into a single folder, I like to work off my desktop.
    2. Click File, then Scripts, then Load photos into stack.
    3. Browse to your folder, highlight all the files you want to make a GIF out of, and click Ok, then Ok again.
    4. Photoshop will load all your photos into Layers.
    5. Click on Window in the top menu, then put a checkmark next to Timeline. This will open a new bar at the bottom.
    6. In the top right hand corner of the new window there is an icon with 4 lines in it (circled below), click on that then click "Make frames from layers"
    1. Click through the frames listed in this window and make sure they are in the right order, if they are not drag them to the proper place.
    2. On the bottom of each image there is a little icon that probably says 0sec, drop down the little arrow and select how long to delay on each frame.
    3. When your done it will look something like this, the word "Forever" that is circled tells the browser how long to play the GIF, you can have it run only a few times but I prefer to have it go forever.
    1. Finally click "File" then "Save for Web", in the first window you can set the image size, for the web I prefer something with a height or width no greater than 800px just to keep the file size downloadable in a reasonable time. Once you click "Ok" you will be able to name your GIF.
    2. Now share with all your friends!!! I'd love to see what you come up with!