Raspberry Pi as a Google Calendar Alarm Clock

This post isn’t really thumbnail conducive but I tried!

I have been sleeping in too much. I would like an alarm clock that is easy to set and will play a random song to wake me up.

For a while I was using this program, but as you may be able to tell it requires an awful lot of user input, which isn’t ideal for a sleepy person as they may mess up (as I have, thus this post) but the “fire()” command works really well. To use this program you will need AP scheduler and MPG321 (sudo apt-get install mpg321)

But it wasn’t working. I wanted a way to re-purpose a service I use everyday (that way I wouldn’t have to modify my workflow) as an Alarm Clock. I landed on Google Calendar because I can add events from pretty much every device I interact with on a daily basis, and upon searching found out that developing using the python API wasn’t that hard at all.

To kick things off, you’ll need to download and install the Google Data Library.

I’ll be using this version. Unzip the .tar.gz and from the top top level directory it creates, install the setup.py file. Then run the tests/run_data_tests.py to see if it all works. Mine does fine but it if yours doesn’t, go through this guide written by google to get yourself up and running.

The brunt of this program comes down to a single boolean statement, but first we have to set that up. The API produces an rfc3339 time, and that’s a lot of irrelevant information for this application.

To convert the time I’m using something I found on stackoverflow.

Here’s a video of the system in action, and a basic overview of the setup:

Here’s my program:

And there you have it! thanks for reading and leave me a comment if you have any questions/suggestions.