This build combines a Raspberry Pi with a rotary-encoder, an RGB LED and an OLED character display to create a time clock that logs my time on tasks directly to a Google Docs spreadsheet.
Motivation
Whenever I have to record time against projects, I find it really hard to diligently keep my time records up to date. Maybe with a purpose-built time clock I will keep better records? Hey, it could happen!
Overview
The off-the-shelf components:
- Raspberry Pi model B Rev 1 ā Adafruit has the Rev 2 board.
- 128Ć32 SPI OLED display ā Adafruit
- Rotary Encoder ā Adafruit
- 5mm RGB LED ā Sparkfun
- Occidentalis 0.2 ā Adafruit
- 6ā Female/Female jumper wires ā Adafruit
- 3ā Female/Female jumpers wires ā Little Bird Electronics or Adafruit
I used a common cathode LED from Sparkfun. You could use Adafruitās common anode equivalent with minor code changes.
The theory of operation is pretty simple:
- at start-up, it pulls a list of jobs from a Google Docs spreadsheet,
- rotating the knob scrolls through the list of jobs,
- clicking the knob logs a start time or end time in the spreadsheet.
The Case
The top of the case is made from a single block of wood.
The bottom of the block has been hollowed out to house the RPi board. The RPi sits in a plastic carriage that screws to the bottom of the block. I have not provided access to the HDMI, audio or video ports on the RPi since Iām not going to use them.
The carriage for the Raspberry Pi was designed in OpenSCAD and printed on a Makerbot Replicator. The RPi board doesnāt have mounting holes, so the carriage has edge-clips to grasp the board. The posts at the corners were originally intended to screw the carriage to the block, but I found that to be impractical, so I added the two tabs at the bottom and routed out matching recesses in the block. I left the posts there because they make the carriage look a little more interesting. Or because I was too lazy to remove them, Iāve heard it both ways.
The Circuit
Iām using two of the ground pins originally documented as Do Not Connect (DNC). The extra grounds are really convenient, and Eben has publicly committed to keeping these available in future board revisions.
Itās worth pointing out that I deliberately selected GPIO pin 5 for the push button because of the Raspberry Pi Safe Mode feature. If you have a recent firmware release, you can boot your RPi in safe mode by holding the knob down (shorting pin 5 to ground) when you power up. In truth my intention here is not so much to make safe mode available (Iāve never needed it) but to make sure that pin 5 is not unintentionally shorted to ground at boot time, as it could be if you used it for one of the quadrature encoder inputs. Yep, that happened. After I upgraded to the version of firmware that supports safe mode my box stopped booting. Lesson learned; be careful with pin 5, or disable safe mode by adding avoid_safe_mode=1
to /boot/config.txt
.
For most of the GPIO connections I cut pre-terminated Female Female jumper wires in half and soldered the cut end to the component. I already had header pins on the SSD1306 OLED module, so I used 3ā premade cables from Little Bird Electronics.
It is crucial to keep wiring short and well insulated so that it will all pack in neatly and without shorts when the case is closed up.
RGB LED Indicator
For this device I wanted a large, diffuse and interesting state indicator built around an RGB LED. I use the WiringPi soft PWM library to drive the LED, and the py-gaugette RgbLed class makes it easy to do animated colour transition loops. My first prototype was made from the back of a GU10 light bulb. The bulb glass is thick and diffuses the light nicely, and I thought the terminals would make cool capacitive switches.
I liked that a lot, but ultimately settled on a long oven light which had a more compact footprint. It gives elegant curving internal reflections which look quite nice.
When I cut the metal tip of the bulb off with a Dremel I expected to be able to remove the burned-out filament, but discovered this bulb (like most others I would guess) is made with an inner glass plug that encases the filament wires and seals the bulb. It isnāt easily removed, but has a hollow neck just big enough to receive an LED. So the filament stays. Maybe I should have used a new bulb!
I trimmed the red, green and blue leads on the LED quite short and soldered a 270ā¦ current-limiting resistor to each one. This keeps the resistors tucked up away from the board. I then added connector wires to each lead, pushed the LED up into the bulb neck and pumped some hot glue in to keep it all in place.
Iāve seen advice suggesting I should have selected different values for the resistors to to get optimal white balance. I didnāt bother. Colour balance is fine. I aint bovvered.
For more detail: Raspberry Pi Time Clock