Print this Page


1) Getting started and setting the clock

Geekroo Raspberry Pi LED Clock Expansion Board – Clockatoo is an I2C device for the Raspberry Pi. It comes with some Python code to make the “Clockatoo” work. Install the 4-digit LED taking care not to put the LED up-side-down (as per Figures below). Then stack the Clockatoo on the Raspberry Pi using  the 26-pin GPIO header.

Now you need to configure the I2C in case this is not already done. After log in, edit this file : /etc/modules by running sudo nano /etc/modules and add these two lines to the end of the file if they’re not there:


Then your /etc/modules should be looking like this:

Now it’s time to see if the Clockatoo has been properly connected to the Raspberry Pi or not. Run the following command, to install the i2c-tools utility:

sudo apt-get install python-smbus
sudo apt-get install i2c-tools

After the installation, type the follow command to see all the connected devices.
For the Raspberry Pi Revision 1:

sudo i2cdetect -y 0

For the Raspberry Pi Revision 2:

sudo i2cdetect -y 1

If your Clockatoo has been properly stacked on the top of the Raspberry Pi, you should be able to see these two numbers: 68 and 70

Now to download the software for Clockatoo type the following commands:
sudo apt-get install git
git clone git://

After downloading, if you use ls command, you should be able to see the “Geekroo-Product-Clockatoo” folder. Like this:

Go into that folder, and run the “Clockatoo” script:

cd Geekroo-Product-Clockatoo/
cd R2.0/
(If you’re using the Raspberry Pi Revision 2)


cd Geekroo-Product-Clockatoo/
cd R1.0/
(If you’re using the Raspberry Pi Revision 1)

Now run the script:

sudo python

Now the Clockatoo should be working for you by displaying the time on the LCD screen. The Raspberry Pi keeps updating the time automatically from the global ntp (nework time protocol) servers. Clockatoo gets time from the Raspberry Pi. So you can always see the current time.


2) Using the incorporated buzzer as an alarm

The buzzer can be controlled through the WiringPi library. WiringPi2 for Python is an excellent GPIO handling system written by Gordon Henderson and packaged for Python by Phil Howard. Installing WiringPi2 for Python is very simple, but there are a couple of required packages, so we’ll install those first. Before we install anything, though, let’s update the package first

sudo apt-get update
This is what should happen…

Now we need the following.
sudo apt-get install python-dev python-pip

Now we’re ready to install WiringPi2 for Python itself
sudo pip install wiringpi2

You will see lots of messages. pip, the python package installer that you just installed, is compiling WiringPi2 and installing it all for you. After lots of messages starting with “gcc – pthread”, you should see this…

Now you should be good to go. Let’s check that it works with a live Python environment. Type the following commands in the terminal, with end-line between each of them.

sudo python
import wiringpi2

We just imported wiringpi2 and used one of its new functions piBoardRev() which is the built-in Raspberry Pi revision checker.  If that all works as it should, type ctrl+d to exit python

You are installed and ready for action with WiringPi2′s GPIO features.


Now in order to make the buzzer work you need to type the following commands in the terminal (one at a time):

sudo python

import wiringpi2 as wiringpi 

The softTone library is used for producing the signal on the GPIO which is connected to the buzzer. The buzzer is connected to GPIO Pin 4, which corresponds to WiringPi GPIO Pin 7. The second parameter for softToneWrite is the frequency, drive it higher and the alarm sound will become steadily more irritating until you’re sure to wake up!

Pressing Ctrl+D will terminate the python program but will not make the annoying sound disappear. For this, you need to type in the terminal a command which will set the GPIO 7 from High to Low. The following will do: gpio mode 7 in


3) Displaying text on the Clockatoo LCD

By modifying the Clockatoo library provided by Geekroo, text rather than the actual time can be displayed onto the LED Screen. The 4 digit 7-segment display is designed for digits so some of the letters (such as ‘m’ or ‘w’) will appear a bit different on the LED but should make sense.

First, make sure that the program used to display time is not running as it will interfere with the text displaying. Then, you will need to modify the file by typing (when located in the /Geekroo-Product-Clockatoo/R2.0 directory) sudo nano This will open up the python script in which you need to copy and paste the following bits of code:

 # Basic text lookup table ( a-z, -, _ space, 0-9 ), lowercase only
  letters = { 'a':0x77, 'b':0x7c, 'c':0x39, 'd':0x5e, 'e':0x79, 'f':0x71, \
              'g':0x3d, 'h':0x74, 'i':0x06, 'j':0x1e, 'k':0x76, 'l':0x38, \
              'm':0x15, 'n':0x54, 'o':0x5c, 'p':0x73, 'q':0x67, 'r':0x50, \
              's':0x6d, 't':0x78, 'u':0x3e, 'v':0x1c, 'w':0x2a, 'x':0x76, \
              'y':0x66, 'z':0x5b, '0':0x3f, '1':0x30, '2':0x5b, '3':0x4f, \
              '4':0x66, '5':0x6d, '6':0x7d, '7':0x07, '8':0x7f, '9':0x6f, \
              ' ':0x00, '-':0x40, '_':0x08, '.':0x80 }

This needs to be added after the enumeration: digits = [ 0x3F, 0x06, 0x5B, ……… and before the #Constructor. This code enumerates all the letters/digits and characters which will be needed to display text on the screen and assigns each one of them with a value in hexadecimal which corresponds to certain segments on an LCD digit to be turned ON. For example ‘_’:0x08 will only turn ON the lower segment resulting in a “underscore” displayed on the screen.

The following code also needs to be added. This will define a new function called writeTextString which will be called every time text is to be displayed on the LCD. It can be added anywhere towards the end of the code, in between two other functions. For example it can be added between def _init_ and def writeDigitRaw.

def writeTextString(self, string, speed=0.5):
    string = '    ' + string.lower() + '    '
    buf = []
    disp = []
    for c in string:
      if c in self.letters:
      if(len(buf) > 3):
        disp = buf[-4:]
      if (len(disp) > 0):
      if (len(disp) > 1):
      if (len(disp) > 2):
      if (len(disp) > 3):

Once these two pieces of code have been added, save the file with Ctrl+x making sure to overwrite it and not saving it under a new name. Now write the following commands in a terminal (with end of line between each command):

sudo python

from Raspi_7Segment import SevenSegment
delay_seconds = 0.5
segment = SevenSegment(address=0x70)
segment.writeTextString('hello world',delay_seconds)

sudo python enables the python environment in the command line. The next line imports the module Raspi_7Segment which you have just modified, and creates reference in the current namespace to the object SevenSegment located inside the module. Then the segment variable initialised and used to call the newly added writeTextString function to display the text. The delay controls the speed at which characters scroll off to the left, modify this to scroll faster/slower.

Permanent link to this article: