Tuesday, 28 October 2008

DIY Gmail Notifier

I actually also researched in this particular idea last year when we had Maverick Machines. It took my interest then that we could use the Arduino to present a more physical way of grabbing someone's attention.



The following guide is deliberately fairly high-level, because the exact details will vary depending on your operating system and particular hardware setup. I did this with my Mac, but hopefully there'll be enough information here for you make it work on your system, perhaps with a little Googling.

If you don't happen to have a glowing cube lying around, you can modify this to work with almost any output device you could think of, from a simple LED, or a buzzer, to something far more clever like moving a servo (Gmail Notifier Robot, anyone?)


Again in this project a Arduino is used or rather a Boarduino. Probarly the main important thing here is the code that drives this project to turn the light to a specific colour. The hardware set-up itself is not something very complicated that we have not seen before.

I was however intrigued by using a different language to drive the Arduino the code seems pretty straightforward and gives some more insight on how to read the USB Serial port as well.

1. import serial, sys, feedparser
2.
3. #Settings - Change these to match your account details
USERNAME="username@gmail.com"
PASSWORD="yourpassword"
4. PROTO="https://"
SERVER="mail.google.com"
PATH="/gmail/feed/atom"
5.
6. SERIALPORT = "/dev/tty.usbserial-FTDK0P3M" # Change this to your serial port!
7.
8. # Set up serial port
9. try:
10. ser = serial.Serial(SERIALPORT, 9600)
11. except serial.SerialException:
12. sys.exit()
13.
14. newmails = int(feedparser.parse(PROTO + USERNAME + ":" + PASSWORD + "@" + SERVER + PATH)["feed"]["fullcount"])
15.
16. # Output data to serial port
17. if newmails > 0: ser.write('M')
18. else: ser.write('N')
19.
20. # Close serial port
21. ser.close()


The above code is Python script which is used in combination with the Universal Feed Parser module from feedparser.org

Source

No comments: