loading

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,

sudo apt-get update
sudo apt-get upgrade

or (Jessy)

sudo apt-get dist-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 use 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 only used simple Bash scripting, the mp3s and crontab for this project. I firstly created 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) do/copy the following steps to create the directory and copy the mp3 files to it:

mkdir /home/pi/big-ben
cd /home/pi/big-ben
wget https://www.instructables.com/files/orig/F3C/WOPJ/INC0CAI4/F3CWOPJINC0CAI4.mp3
wget https://www.instructables.com/files/orig/FOP/GM68/INC0CAI9/FOPGM68INC0CAI9.mp3

To create the script do the following:

nano clock.sh

and copy this code to it:

#!/bin/bash
# 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)

Now to activate this script through crontab, use

crontab -e

and paste the following code to the bottom of the cron file:

0,30 * * * * bash /home/pi/big-ben/clock.sh

Remember again to 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 cron for that. Also go and try your own sounds.

Enjoy =)-~

<p>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 ;-)</p>
Thank you Neil!<br><br>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 &quot;little&quot; clock.
<p>Welcome to Instructables. Thanks for sharing with the community.</p>

About This Instructable

1,236views

14favorites

License:

Bio: Veterinarian by profession, but apart from my own pets and keeping my animal hospital afloat, I also find myself busy with creative web design, my ... More »
More by renierdelport:Raspberry Pi Big Ben Clock 
Add instructable to: