Last time, we had managed to get a command for controlling the lights up and running on the Raspberry Pi. The obvious choice for scheduling such a command in Linux is Cron. To automatically turn on the lights using Cron, we need to edit the root-user’s crontab:
$ sudo crontab -e
This will launch a text editor inside the terminal. Lets scroll down to the end using the arrow keys and add the following lines:
45 6 * * 1,2,3,4,5 send 11111 3 1 50 6 * * 1,2,3,4,5 send 11111 4 1
The values, in turn, represent minute, hour, day of month, month and day of week. That is, the first command fires 06:45 every month, Monday through Friday. The send command is the same as before; turn group 11111, light 3 and 4, on (1). There is lots you can do with Cron and it has been around forever. If you have not used it before there are lots of extensive guides out there to get you started so I will not bother. This setup took me through most of the winter. The Pi turned on the lights just before my alarm went off at 07:00 and the results were imminent – waking up was a lot easier and “softer” as the light eased the body into the idea of waking up before it was blasted by the sound of an alarm. It was good, but not what I had planned for. This was only fading in two discrete steps, and even though I could just have added a few more outlets like this, I really wanted a singe, more powerful, custom light. Plus, the relays in the outlets make a loud and annoying clicking sound when they turn on. On the software side things were working fine, but logging onto the Pi and setting the alarm in the terminal was not really optimal. Next time: Building some hardware!