- The parameters are grouped in 6 sections: Main, timerConfig, camConfig, dirConfig, dbxConfig and rcConfig. See comments in the rpiconfig.yaml file for all available configuration parameters and their use.
-
Uses the Advanced Python Scheduler to background schedule the three main interval jobs implemented in rpicam, rpimgdir and rpimgdb.
-
Schedule an additional background timer job to collect/combine the status messages from the rpi scheduled jobs, and to send/receive remote control commands via ThingSpeak TalkBack App. All classes described below have a remote control interface to this timer job.
-
When SystemD is used the module notifies the systemd (when available) with: READY=1, STATUS=, WATCHDOG=1 (read env variable WATCHDOG_USEC=), STOPPING=1.
-
Use of Picamera2 (2022+):
-
When
RPICAM2is set inrpiconfig.yamlunder the Main section, then the Picamera2 API is used. -
When
LIBCAMERAis set inrpiconfig.yamlunder the Main section, then rpicam-still is used from rpicam-apps installed with picamera2. -
When
RPICAM2orLIBCAMERAis set inrpiconfig.yaml, a camera tunning file (--tuning-file) is used, auto-configured by setting thecam_versionandcam_typespecified in therpiconfig.yamlunder thecamConfigsection. -
When neither
RPICAM2orLIBCAMERAare set, theFAKESNAPcan be used to fake an image capture. -
When neither
RPICAM2,LIBCAMERAorFAKESNAPare set, then the webcamfswebcamutility is used to capture images. -
Example testing the installation with camtest.sh
-
-
Gracefull exit is implemented for SIGINT, SIGTERM and SIGABRT.
Run manually:
Use
RPI_LGPIO_REVISION=800012 python3 rpicam_sch.py &
NOTE: The RPI_LGPIO_REVISION environment variable must be set due the use of the user-space GPIO access is via the rpi.gpio compatibility package, on Linux kernels which support /dev/gpiochipX.
Auto-start as service:
Use the SystemD user service unit rpicamsch.service.user.
The rpicamsch.service.user systemd user service unit is to be copied to /etc/systemd/user/rpicamsch.service.
While running, all messages are logged to a (rotated) rpicam.log file. The log level is configured in rpilogger.py.
Image capture options are selected in rpiconfig.yaml under the Main section (see above).
The captured images are stored locally in a sub-folder with the current date 'DDMMY' as name, under the image_dir folder, specified in the configuration file under the dirConfig section.
The captured image local file names are 'DDMMYY-HHMMSS-CAMID.jpg', where CAMID is the camera identification string cam_id, specified in the configuration file under the camConfig section.
The module implements a 'dark' time long exposure time or an IR/VL reflector ON/OFF switch. The module implements the infra-red (IR) or visible light (VL) reflector control via GPIO (configured with use_irl: yes and bcm_irlport parameters in the configuration file under the camConfig section).
- The 'dark' time period (start and stop) can be configured manually using the hour/min parameters set in the configuration file under the
timerConfigsection. - Alternatively, the 'dark' time period can be configured automatically using the PyEphem
and the location parameters (latitude and longitude)
lat_lonset in the configuration file under thecamConfigsection.
PIR sensor support, as external trigger via GPIO for the camera job, is in BETA. (replaces the normal camera job scheduler when configured with use_pir: yes and bcm_pirport parameters in the configuration file under the camConfig section).
Further info about the other implemenation modules
- The captured images are uploaded to a sub-folder with the current date 'DDMMYY' as name, under the
image_dirfolder, under the Dropbox App folder. - The captured image upload file names are 'DDMMYY-HHMMSS-CAMID.jpg', where CAMID is the camera identification string
cam_id, specified in the configuration file under thecamConfigsection. - The current/last captured image is always uploaded with the name
image_snap, specified in the configuration file under thedbConfigsection, under theimage_dirfolder, under the Dropbox App folder. - All uploaded images file names are stored in in a local
upldlog.jsonfile when the configured capture sequence ends or at the end of each day.
thingspk: A simple REST request abstraction layer and a light client ThingSpeak API and TalkBack API.
-
The implementation of the thingspk module follows the ThingSpeak API documentation and the TalkBack API documentation
-
The REST client implementation follows the model of the older Python Xively API client.
-
The use of the ThingSpeak API (to send status messages) and ThingSpeak TalkBack API (to receive remote control commands) requires in the 6th section (rcConfig) of the
rpiconfig.yamlthe configuration of:
rc_type: ['ts-status', 'ts-cmd']
token_file: ['ts_tokens.txt']
where ts_tokens.txt (only example file name) is a text file which contains 2 lines with the necessary ThingSpeak API client access keys, as follows:
<channel_id>,<write_key>,<read_key>
<talkback_id>,<talkback_key>
rpiwsocket: A simple threaded WebSocket server implementation to send status messages and receive remote control commands.
- The use of the WebSocket server to send status messages and/or receive remote control commands requires in the 6th section (rcConfig) of the
rpiconfig.yamlthe configuration of:
rc_type: ['ws-status', 'ws-cmd']
token_file: ['ws_tokens.txt']
where ws_tokens.txt (only example file name) is a text file with the access tokens which need to be provided by each client during the initial authoriastion handshake, when connecting to this server, as follows:
<recv_status_token>,<send_cmd_token>
Installed with sudo apt install --upgrade python3-<package>
-
apscheduler: Advanced Python Scheduler
-
yaml: YAML
-
pil: PIL
-
piexif: Piexif
-
ephem: PyEphem
-
dropbox: Python SDK for Dropbox API v2
-
rpi-lgpio: rpi.gpio compatibility package on Linux kernels which support /dev/gpiochipX
-
systemd: python3-systemd
-
websockets: python3-websockets
Installed with sudo apt install --upgrade <package>
-
libopenjp2-7: libopenjp2, required by Pillow
-
fontconfig: fontconfig provides Dejavu fonts
Run full system update with sudo apt-get update && sudo apt-get full-upgrade -y
(in scripts folder)