TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: ALL
from: A. DUMAS
date: 2017-02-03 23:14:00
subject: Re: Time lapse using rasp

Here is my script for a webcam. Saves to RAM, uploads to server. I
commented out saving to /tmp because it turned out looking at the
timelapse video (separate crontab 'makevideo' script every night) was
only fun for a couple of times. It used filenames ending in minutes, so
only one pic per minute left, others overwritten.

Other scripts used:
https://github.com/ednl/shellscripts/blob/master/sun
https://github.com/ednl/shellscripts/blob/master/timedelta
https://github.com/ednl/shellscripts/blob/master/makevideo


#!/usr/bin/env bash

TWILIGHT=30

MEM='/run/shm/cam.jpg'
SRV='username@example.com'
DIR='public_html/picam/'
ID='/home/pi/.ssh/id_rsa'

PREV=2500
while true; do

 CLOCK=$(date +'%-H%M' | sed -r 's/^0*([0-9])/\1/')
 if (( CLOCK < PREV )); then
  # New day
  set $(sun)
  DAWN=$(timedelta $1 -$TWILIGHT)
  DUSK=$(timedelta $2 +$TWILIGHT)
 fi
 PREV=$CLOCK

 # Take picture
 if (( CLOCK >= DAWN && CLOCK <= DUSK )); then
  # Day
  raspistill \
   -n -w 800 -h 600 -q 80 -st \
   -t 2000 \
   -ae 16 -a 8 -a '%F %T' \
   -o "$MEM"
 else
  # Night
  raspistill \
   -n -w 800 -h 600 -q 80 -st \
   -t 1 -ss 800000 -drc high \
   -ae 16 -a 8 -a '%F %T' \
   -o "$MEM"
 fi

 # Save
 #SAV=/tmp/cam$(date +'%Y%m%d%H%M').jpg
 #cp "$MEM" "$SAV"
 #chmod 644 "$SAV"
 #chown pi:pi "$SAV"

 # Upload
 scp -q -B -p -P 22 \
  -o "CheckHostIP no" \
  -i "$ID" \
  "$MEM" "$SRV:$DIR"

done

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.