E-Mail / RSS checking LED

Over the serial port?!!

A sample python sketch that reads from the arduino may help to get you started

import sys, os, serial

def monitor():

    ser = serial.Serial(COMPORT, BAUDRATE, timeout=0)

    while (1):
        line = ser.readline()
        if (line != ""):
            #print line[:-1]                 # strip \n
            fields = line[:-1].split('; ')
            ID = fields[0]
            # print fields
            print "device ID: ", ID
            # write to file
            text_file = open("Pdata.log", "w")
            text_file.write(line)
            text_file.close()

        # do some other things here

    print "Stop Monitoring"


""" -------------------------------------------
MAIN APPLICATION
"""  

print "Start Serial Monitor"
print

COMPORT = 4;
BAUDRATE = 115200

monitor()

but the arduino uno haves only a usb port should I replace serial with usb?

but the arduino uno haves only a usb port should I replace serial with usb?

It has a USB to serial converter on board so it appears as a serial port to your computer.

woops sorry I didn't know that

Came across this one today : - Checking email with Python - Stack Overflow
should get you started.

is that pithon 2 or 3 ?

it compiles under my python 2.7
In the comments there is a ref to - http://snippets.dzone.com/posts/show/4024 - which is a more elaborate checker, includes sending mail too.

Robohac:
Hy,

I just finished a LED Cube and thought LED's are good signes. How can I make my Arduino uno recieve E-Mails and RSS feeds, so he can lite a LED? Is USB ok or should I bui the ethernet shield?

Thanks
Robohac

wihtout ethernet shield, your PC must be always on to retrieve emails and send them to Arduino.
With ethernet shield you don't need any PC at all.

But with ethernet shield I need a server. Or not? How should I programm that?

How should I program that?

With difficulty - You would need some kind of server (but if you have an email address then you probably have one you can access). You can probably monitor an imap server for new messages.

Robohac:
But with ethernet shield I need a server. Or not? How should I programm that?

If you do not need active pages (ASP, PHP,...), Arduino is the server: it reads request over the network, and it sends HTML pages as replies.
You can program Arduino in such a way that upon connecting to its IP from remote, it will reply with a web page containing a form which shows text and buttons; you click a button, and something is turned on/off at home. :slight_smile:
If the page is very simple, it can fit in the little onboard memory. If you want to "serve" images and video, yuo'll need a microSD slot to hold the data.

you click a button, and something is turned on/off at home.

I was thinking more of without having a computer on all the time.

mowcius:

you click a button, and something is turned on/off at home.

I was thinking more of without having a computer on all the time.

Then you definitely need an eth shield.
Just decide if you want to make availabale large files (microsd slot required) or just some data.

Well I don't - the OP does.

Just decide if you want to make availabale large files (microsd slot required) or just some data.

You really haven't read the thread properly have you?

They want to have Email notification...

What is Python (Beside a language) and how do I get started? I kind of want to do the same thing.

First you need to Install Python: Download Python | Python.org

Then you have to understand the language (but this is not Necessaray, you learn with the Programms you read)

Maybe you need the Com port here is a little Programm:

import serial
COMPORT = 8
BAUDRATE = 115200
MASSAGE = "Testnachicht"
print "Initialisiere Comport %s mit einer Baudrate von %s" % (COMPORT, BAUDRATE)
ser = serial.Serial(COMPORT, BAUDRATE, timeout=0)
print "Comport Initialisiert"
print "Sende '%s'.." % (MASSAGE)
ser.write('5')
print "...gesendet"

Important is that in this Language no ; and { exist like in Java.

My finished E-Mail Programm that checks for "Start" and sends 1 over serial and "Stop" and sends 2

# -*- coding: cp1252 -*-
import sys, getpass, poplib, re
import serial
import time

# arduino connection
COMPORT = 8
BAUDRATE = 115200

# change according to your needs
POPHOST = "popmail.t-online.de"
POPUSER = "sebastian.frebel@t-online.de"
POPPASS = raw_input("Bitte gieb dein E-Mail Passwort ein:")


# the number of message body lines to retrieve
MAXLINES = 10
HEADERS = "@Arduino".split()
print "Erwartete Header: %s" % (HEADERS)
print "Max. Zeilen: %s" % (MAXLINES)

# headers you're actually interested in
rx_headers = re.compile('|'.join(HEADERS), re.IGNORECASE)

try:
    # Hauptmenüü
    while 1:

        # Space
        print
        print
        print 50 * "_"
        print
        print
        print

        key = raw_input("(w=wait for Massage, o=organize Mailbox, q=quit) What?")
        if key == 'w':
            ser = serial.Serial(COMPORT, BAUDRATE, timeout=0)
# Anfang warten
            # connect to POP3 and identify user
            pop = poplib.POP3(POPHOST)
            pop.user(POPUSER)
    
            if not POPPASS or POPPASS=='=':
                # if no password was supplied, ask for it
                POPPASS = getpass.getpass("Password for %s@%s:" % (POPUSER, POPHOST))

            # authenticate user
            pop.pass_(POPPASS)

            # get general information (msg_count, box_size)
            stat = pop.stat( )

            # print some information
            print "Logged in as %s@%s" % (POPUSER, POPHOST)
            print "Status: %d message(s), %d bytes" % stat
            print "Waiting for assignment for Arduino"




            # eigentliche Programm
            TIME = 10
            bye = 0
            count_del = 0
            
            while 1:
               

                n = 0
                for n in range(stat[0]):

                    msgnum = n + 1
                        
                    # retrieve headers
                    response, lines, bytes = pop.top(msgnum, MAXLINES)

                    # suchen nach Begriff
                    #if lines.find('Stop') != -1:
                        #print "Stop in if gefunden!"


                    
                    if 'Stop' in lines:
                        print "Stop Gefunden!!!"
                        print "Initialisiere Comport %s mit einer Baudrate von %s" % (COMPORT, BAUDRATE)
                        print "Comport Initialisiert"
                        print "Sende 1.."
                        ser.write('1')
                        print "...gesendet"

                    if 'Start' in lines:
                        print "Start Gefunden!!!"
                        print "Initialisiere Comport %s mit einer Baudrate von %s" % (COMPORT, BAUDRATE)
                        print "Comport Initialisiert"
                        print "Sende 2.." 
                        ser.write('2')
                        print "...gesendet"

                    n = n + 1

                n = 0 


 
                print "Status: %d message(s), %d bytes" % stat

                if "start" in response:
                    print "Loooooooooos!"
                pop.quit( )

                # Waits TIMEs
                time.sleep(TIME)
    
                # headers you're actually interested in
                rx_headers = re.compile('|'.join(HEADERS), re.IGNORECASE)

                # connect to POP3 and identify user
                pop = poplib.POP3(POPHOST)
                pop.user(POPUSER)
    
                if not POPPASS or POPPASS=='=':
                    # if no password was supplied, ask for it
                    POPPASS = getpass.getpass("Password for %s@%s:" % (POPUSER, POPHOST))

                # authenticate user
                pop.pass_(POPPASS)

                # get general information (msg_count, box_size)
                stat = pop.stat( )
# Ende warten
        elif key == 'o':
# Anfang Organisation
            # connect to POP3 and identify user
            pop = poplib.POP3(POPHOST)
            pop.user(POPUSER)
    
            if not POPPASS or POPPASS=='=':
                # if no password was supplied, ask for it
                POPPASS = getpass.getpass("Password for %s@%s:" % (POPUSER, POPHOST))

            # authenticate user
            pop.pass_(POPPASS)

            # get general information (msg_count, box_size)
            stat = pop.stat( )

            # print some information
            print "Logged in as %s@%s" % (POPUSER, POPHOST)
            print "Status: %d message(s), %d bytes" % stat

            bye = 0
            count_del = 0
            for n in range(stat[0]):

                msgnum = n+1

                # retrieve headers
                response, lines, bytes = pop.top(msgnum, MAXLINES)

                # print message info and headers you're interested in
                print "Message %d (%d bytes)" % (msgnum, bytes)
                print "-" * 30
                print "\n".join(filter(rx_headers.match, lines))
                print "-" * 30

                # input loop
                while 1:
                    k = raw_input("(d=delete, s=skip, v=view, q=quit) What?")
                    #k = k[:1].lower( )
                    if k == 'd':
                        # Mark message for deletion
                        k = raw_input("Delete message %d? (y/n)" % msgnum)
                        if k in "yY":
                            pop.dele(msgnum)
                            print "Message %d marked for deletion" % msgnum
                            count_del += 1
                            break
                    elif k == 's':
                        print "Message %d left on server" % msgnum
                        break
                    elif k == 'v':
                        print "-" * 30
                        print "\n".join(lines)
                        print "-" * 30
                    elif k == 'q':
                        bye = 1
                        break

                # done ...
                if bye:
                    print "Bye"
                    break

            # summary
            print "Deleting %d message(s) in mailbox %s@%s" % (
                count_del, POPUSER, POPHOST)

            # close operations and disconnect from server
            print "Closing POP3 session"
            pop.quit( )
# Ende Organisation
        elif key == 'q':
            quit()
        else:
            print "Falsche Eingabe. Bitte versuche es nocheinmal."


except poplib.error_proto, detail:
    # possible error
    print "POP3 Protocol Error:", detail

I forgot: The structure is important so:

right:

while 1:

        # Space
        print
        print
        print 50 * "_"

wrong:

while 1:

# Space
print
print
print 50 * "_"

@robohac

Please modify your (excellent) postings, select the code and press the # button to tag it properly,

Thanks,
Rob

With python and Arduino ! the LED trun on when a mail (gmail ) arrive !

http://arduino.cc/forum/index.php/topic,54332.0.html

In french sorry ^^