Useful Script to let people easily program the Pijuice and Schedule Raspberry pi happenings

For our mothbox project we are programming pijuices and pis to automatically turn themselves on during certain nights of a month and automatically attract and take photos of moths

This tool will be used hopefully by many field technicians and thus asking them to do things like VNC into the pi, and adjust python scripts or even the pijuice GUI aren’t really feasible for multiple reasons.

We also found a problem when duplicating images of a setup where a system is programmed to run a certain schedule: If you put a image into identical hardware, it will not run the schedule because the pijuice hadn’t yet been fed the programming by the pi.

So i made a script

that reads a CSV formatted like this

SETTING,VALUE,DETAILS
second, 1,
minute,0, specify a specific minute or you can replace the 'minute' key in the arguments dictionary with 'minute_period'
hour,20;22;1;3,specify what hour you want things to turn on in 24 timeframe separate multi values with a semicolon or write "EVERY_HOUR"
weekday,1;2;3;4;5;6;7, (theres currently an error where you cant do multiple days of a month) specify what days of the month you want to wakeup or write 'EVERY_DAY' or you can change the entry on the leftmost to say "weekday" and specify a number(s) 1-7


utc_off,-5, put your UTC offset for whereever you are based The pijuice just uses raw UTC
runtime, 47, (prime numbers are good) put how long you want each session to go (in minutes) before it shuts the pi back down.
ssid, Examplewifi, write an SSID of a wifi you want to add to the pi
wifipass, examplepassword42, write the wifi password
onlyflash,1,switch to using only the flash for the attraction by setting to 1

and then a cron command that runs the scheduler every time the pi starts up.

The last bit of magic is that the script will search for a CSV named “schedule_settings” on any external media plugged into the pi. So if you want to change the pi’s schedule in the field, you can just copy a new CSV to a USB stick, plug it in, and now the pi will load that schedule when it starts up!

it also calculates a UTC offset to make it easier to program!
Hopefully this is useful to people, and feel free to share any ways you know to make it better!