Let it Grow!
This page was once for watching a single basil plant; now, it is monitoring my
new indoor gardening setup. The eventual goal is to automate as much as possible, with novel soil moisture detection,
water recycling, automatic fertilization, and perhaps some image recognition AI to judge overall plant health. For now,
we just have an image feed thanks to a Raspberry Pi and a remarkably shitty webcam.
The Raspberry Pi captures one image every two minutes and uploads the result to my webserver. The set of images for each day is combined into a 60fps video and then concatenated with a video of all previous days.
1#!/bin/bash
2
3while true
4do
5 HOUR=$(date +"%H")
6 # This saves us from having 8 hours of black frames every night.
7 if [ $HOUR -lt 20 -a $HOUR -gt 6 ]
8 then
9 DATE=$(date +"%Y%m%d_%H%M%S")
10 fswebcam -r 1920x1080 -F 5 -S 5 --rotate 180 --line-colour \#FF000000 --banner-colour \#80000000 --font sans:30 /home/pi/camera/$DATE.jpg
11 scp /home/pi/camera/$DATE.jpg webserver:/location/of/website/plant.jpg
12 fi
13 sleep 120
14done
The webcam takes a while to adjust exposure, white balance, and the like. To account for this, it takes a total of ten frames, discards
the first five with -S 5
and averages the next five with -F 5
.