We mounted a large clock on the wall of our vaulted ceiling and wanted to give it a little more pizzazz. I wanted to give it a Big Ben feel, so I added some speakers, a Raspberry Pi, a little code, and voilà! We now have a mini Big Ben of our own.
With a Wifi connector I am also able to remotely push other audio sounds to the speakers. Think speaker front end for a makeshift security system, or other audio states of your home automation. The possibilities are endless.
CodeThe following is the code I wrote for the cronjob schedule and bash script to determine which audio file to play.
# hourly from 7am to 10pm 0 7-22 * * * /opt/big_ben/big_ben.sh > /dev/null
#!/bin/bash # Author: Kenneth Burgener
2014 # Purpose: Determine hour and play appropriate Big Ben MP3 # crontab: (from 7am and 10pm) # 0 7-22 * * * /opt/big_ben/big_ben.sh > /dev/null # Get hour (1-12) for mp3 file HOUR=`date +%l` HOUR=$(( $HOUR )) # Get military hour (1-24) for math below MILHOUR=`date +%k` MILHOUR=$(( $MILHOUR )) # Set audio volume depending on time of day if [ $MILHOUR -le 8 -o $MILHOUR -ge 20 ] ; then # 8am and earlier, 8pm and later #/usr/bin/amixer set PCM 80% > /dev/null /usr/bin/amixer set PCM 90% > /dev/null else # 9am to 7pm #/usr/bin/amixer set PCM 95% > /dev/null /usr/bin/amixer set PCM 91% > /dev/null fi /usr/bin/mpg123 /opt/big_ben/audio/big_ben_$HOUR.mp3 2> /dev/null
Big Ben Audio
I found a good quality mp3 file that had the full 12 chimes. I then used Audacity to chop the file into smaller versions for the appropriate hour chimes.