Comments
You can use your Mastodon account to reply to this post.
By Leo Gaggl
One common task for my Raspberry Pi Zero with (infrared) Camera is to do still image capture in regular intervals and upload the images for storage and post-processing. A simple way to achieve this with standard software tools available in the Raspberry Pi OS repositories is to use the S3 CLI tools and a simple bash script run by a scheduled cron job.
sudo apt install python3-pip
sudo pip3 install s3cmd
s3cmd --configure
The values:
You can use the CLI for that, but for most users probably easier via the Web
Create a shell script with the contents below and give it execution permissions.
vim capture_upload.sh
chmod +x capture_upload.sh
#!/bin/bash
# ------------------------------------------------------------------
# [Author] Leo Gaggl
# http://www.gaggl.com
# ©2014 - SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
# License GPL V2 - details see attached LICENSE file
# This script captures a still image from the Raspberry Pi
# via the camera and upload it to AWS S3 or Linode object storage.
# https://gaggl.com
#
# Dependency:
# Raspberry Camera Module - enabled
# s3cmd tools installed
# ------------------------------------------------------------------
IMAGEDIR=/home/pi/wildlife-rpi-cam/
FILENAME="$IMAGEDIR"rpi$(date "+%Y-%m-%d--%H-%M-%S").jpg
S3BUCKET=s3://wildlife-rpi-cam/
raspistill --nopreview -v -o ${FILENAME}
s3cmd put ${FILENAME} ${S3BUCKET}
rm ${FILENAME}
Note: You will probably have to adjust the home directory if you have a more recent Pi or, like me, changed the default user account on previous Raspian images.
crontab -e
# Run every 10 minures
*/10 * * * * /home/pi/capture_upload.sh
Linode “Using S3cmd with Object Storage” Guide
There’s plenty of ways to make this more efficient and for example use OpenCV for motion detection and only upload on movement. But this is a great start for a quick time lapse job. It has assisted me to find the culprits eating my vegetables overnight (earwigs twice and some rodent another time).
This same approach will obviously work with AWS S3 storage too.