2018-06-18
Dynamically pausing the Raspberry Pi Camera
For several months, i have set the time frame for creating the "zip file" to a static value. But a disadvantage of this approach is, a few minutes pass by, in which the Raspberry Pi has nothing to do at all. Because i reserved with 15 minutes a generous amount for the quite demanding job. Since the "zip file" sizes with up to 600 MB were too big anyway, i changed the way i do it. Instead of making one big archive at midnight, i create two small ones, one every 12 hours, as instructed in my shell scripts, and set up in crontab. Files with around 300 MB are just more manageable on the Zero W, especially with the workload it has.
I also make use of a "file locking" mechanism to get the transitions seamless. This way the Raspberry Pi will immediately continue to take photos when the packaging of the JPEG files is done, simply by checking for the absence of a "lock file", which prevents it from doing multitasking. I wrote four separate Unix shell scripts for this process, and added them to cron: camera, cameraSweep, cameraWatchdog, and cameraZip. They explain themselves by their filename, and i already presented some functions in older posts, except for the second one: After a fresh start, it deletes all "lock files", just in case if the reason for the reboot was a crash and crumbs are left behind.