Skip to content

Instantly share code, notes, and snippets.

@sphaero
Created February 11, 2022 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sphaero/4a325511735d8064c748b734066c6dc6 to your computer and use it in GitHub Desktop.
Save sphaero/4a325511735d8064c748b734066c6dc6 to your computer and use it in GitHub Desktop.
RPI timelapser
#!/usr/bin/python3
from time import sleep
from picamera import PiCamera
camera = PiCamera()
camera.resolution = (1920, 1080)
#camera.start_preview()
# Camera warm-up time
sleep(5)
count = 0
while (True):
camera.capture( 'timelapse{:06d}.jpg'.format(count) )
count += 1
sleep(60)
#!/bin/bash
# Create a timestamped directory
# Run a webserver there
# Run the timelapse python script
set -e
DATE=`date +%d-%m-%y-%Hh%M`
mkdir -p /home/pi/timelapse/$DATE
cd /home/pi/timelapse/$DATE
python3 -m http.server &
# If we get a camera crash we will retry after 5 second
while true; do
python3 /home/pi/timelapse.py
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment