Go Down

Topic: E-Mail / RSS checking LED (Read 2983 times) previous topic - next topic

jumpjack


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.  :)
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.

mowcius

Quote
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.

jumpjack


Quote
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.

mowcius

Well I don't - the OP does.

Quote
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...

AKSoapy29

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

Robohac

#20
May 17, 2011, 05:51 pm Last Edit: May 17, 2011, 07:43 pm by Robohac Reason: 1
First you need to Install Python: http://www.python.org/download/

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:

Code: [Select]
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

Code: [Select]
# -*- 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


Robohac

#21
May 17, 2011, 05:52 pm Last Edit: May 17, 2011, 07:41 pm by Robohac Reason: 1
I forgot: The structure is important so:

right:
Code: [Select]
while 1:

       # Space
       print
       print
       print 50 * "_"

wrong:
while 1:

# Space
print
print
print 50 * "_"

robtillaart

@robohac

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

Thanks,
Rob
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

chicotore

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 ^^
Mon Blog sur l'environnement Arduino ... Tutos fait par un débutant pour les débutants ^^

http://chicowebsite.free.fr/

Go Up