From c9ed87da7cdcc6954a32fac2ce095c1e18afa85f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 10 Jul 2021 14:55:37 +0100 Subject: [PATCH] initial add --- systemd/camera.service | 15 +++++++++++++++ take-photo.py | 11 +++++++++++ take-photos.sh | 11 +++++++++++ 3 files changed, 37 insertions(+) create mode 100644 systemd/camera.service create mode 100644 take-photo.py create mode 100755 take-photos.sh diff --git a/systemd/camera.service b/systemd/camera.service new file mode 100644 index 00000000..192d0a3a --- /dev/null +++ b/systemd/camera.service @@ -0,0 +1,15 @@ +[Unit] +Description=camera service + +[Service] +TimeoutStopSec=5 +#EnvironmentFile=/home/pi/CubeSatSim/.mode +ExecStart=/home/pi/CubeSatSim/take-photos.sh +WorkingDirectory=/home/pi/payload +StandardOutput=inherit +StandardError=inherit +Restart=always +User=pi + +[Install] +WantedBy=default.target diff --git a/take-photo.py b/take-photo.py new file mode 100644 index 00000000..d6b0102f --- /dev/null +++ b/take-photo.py @@ -0,0 +1,11 @@ +import time +from picamera import PiCamera + +camera = PiCamera() +#camera.resolution = (3280,2464) +camera.resolution = (2592,1944) +camera.start_preview() + +current_time = time.strftime("%H;%M;%S", time.localtime()) +current_time = time.strftime("%m-%d-%H%M%S", time.localtime()) +camera.capture('/home/pi/payload/img'+current_time+'.jpg') diff --git a/take-photos.sh b/take-photos.sh new file mode 100755 index 00000000..b84c8cad --- /dev/null +++ b/take-photos.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +echo -e "\nScript to take pictures every 30 seconds\n" + +while true; do + + python3 /home/pi/CubeSatSim/take-photo.py + echo -e "\nTaking photo!\n" + sleep 28 + +done