Use a Raspberry Pi and Google Calander to set an alarm

Use Google Calendar to set an alarm on the Raspberry Pi.



import gdata.calendar.service
import gdata.service
import atom.service
import gdata.calendar
import gdata.calendar
import atom
import getopt
import sys
import string
import time

import xe #for the time comparator
from import tf_from_timestamp #also for the comparator
from datetime import datetime #for the time on the rpi end
from apscheduler.scheduler import Scheduler #this will let us check the calender on a regular interval
import os, random #to play the mp3 later

#this is more stuff google told me to do, but essentially it handles the login credentials
calendar_service = gdata.calendar.service.CalendarService() = 'youremail@yourdomain' #your email
calendar_service.password = 'yourgcalpassword' #your password
calendar_service.source = 'Google-Calendar_Python_Sample-1.0'

def FullTextQuery(calendar_service, text_query='wake'):
print 'Full text query for events on Primary Calendar: \'%s\'' % ( text_query,)
query = gdata.calendar.service.CalendarEventQuery('default', 'private', 'full', text_query)
feed = calendar_service.CalendarQuery(query)
for i, an_event in enumerate(feed.entry):
for a_when in an_event.when:
print "---"
print an_event.title.text ,"Number:",i,"Event Time:",time.strftime('%d-%m-%Y %H:%M',time.localtime(tf_from_timestamp(a_when.start_time))),"Current Time:",time.strftime('%d-%m-%Y %H:%M')

if time.strftime('%d-%m-%Y %H:%M',time.localtime(tf_from_timestamp(a_when.start_time))) == time.strftime('%d-%m-%Y %H:%M'):
print "Comparison: Pass"
print "---"

songfile = random.choice(os.listdir("/home/pi/alarmclock/test_MP3s/")) #chooses the .mp3 file
print "File Selected:", songfile
command ="mpg321" + " " + "/home/pi/alarmclock/test_MP3s/" + "'"+songfile+"'"+ " -g 100" #plays the MP3 in it's entierty. As long as the song is longer than a minute then will only trigger once in the minute that start of the "wake" event

print command
os.system(command) #runs the bash command
print "Comparison:Fail" #the "wake" event's start time != the system's current time

def callable_func():
os.system("clear") #this is more for my benefit and is in no way necesarry
print "------------start-----------"
print "-------------end------------"

scheduler = Scheduler(standalone=True)
scheduler.start() #runs the program indefinatly on an interval of 5 seconds


Issues with soldering – I recomend Multicore Savbit Alloy Solder

Multicore Alloy SolderI recently purchased Maplins leadfree solder and had lots of issues with it.  I thought it might have something to do with the soldering iron not getting hot enough so bought a new Antex iron.  The old one was over 20 years old.

Unfortunatly the bit on the new iron became very black very quickly and again refused to melt the solder, so I bought new tips for the iron.

After doing some research I found other similar complaints about Maplins own brand solder, so ordered up some Multicore Savbit Aloy Solder from ebay.

What a difference it makes.  It melts quickly and flows easilly.

Multicore Solder Lead Free 038mm Dia 965SN 3AG 5CU MM02108 97SC alloy 250G
Multicore Solder Lead Free 038mm Dia 965SN 3AG 5CU MM02108 97SC alloy 250G $25.00
End Date: Friday Jan-5-2018 11:44:32 PST
Buy It Now for only: $25.00
Size 5 Multicore Tube Savbit Alloy Electrical Solder
Size 5 Multicore Tube Savbit Alloy Electrical Solder $21.13
End Date: Monday Jan-8-2018 22:20:11 PST
Buy It Now for only: $21.13
Old car tool 5 core savbit alloy ersin multicore solder size 5 made Hemel London
Old car tool 5 core savbit alloy ersin multicore solder size 5 made Hemel London $9.62
End Date: Monday Dec-18-2017 9:43:34 PST
Multicore Size 5 Tube Savbit Alloy Solder
Multicore Size 5 Tube Savbit Alloy Solder $11.01
End Date: Wednesday Jan-3-2018 3:18:57 PST
Buy It Now for only: $11.01

My Current Pi Projects


Update 16 July 2016

Raspberry Pi's

Used waiting new use - 1 x Pi2, 1 x B+, 2 x B, 2 x A+, 3 x A
New Raspberry Pi - Zero (1.2), Zero (1.3), B+
Broken - 1 x B+ (water), 2 x B rev 2 (ebay arrived O/S)
Missing - 1 x B rev 1

TinyTX3 - Wireless Sensors -

  • Bathroom - DHT22 Humidity Sensor (Node 11)
  • Kitchen - DHT22 Humidity Sensor (12)
  • Hallway - DHT22 Humidity Sensor (14)
  • Extractor Fan Pipe - DHT22 Humidity Sensor (15)
  • Freezer- DS18B20 1-Wire Temperature Sensor (23)
  • Fridge - DS18B20 1-Wire Temperature Sensor (24)
  • Spare - DS18B20 1-Wire Temperature Sensor (26)
  • PC Case - DS18B20 1-Wire Temperature Sensor (27)
  • Air Con Fan - dual DS18B20 1-Wire Temperature Probes (29)
  • Door Switch (5)
  • Window Switch (6)


This site is a collection of notes, documentation and web links for my Pi's.

Retired Pi Uses

I mainly buy parts from CPC, ModMyPi, Pimoroni and eBay