I've been really interested in doing J4mie's Physical Gmail Notifier ever since it came out in February. I only recently dropped into the project and got to learn a lot about python, plists, and arduino auto-reset functionality. I'm going to share what I've learned because I think there are lots of other people out there struggling to make it work. This page doesn't really offer much that J4mie didn't already say - it just says it in a different way.
I'll post the code below - one issue with the way J4mie posted his was that it appended line numbers to everything and messed with formatting. Python is _really_ picky about formatting! All of the files are zipped HERE. It consists of three documents -
1) one python script that logs into your gmail rss feed and checks your total number of new messages. It then sends either an 'm' or an 'n' to the serial port.
2) one arduino sketch that tells the arduino to turn on or off a light based on the serial input
3) one .plist file that tells your mac (sorry pcs!) to run the python script every 60 seconds. If you run windows or linux then I'm sure there is something you can do to schedule this. You could also just set it to loop until quit. (to quit a script in terminal hit control-c)
Section 1- Python. You will need to change the python script so that it has your email and password, as well as your serial port info. This assumes you are checking a gmail account. It also works if you are using gmail as your email host for a private domain. The serial port info you can grab from the arduino program or by typing "ls /dev/tty.*" into the terminal. Save that file and put it somewhere on your computer. I picked my Documents folder. You will also need to download and install feedparser. This is what helps python parse the rss feed into useable chunks.
Section two - Arduino. Now go ahead and open the arduino sketch included in the zip file, paste it into your arduino window, and upload it to your arduino. You don't need to change anything on this.
Section three - .plist. Next you should open the plist file and change it so that it points to the python script you changed earlier. If you want to change the frequency that it checks your mail at, that is the "integer" tag towards the end of the file. It is measured in seconds. The plist file should go in your user folder under Library/LaunchAgents. If the folder isn't there then go ahead and make it.
Until you restart the plist won't do anything, so the simplest thing to do is to restart. If not then you can manually run the python script. To do that type "python " into terminal and drag in the python file. Hit return to run it. Once it has run, you can hit the up arrow to recall the last command typed, and return to run it again.
Section four - Wiring The wiring is very easy. Hook up a led and an appropriate resistor (i (should have) used a 22 47 ohm - if you are unsure - use a led calculator) between pin 12 and +5v. The negative (shorter) lead goes to the pin side. Done! (footnote: Make sure that not only are you within spec for your led, but you also aren't sourcing more than 40ma from the pin. Otherwise you could do damage to your Arduino! My initial setup sources 100ma and could have fried the pin.)
Open up the serial monitor in arduino and wait for a signal to come in. It should come in once every 60 seconds, so be patient. If it isn't sending data, then it could be either sending it on the wrong port (check your serial port settings) or the plist could not be working yet (restart, or run it manually) You should be seeing either an "n" or an "m". That should also be turning on or off the LED
One final thing to look out for is that any arduino with auto-reset enabled will only work while the arduino application is running _with_ serial monitor open. Otherwise it will just reset itself every time the data comes in. To check out how to remove arduino auto reset from a bare bones board go here, for other boards, ask the google.
One thing about this is that I didn't really like the bright light shining at me, so I mounted it under my desk, with it pointing up towards the wall. Now it's a subtle glow, and it's much easier to ignore when I have a lot of work.
Summary The plist file should run your python script every 60 seconds. The 'n' or 'm' should be sent from the python script and received by the arduino. Then the arduino tells the led to turn on or off. I tested both statuses (statii?) by logging in and marking messages as read or unread until I was happy with the results.
This has been the first project where I have been able to send serial data in a useable way. I'm excited about moving on to a version that scrapes email info and posts it to an lcd screen, or maybe a project that sends data back to the computer to do something. There is also the distinct possibility that you could script the python carefully enough so that the arduino was not needed for a serial lcd version. a serial port would be the only necessity...




17 responses so far ↓
1 j4mie // Nov 25, 2008 at 10:55 am
Glad you got it working! Cheers!
2 Arduino based rss reader (with LCD)! | Build it up to break it down again // Dec 2, 2008 at 8:18 am
[...] gmail notifier project (for dummies)11.25 [...]
3 Gmail and RSS Notifiers using the Arduino | Hack N Mod // Dec 3, 2008 at 9:27 pm
[...] your computer’s serial port, you can create your own physical notifier which alerts you when you receive email or when an RSS news feed is updated. It can even update you of your friends’ facebook [...]
4 GEARFUSE » Arduino-based Gmail Notifier // Dec 4, 2008 at 9:07 am
[...] Link Read More Control Your Arduino With A TV RemoteFather And Son Arduino Flashlight LeashBorg Cube Let’s You Know You’ve Got MailArduino Controlled Powerball GameGoogle Adds SMS To Gmail Labs TAGS: Arduino, email, gmail, LED, notifier, project, python, utility SHARE: Stumble Upon, Digg, del.icio.us, Reddit this, SlashdotSend to a FriendPermalink [...]
5 Arduino-based Gmail Notifier | American News World - News And Technology // Dec 4, 2008 at 6:03 pm
[...] Link [...]
6 Ben // Dec 24, 2008 at 3:29 am
Thankyou thankyou thankyou! I’d been trying to figure this out for aaaages, but I was having a lot of problems with https requests not working with python, and an oddball character in my usb serial name, but now it works!
I think it was a combination of straight downloading the scripts from you, then installing python2.5, and using the command “ls /dev/tty.* | pbcopy” on the terminal so I could just paste my usb serial into the script, weird character and all!
Thanks again to you and j4mie for taking the time to write it up.
7 Ben // Dec 24, 2008 at 3:31 am
Oh, and to elaborate on the terminal command, it just copies everything that ls throws up onto the clipboard so you can paste it somewhere else.
8 Chris // Jan 10, 2009 at 9:58 pm
I’m having a problem with the python script. When I drag the script into terminal with python running I get the error message “File “”, line 1″, “SyntaxError: invalid syntax”. I’m sure I’m doing something wrong but unfortunately I don’t know what it is. With the script in BBedit I am able to get it to work by clickin on the #! menu and selecting to run it in the Terminal. I’ve tried adding the line “#!/usr/bin/env python” to the first line but I’ve had no luck.
Again when I run the script from within BBedit everything works. With the .plist file in the Library/LaunchAgents nothing happens so I have a problem with my script. Any ideas?
Thanks for the great tutorials!
9 Chris // Jan 11, 2009 at 4:37 pm
Okay, I think I figured it out using Google. To get it to work I added the statement “#!/usr/bin/env python” to the first line of the script. I then made the file executable by typing “chmod +x check-gmail.py”. Now when I drag the script file to the terminal it runs.
10 johnty // Feb 20, 2009 at 12:42 am
neat and clearly written tutorial. thanks! :-)
for windows users, you can do something like this:
//////begin code
Set objShell = CreateObject(”Wscript.Shell”)
do while 1
objShell.Run “C:\Python26\pythonw.exe gmail.py”
Wscript.Sleep 60000
loop
//////end code
save it as a .vbs file, and it should run fine. the above is assuming python is installed at the above location, and the vbs script file is in the same folder as the python script.
11 PaulAndrewF // Mar 18, 2009 at 6:19 pm
Hey everyone, I’m in need of a genius to help me complete this project. I cant believe how cool of a project this is, but being a COMPLETE noob, i have no clue where i went wrong. I followed everything to the best of my ability but im stuck!
I have the arduino all hooked up and programmed, the .plist in place and the python file edited to my information. unfortunately ive never used python before and i have no idea how to run or install everything. Ive tried everything i can think of and googling anything just confuses me more. I have no idea what feedparser is or how to install it. PLEASE HELP! ASAP :)
12 TinyEnormous // Apr 30, 2009 at 9:27 am
Thanks John!
13 TinyEnormous // Apr 30, 2009 at 9:31 am
hey paul!
are you using osx or windows? What problems are you having? I’ll gladly help if you tell me how you are struggling. did you try running the python file? if you are running windows, then johnty wrote how to run a python script. Good luck!
14 IvanM // May 2, 2009 at 6:35 pm
Hello everyone,
I’m having the same problem as PaulAndrewF. I’m using OSX, and although i have the arduino working well, the feedparser is killing me. I can’t figure out how to install it, I keep getting errors. Am I suppose to use the python shell to install the feedparser? I found this line on the internet to install…
python setup.py install
but it doesn’t work. There’s not much information about installing the feedparser out there. Hope you guys could help me out.
Thanks
15 mark // Jun 12, 2009 at 10:06 pm
In reference to IvanM and PaulAndrewF’s problem: in order to install feedparser you must type python setup.py install into terminal. However first you must ensure that terminal is being pointed to the feedparser folder, you do this by chnging directory in terminal – cd Documents/feedparser etc- then run the setup command.
I’ve had my own problem that maybe someone can help with. This script works fine and talks to the arduino when i run the script manually in terminal. However when I try and run the plist with launchd, it tells me that there is no serial module! – ‘ImportError: No module named serial’ – I don’t get why this is happeneing, since the module is obviously installed as it works perfect manually. Any ideas?
Thanks btw for this easy to follow tutorial, perfect for noobs like me:)
16 rFree // Jun 14, 2009 at 9:37 pm
I noticed your 22 ohm resistor, IO pins are only rated to 40mA, I presume you were powering the LED solely through the IO pin?
That would via calculation suggest your LED has a forward voltage of 4.12V if you’re powering it from 5V, which sounds rather high for a while LED, I’d have expected around 3.5V. In summary, are you overloading your IO pin?
17 TinyEnormous // Jun 15, 2009 at 12:36 pm
Hi rFree!
Yes, the 22ohm resistor was chosen with no regard to the io pin rating. It was definitely way over 40Ma. It seems like a safer resistor would be more than double it. 47 seems safe.
Thanks for pointing that out – I’d hate to see someone lose a pin following in my footsteps!
Leave a Comment