Email Notifier Tutorial

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
Exigent
 
Posts: 1
Joined: Thu Dec 20, 2012 8:46 am

Email Notifier Tutorial

Post by Exigent »

tried this as my first project on RPi but getting this error when i run the script:

File "./raspi-gmail.py", line 2
SyntaxError: Non-ASCII character '\xc2' in file ./raspi-gmail.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

this is what i used to create the file by just copy/paste :

cat <<! > raspi-gmail.py
#!/usr/bin/env python

import RPi.GPIO as GPIO, feedparser, time

DEBUG = 1

USERNAME = "username" # just the part before the @ sign, add yours here
PASSWORD = "password"

NEWMAIL_OFFSET = 1 # my unread messages never goes to zero, yours might
MAIL_CHECK_FREQ = 60 # check mail every 60 seconds

GPIO.setmode(GPIO.BCM)
GREEN_LED = 18
RED_LED = 23
GPIO.setup(GREEN_LED, GPIO.OUT)
GPIO.setup(RED_LED, GPIO.OUT)

while True:

newmails = int(feedparser.parse("https://" + USERNAME + ":" + PASSWORD +"@mail.google.com/gmail/feed/atom")["feed"]["fullcount"])

if DEBUG:
print "You have", newmails, "new emails!"

if newmails > NEWMAIL_OFFSET:
GPIO.output(GREEN_LED, True)
GPIO.output(RED_LED, False)
else:
GPIO.output(GREEN_LED, False)
GPIO.output(RED_LED, True)

time.sleep(MAIL_CHECK_FREQ)
!

Any ideas? Can I just delete the file and start over ?

Killerspec
 
Posts: 1
Joined: Tue Feb 22, 2011 11:51 am

Re: Email Notifier Tutorial

Post by Killerspec »

Hi

Looking for some help! I have put together this project and I know that the e-mail thing is working as in Putty window it is showing the updates. My problem is that my LED's stay on all the time no matter what I do I even tried to change the out puts from 18 and 23 to 21 and 24 but no joy please help.

Thanks a million in advance.

Matthew

User avatar
wanders11
 
Posts: 1
Joined: Sat Jan 19, 2013 12:59 pm

Re: Email Notifier Tutorial

Post by wanders11 »

I am having a lot of problems running this script, BUT I have found and solved my instance of the problem you have.

I don't know what the origin of it was, but there were unprintable characters showing up in my raspi-gmail.py after I created it and tried to run it.

I both cut and pasted or handwrote the script using either nano or Leafpad. I removed blank lines and the problem would disappear (for that line - only to be replaced by the same error in the next blank line) SO: What I found were unprintable characters (possibly formatting or control codes) that were carried into the script. Removing the line and reinserting it cured the problem - even when there was a "blank" line. It turns out that the line wasn't blank, just unprintable.

I hope this helps.

Ron2222
 
Posts: 2
Joined: Fri Feb 15, 2013 8:01 pm

Raspberry Pi E-mail Notifier Using LEDs

Post by Ron2222 »

I am also have a problem making the Gmail Python working. when I run the program here is what I get:
pi@raspberrypi ~ $ sudo ./raspi-gmail.py
Traceback (most recent call last):
File "./raspi-gmail.py", line 21, in <module>
newmails = int(feedparser.parse("https://" + USERNAME + ":" + PASSWORD +"@ma il.google.com/gmail/feed/atom")["feed"]["fullcount"])
File "/usr/local/lib/python2.7/dist-packages/feedparser.py", line 375, in __ge titem__
return dict.__getitem__(self, key)
KeyError: 'fullcount'

I am new to the Raspberry Pi and Python. If someone would be so kind to help me
Thanks Ron

killeth
 
Posts: 1
Joined: Wed May 22, 2013 4:31 pm

Re: Email Notifier Tutorial

Post by killeth »

Hi just a quick update to the problem with the copy and paste section in the tutorial. The problem arises because the window the code appears in has embedded hidden code and when you copy it, it carries that hidden code with it. At the bottom of that window on the right hand side you can click to see the raw file. Click here and another screen in your browser will open, this is pure text without any hidden formatting code. Copy this and you will not have any problems with pasting and creating the file. BUT the python script will not run on my Pi and I am desperately searching for the reason. Which is why I ended up here Hey oh.

User avatar
sjarvis
 
Posts: 7
Joined: Sun Jun 09, 2013 9:20 pm

Re: Email Notifier Tutorial

Post by sjarvis »

I have the script running under Occidentalis 0.2, and the script returns the proper value from gmail, but NOTHING lights up on my board.

I have my RPi B connected with the ribbon cable to a Pi Cobbler on a half-size board. Everything is wired up exacly like in the photos in the tutorial, but I can't get any LEDs to light up.

I don't have any female-to-male wires to try connecting straight from the GPIO pins to the breadboard, but I suspect hardware issues.

Do I need to restart the RPi after each time I wire the board up or change something?

Thanks,

Steven

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Email Notifier Tutorial

Post by adafruit_support_mike »

Are you sure your LED is plugged in the right way around? More generally, have you tested the LED by applying voltage directly and confirming that it lights up?

User avatar
sjarvis
 
Posts: 7
Joined: Sun Jun 09, 2013 9:20 pm

Re: Email Notifier Tutorial

Post by sjarvis »

Turns out I had my GPIO ribbon cable installed backwards. I read and re-read and re-read AGAIN the setup, but I kept incorrectly interpreting the directions on how to hook up the ribbon cable.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Email Notifier Tutorial

Post by adafruit_support_mike »

Ah, the old "ribbon cable orientation issue".. it's driven many a brave soul to drink, despair, and the occasional "calibration hammer" incident.

Welcome to the club, and I'm glad you got it working. ;-)

User avatar
phil.drummond
 
Posts: 125
Joined: Sun Feb 08, 2009 4:57 pm

Re: Email Notifier Tutorial

Post by phil.drummond »

I got the email notifier to work with my Pi and LCD pi plate!
Here is my script...

Code: Select all

#!/usr/bin/env python

from time import sleep
from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
import RPi.GPIO as GPIO, feedparser, time

# Initialize the LCD plate.  Should auto-detect correct I2C bus.  If not,
# pass '0' for early 256 MB Model B boards or '1' for all later versions
lcd = Adafruit_CharLCDPlate()

# Clear display and show greeting, pause 1 sec
lcd.clear()
lcd.message("raspi-gmail.py")
sleep(1)

DEBUG = 1

USERNAME = "username" # just the part before the @ sign, add yours here
PASSWORD = "password"

NEWMAIL_OFFSET = 0 # my unread messages never goes to zero, yours might
MAIL_CHECK_FREQ = 600

while True:

   newmails = int(feedparser.parse("https://" + USERNAME + ":" + PASSWORD +"@mail.google.com/gmail/feed/atom")["feed"]["fullcount"])

   if DEBUG:
      lcd.clear()
      text = "Mail Count: " + str(newmails)
      lcd.message('GMAIL username\n')
      lcd.message(text)

      if newmails > NEWMAIL_OFFSET:
         col = (lcd.RED)
         lcd.backlight(col)
      else:
         col = (lcd.GREEN)
         lcd.backlight(col)

   sleep(MAIL_CHECK_FREQ)

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”