Make a time clock with the Raspberry Pi

People working on projects are usually required to keep their time records up to date. However, those who are more engrossed with the technicalities of their work, find that they slip on their time keeping chores. If you fall into that category, let your Raspberry Pi (RBPi) help you out. Along with the tiny single board computer, you will additionally need one RGB LED, an OLED character display and a rotary encoder. Your time will be logged directly into a Google Docs spreadsheet.

The purpose-built time clock has several off-the-shelf components. For the RBPi, use the Occidentalis 0.2 operating system. The 128×32 OLED display uses SPI interface and this OS has the interface bundled in.

The time clock is very simple to operate. When you start it up, it will pull in a list of jobs from a specified Google Docs spreadsheet. To scroll through the list of jobs, simply rotate the knob on the rotary encoder. When you want to record time for specific project, just locate it by rotating the knob and click it. That starts the clock ticking on the spreadsheet. For logging off, simply click once again.

Use any case suitable for the RBPi or make your own. Since the HDMI, audio and video ports will not be used it is acceptable if the case does not provide access to these ports. For those who like to do things professionally, designing the carriage for the RBPi on OpenSCAD could be great fun. Printing the carriage on a Makerbot Replicator will give the required professional touch. Since the RBPi board does not have any mounting holes, you may have to put in edge-clips for holding it. Having posts at the corners of the board will make a snug fit.

Although the documentation of the RBPi mentions some ground pins as DNC or Do Not Connect, using them as extra grounds can be very convenient, just make sure you are using the proper ground pins.

Using the GPIO pin 5 of the RBPi for the push button can be of dual advantage. This keeps the pin 5 available for a Safe Mode boot, for example, when there is a recent firmware release. Simply hold the knob down when booting up and your RBPi comes up in the safe mode. Additionally, there is no chance of the pin being accidentally held low, such as could be the case if it was used for one of inputs to the quadrature encoders.

Use the software from here. The PWM library drives the RGB LED and the RgbLed class animates its color transition loops. The rotary encoder uses the RotaryEncoder.Worker class for polling through the encoder GPIOs and for keeping the application code as simple as possible.

Since the application code utilizes the CPU only to around 20%, its temperature rise is within safe range. The color-coding gives idea of the state of the machine. When no time is being logged, the LED shows purple. As time is logged against a task, the LED pulses slowly and turns blue. When rapidly flashing, you know that the spreadsheet on the Google Docs is being updated.