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.
Demonstration
Code
The following is the code I wrote for the cronjob schedule and bash script to determine which audio file to play.cronjob schedule:
# hourly from 7am to 10pm 0 7-22 * * * /opt/big_ben/big_ben.sh > /dev/null
big_ben.sh:
#!/bin/bash # Author: Kenneth Burgener2014 # 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.
- big_ben.zip
- big_ben_1.mp3
- big_ben_2.mp3
- big_ben_3.mp3
- big_ben_4.mp3
- big_ben_5.mp3
- big_ben_6.mp3
- big_ben_7.mp3
- big_ben_8.mp3
- big_ben_9.mp3
- big_ben_10.mp3
- big_ben_11.mp3
- big_ben_12.mp3
- big_ben_12.mp3
Works great! Got this working on my LinuxMint 17.3 desktop, now for putting it into my long case clock with a Raspberry Pi. Thanks.
ReplyDeleteI love your idea of this clock. If I get some free time, I'm going to be trying this out for sure, although I would need some time to learn how to code.
ReplyDeleteHere is my take on a ships clock for the same idea, you will need to provide the sound files on your own.
ReplyDelete#!/bin/bash
# Triggered through Crontab every 30 minutes
minute=$(date +"%M")
hour=$(date +"%I")
if [[ $minute == "00" ]]
then
if [[ $hour == "04" || $hour == "08" || $hour == "12" ]]
then mplayer /home/richard/big-ben/eight-bells.mp3
elif [[ $hour == "03" || $hour == "07" || $hour == "11" ]]
then mplayer /home/richard/big-ben/six-bells.mp3
elif [[ $hour == "02" || $hour == "06" || $hour == "10" ]]
then mplayer /home/richard/big-ben/four-bells.mp3
elif [[ $hour == "01" || $hour == "05" || $hour == "09" ]]
then mplayer /home/richard/big-ben/two-bells.mp3
fi
fi
if [[ $minute == "30" ]]
then
if [[ $hour == "04" || $hour == "08" || $hour == "12" ]]
then mplayer /home/richard/big-ben/one-bell.mp3
elif [[ $hour == "03" || $hour == "07" || $hour == "11" ]]
then mplayer /home/richard/big-ben/seven-bells.mp3
elif [[ $hour == "02" || $hour == "06" || $hour == "10" ]]
then mplayer /home/richard/big-ben/five-bells.mp3
elif [[ $hour == "01" || $hour == "05" || $hour == "09" ]]
then mplayer /home/richard/big-ben/three-bells.mp3
fi
fi
Raspberry Pi is a great oportunity to learn electronics basics
ReplyDeleteplz upload sounds again
ReplyDelete