Smart Radio Alarm Clock

I struggle to get out of bed in the morning. And traditional alarms are horrible, there cannot be anything worse than getting rudely awoken by a blaring, repetitive noise! What would be much nicer would be to wake up to a playlist of beautiful music of your own choice.

The alarm has been through many iterations to get to it’s current state. I started with a raspberry pi connected to some old speakers but then I found an old radio which made the perfect case for the job. The audio quality has also gone way up since I first started mainly thanks to the inclusion of a HifiBerry AMP – fairly expensive but it solved practically every problem I was having with audio: It prevents any annoying static feedback noise; It can now power ridiculously big speakers to a high volume; And it powers the raspberry pi meaning I only need one power supply for everything.

2015-10-18 14.14.44

Behind the scenes there is an amazing piece of software called mopidy that is doing the hard work. It can connect to Spotify, SoundCloud, Google Music, Internet radio, YouTube and loads more to stream music from the internet. Mopidy itself is just a backend that does a heap of clever things to convert all of those online sources into a mpd server. So to be able to play music you need a frontend. That’s where Pi MusicBox comes in: Pi MusicBox is a Raspberry Pi distro that has mopidy installed and a bunch of extra niceties  thrown in to make it “the Swiss Army Knife of streaming music”.

The only part that I have written myself is the alarm clock system. I wrote it in node.js as a bit of an experiment but it worked out well. It uses schedules that can be written using cron syntax or something more human friendly and when the time is right it fires off a fairly simple sequence:

  1. Set the volume to 0
  2. Load up the alarm playlist
  3. Shuffle the playlist
  4. Play the music
  5. Slowly raise up the volume to a nice level

The code for the alarm is up at https://github.com/terminalpixel/node-alarm.

Since the alarm is constantly internet connected it can be expanded to do so much more in the future. At the moment I have the ability for it to switched on and off by any internet connected devices and also send messages out to other devices when the alarm goes off. So there are a bunch of things I’d love to do with this:

  • Send mean tweets about myself when I don’t get up
  • Switch on the lights when the alarm goes off
  • Have a giant button to hit to switch off the alarm
  • Pull the sheets off the bed when the alarm goes off
  • Have some sort of passive aggressive thing where you can wake up a friend or random person somewhere