johnbradley / picameratraps

Raspberry Pi Camera Trap management software
MIT License
0 stars 0 forks source link

picameratraps

This software allows management of multiple Raspberry Pi camera traps. Requires python3 to be installed.

Features

Camera Trap Hardware

The camera trap hardware is based on PICT (plant–insect interactions camera trap).

The hardware we are currently using

Camera Trap Manual Setup

Each Raspberry Pi needs an SD card with the Raspberry Pi OS installed. This is done by using Raspberry Pi Imager. To avoid entering a password many times you should have a SSH key setup. See GitHub's documentation on Checking for an existing SSH key and Creating a SSH key. You will need to enter the contents of your public key (~/.ssh/*.pub) into the Raspberry Pi Imager.

Steps:

Edit Camera Trap settings

To customize the recording proceedure you can edit:

cameratraps.txt

Example cameratraps.txt content for two camera traps with names ct1-1 and ct1-2:

ct1-1.local
ct1-2.local

capture.ini

The capture.ini file contains settings for when to run alarms and video/image config.

The default settings for capture.ini are as follows:

[settings]
RECORD_TIME_SECONDS = 30
CAPTURE_HOURS = 7,8,11,12,13,16,17,18
UTC_OFFSET_HR = 4
SET_ALARM_AFTER_MINUTE = 55
ALARM_MINUTE_PERIOD = 5
CAPTURE_SCRIPT=./scripts/capture-video.sh

This causes the camera traps to

TODO: Remove need for UTC_OFFSET_HR

Main Script

To manage your camera traps there is a single ./run.py script that has multiple commands. To view help for this command run the following:

./run.py --help

One-Time Initialization

Before you can perform the one-time init step the camera traps they must be turned on and accessible via WiFi.

Run the setup script to copy scripts and install software.

./run.py init

The first time you run this command on a Raspberry Pi you will be prompted to accept the key fingerprint. Something like the following:

The authenticity of host 'ct1-1.local (...)' can't be established.
ED25519 key fingerprint is ....
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

As shown above enter yes. The raspberry pi will likely be rebooted to handle a configuration change for the RTC.

Setup Recording

Before you can run this script the camera traps they must be turned on and accessible via WiFi. This script will copy scripts and update the job scheduler (crontab).

./run.py setup

Check Camera Trap Status

./run.py status

Stream Video from Camera Trap

This step requires that you have installed VLC and uses two terminals. You need pass the hostname of the camera trap to stream from.

So to start streaming video from trap ct1-1.local run the following:

./run.py stream ct1-1.local

Then in another terminal run the command printed bin a new termial to open VLC. When through press Ctrl-C in the first terminal and close VLC.

Update RTC from System clock

The RTC must be set initially and if the battery is depleted or disconnected from the PiJuice. To sync the RTC clock from the system clock on the raspberry pi run:

./run.py sync-rtc

Retrieve images/videos

./run.py fetch

Convert fetched images in mkv videos

./run.py convert

Delete images/videos

./run.py purge

Set WiFi SSID

./run.py set-wifi

Shutdown Camera Traps

This is necessary so the next alarm will fire and capturing will begin

./run.py shutdown

TODO

See if we can use the present of WiFi to know when to keep the Raspberry Pi active. Otherwise we will not have long enough to download images from the camera traps when they are active. This command might help

iwgetid --raw

Allow setting battery profile so PiJuice can correctly and efficiently charge the battery, correctly monitor the charge percentages and more