Introduction: Raspberry Pi Big Ben Clock

Want your own grandfather or cuckoo sounding clock run on each hour? Stay tuned. I've been using Instructables for so long long now, so I decided to give something back. Introducing my Raspberry Pi Big Ben Clock.

This is a small little project I did out of a bit of boredom because I had a 'silent' Raspberry Pi behind my TV who's only job was to play mp3s on demand (maybe an Instructable for another day).

The Raspberry Pi Big Ben Clock is basically an audio simulation of a grandfather or cuckoo clock using some edited mp3's I got off the internet, some Bash scripting and crontab. It is called Big Ben because the audio files I decided to use was from the Great Bell in London, England.

You can use any audio of your choice, but this fairly simple Instructable will help you to put it all together.

Step 1: Requirements

This Instructable will be very easy for those who owns and/or are familiar with the Raspberry Pi. You will obviously need one, pre-installed with the very popular Raspbian operating system. I used Wheezy, but the steps will be the same with Jessy.

You will also need to be connected to the internet to be able to do the latest update/upgrade,

sudo apt-get update
sudo apt-get upgrade

get the necessary additional software like MPlayer

 sudo apt-get install mplayer

and to get the time accurately (usually done automatically if your location settings are correct).

I used a B model Raspberry Pi, with which you can run audio through the HDMI cable, but I preferred using the audio jack instead (configurable through Raspi-config or the GUI).

Step 2: Do the Coding

I used a simple Bash script, the mp3s and Crontab for this project. Create a big-ben directory in a known location to hold the Bash script and the mp3s. For explanation, I will use /home/pi/big-ben. To get started, you can download mine below - originally from the UK Parliament website.

From a freshly booted Raspbian terminal (i.e. the default working directory, which should be /home/pi) copy the following lines one-by-one to create the directory and copy the mp3 files:

mkdir /home/pi/big-ben
cd /home/pi/big-ben

To create the script:


and copy this code to it:

# Triggered through Crontab every 30 minutes minute=$(date +"%M") if [[ $minute == 30 ]] then mplayer "/home/pi/big-ben/FOPGM68INC0CAI9.mp3" elif [[ $minute == 00 ]] then mplayer "/home/pi/big-ben/F3CWOPJINC0CAI4.mp3" hour=$(date +"%I") x=0 while [ $x -lt $hour ] do mplayer "/home/pi/big-ben/FOPGM68INC0CAI9.mp3" let x=x+1 done fi

Remember to exit & save (Ctrl + x, y Enter)

To add this script to Crontab:

crontab -e

By adding the following command to Crontab, the scrip will be executed every 30 minutes:

0,30 * * * * bash /home/pi/big-ben/

Exit & save (Ctrl + x, y Enter)

Step 3: Conclusion

That's about it! Sit back and wait for the magic to happen if the clock strikes.

You can go back and look a bit deeper into what I did and make your own changes. I for example added Bash to prevent this clock script running in the evenings. You can also use Crontab for that. Also go and try your own sounds.

For more like this, see my Blog.

Enjoy =)-~


neilblenkiron (author)2016-04-25

What a great Instructable. I have it running on my Pi, laptop and desktop computers. Must remember to turn off when I'm in the library though ;-)


Thank you Neil!

Lately I have it running on 2 different Pis in different locations in my house. I also use it on my Raspberry Pi alarm clock next to my bed. Adopted it to automatically switch off when I sleep, and turn back on after the time my alarm clock is set. I think the ability to switch it off when needed makes it such an awesome "little" clock.

About This Instructable




Bio: I also find myself busy with creative web design, my websites, motorcycling, photo shopping, micro electronics, non-commercialised music, superhero movies, bad ass series and many ... More »
More by renierdelport:Bluetooth Audio Device on OpenELECInstalling & Using Arduino IDE on a Raspberry Pi 3Raspberry Pi Big Ben Clock
Add instructable to: