├── .gitignore ├── README.md ├── camera.sh ├── cronCommand.txt ├── deleteOld.js ├── package.json ├── rsyncCommand.txt └── sync.sh /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/* 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Timelapse-Zero 2 | ============== 3 | 4 | Documentation and files for setting up timelapse photography on a Raspberry Pi Zero. 5 | 6 | 7 | Dependencies 8 | ------------ 9 | 10 | - Enabled Pi Camera 11 | - NodeJS 12 | - AWS CLI (through pip, not apt-get) 13 | - AWS IAM credentials configured on the Pi with access to an S3 bucket 14 | 15 | 16 | Timelapse Timing 17 | ---------------- 18 | 19 | Configured to take a picture every 5 minutes (see cronCommand.txt), so: 20 | 21 | 12 pictures an hour 22 | 60 pictures = 5 hours 23 | 1 second at 60FPS = 5 hours of real time 24 | -------------------------------------------------------------------------------- /camera.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DATE=$(date +"%Y_%m_%d") 3 | TIME=$(date +%s) 4 | mkdir -p /home/pi/camera/$DATE 5 | raspistill -o /home/pi/camera/$DATE/$TIME.jpg \ 6 | -t 3000 \ 7 | -q 100 \ 8 | -ISO 100 \ 9 | -awb cloud \ 10 | --metering matrix 11 | -------------------------------------------------------------------------------- /cronCommand.txt: -------------------------------------------------------------------------------- 1 | Stored in /var/spool/cron/crontabs/pi, edit with `crontab -e` 2 | 3 | */5 * * * * /home/pi/timelapse-zero/camera.sh 2>&1 4 | 0 * * * * /home/pi/timelapse-zero/sync.sh 2>&1 5 | -------------------------------------------------------------------------------- /deleteOld.js: -------------------------------------------------------------------------------- 1 | var fs = require("fs-extra"); 2 | var moment = require("moment"); 3 | 4 | var maxAge = 172800; // 2 days in seconds 5 | var cutoffTime = moment().startOf("day").subtract(2, "days"); 6 | var baseDir = "/home/pi/camera"; 7 | var now = +new Date(); 8 | now = now / 1000; 9 | 10 | var files = fs.readdirSync(baseDir); 11 | 12 | files.map(function (f) { 13 | return { 14 | fullPath: baseDir + "/" + f, 15 | dirName: f 16 | }; 17 | }) 18 | .filter(function (f) { 19 | // Only allow directories with a date pattern 20 | return fs.lstatSync(f.fullPath).isDirectory() && /\d{4}_\d{2}_\d{2}/.test(f.dirName); 21 | }) 22 | .filter(function (f) { 23 | // Only allow directories older than two days 24 | return moment(f.dirName, "YYYY_MM_DD").isBefore(cutoffTime); 25 | }) 26 | .forEach(function (f) { 27 | // Delete the older directories 28 | fs.emptyDirSync(f.fullPath); 29 | fs.rmdirSync(f.fullPath); 30 | }); 31 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "timelapse-zero", 3 | "version": "1.0.0", 4 | "description": "Timelapse-Zero ==============", 5 | "main": "deleteOld.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/bschwind/timelapse-zero.git" 12 | }, 13 | "author": "", 14 | "license": "ISC", 15 | "bugs": { 16 | "url": "https://github.com/bschwind/timelapse-zero/issues" 17 | }, 18 | "homepage": "https://github.com/bschwind/timelapse-zero#readme", 19 | "dependencies": { 20 | "fs-extra": "^1.0.0", 21 | "moment": "^2.17.1" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /rsyncCommand.txt: -------------------------------------------------------------------------------- 1 | rsync -avz -e ssh pi@10.0.0.19:/home/pi/camera destDir/ 2 | -------------------------------------------------------------------------------- /sync.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games 3 | 4 | aws s3 sync /home/pi/camera s3://timelapse-zero-1/meiji-dori-winter 5 | nodejs /home/pi/timelapse-zero/deleteOld.js 6 | --------------------------------------------------------------------------------