Basil Watch!

In a perfect storm of events, I found myself with a raspberry pi that was not being used for anything, a raspberry pi compatible camera, some recently acquired basil seeds, and a few hours of free time. Naturally, the thing to do was set up a timelapse camera to monitor my basil’s growth. This was accomplished simply enough with an extension cord, some duct tape and a bash script.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#!/bin/bash

while true
do
    HOUR=$(date +"%H")
    # This saves us from having 8 hours of black frames every night.
    if [ $HOUR -lt 20 -a $HOUR -gt 6 ]
    then
        DATE=$(date +"%Y%m%d_%H%M%S")
        raspistill -ex auto -o /home/pi/camera/$DATE.jpg
        convert /home/pi/camera/$DATE.jpg -scale 50% /home/pi/camera/plant.jpg
        scp /home/pi/camera/plant.jpg webserver:/location/of/website/plant.jpg
    fi
    sleep 120
done

I am aware that the raspistill utility has timelapse capabilities, but since I wanted to publish each snapshot to my website, I found it easier and more flexible to write a bash script (Even if I made a stupid mistake with it and lost a day of footage). The script takes a snapshot every 2 minutes and saves the picture locally. It then makes a resized copy of the last saved picture and sends it to my webserver. That picture can be found here. Meanwhile, every few days, I will manually move the pictures saved on the pi to my desktop where I have more storage. After a month or so, I will hopefully be able to make a nice little timelapse movie of a plant growing from (almost) seed to maturity.