Skip to content

Instantly share code, notes, and snippets.

@Gui13
Created May 1, 2016 19:25
Show Gist options
  • Save Gui13/78535625607e4463507784aedf4e7629 to your computer and use it in GitHub Desktop.
Save Gui13/78535625607e4463507784aedf4e7629 to your computer and use it in GitHub Desktop.
#!/bin/bash
SAVEDIR=/home/pi/timelapse/img
TIME_NIGHT_START=2035
TIME_NIGHT_STOP=700
# temp
TEMP=$(cat /home/pi/temperature)
HUM=$(cat /home/pi/humidity)
now=$(date +"%k%M")
filename=$(date -u +"%Y-%m-%d_%H%M-%S").jpg
# interval between 2 shots; should take in account the exposure time
SLEEP_TIME=30
# time of exposure for night capture
NIGHT_EXPOSURE_TIME=5
EXTRA_OPTIONS=${EXTRA_OPTIONS:=""}
FONT=/home/pi/timelapse/DroidSansFallback.ttf
if (( $now > $TIME_NIGHT_START)) || (($now < $TIME_NIGHT_STOP ))
then
EXTRA_OPTIONS="$EXTRA_OPTIONS -ISO 200 -ss $(( $NIGHT_EXPOSURE_TIME * 1000000 )) -ex night"
fi
function take_picture {
filename=$(date -u +"%Y-%m-%d_%H%M-%S").jpg
/opt/vc/bin/raspistill -a 12 $EXTRA_OPTIONS -o $SAVEDIR/$filename
convert -font $FONT -pointsize 60 -fill white -stroke black -strokewidth 2 -draw 'text 296,60 "Temp: $TEMP Hum: $HUM%"' $SAVEDIR/$filename $SAVEDIR/$filename
}
take_picture
echo Sleeping for $SLEEP_TIME seconds
sleep $SLEEP_TIME
take_picture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment