Hello, je suis sur un nouveau projet: un notificateur de mails. J'en suis qu'à des phases de test, et ça commence plutôt mal...
Principe: j'utilise un scripte python qui se connecte à ma boite mail et qui vérifie si oui ou non il y a des mails non lus:
import serial, sys, feedparser
#Settings - Change these to match your account details
USERNAME="xxxxxxxx@gmail.com"
PASSWORD="**************"
PROTO="https://"
SERVER="mail.google.com"
PATH="/gmail/feed/atom"
SERIALPORT = "COM3" # Change this to your serial port!
# Set up serial port
try:
ser = serial.Serial(SERIALPORT, 9600)
except serial.SerialException:
print "no device connected - exiting"
sys.exit()
newmails = int(feedparser.parse(PROTO + USERNAME + ":" + PASSWORD + "@" + SERVER + PATH)["feed"]["fullcount"])
# Output data to serial port
if newmails > 0:
ser.write("m")
print "some mail"
else:
ser.write("n")
print "no mail"
#print data to terminal
# Close serial port
ser.close()
Ce dernier envoie le résultat au port COM3 où est connecté mon arduino (je suppose que c'est le COM3 puisque indiqué dans le logiciel arduino). Ce code fonctionne, donc le problème ne vient surement pas de là, enfin, il détecte bien si oui ou non j'ai des mails.
Ensuite, l'arduino reçoit l'information:
// led wired + to pin 12, resistor to positive +5v
int outPin = 12; // Output connected to digital pin 12
int mail = LOW; // Is there new mail?
int val; // Value read from the serial port
void setup()
{
pinMode(outPin, OUTPUT); // sets the digital pin as output
Serial.begin(9600);
Serial.flush();
mail = HIGH; // start off with lights out
}
void loop()
{
// Read from serial port
if (Serial.available() > 0)
{
val = Serial.read();
if (val == 110) // n = 110 in dec
{
mail = HIGH; // HIGH is off because led is connected to +5v on the other side
}
else if (val == 109) //109 = m in dec
{
mail = LOW; // LOW is on because led is connected to +5v on the other side
}
}
// Set the status of the output pin
digitalWrite(outPin, mail);
}
Sauf que là... bin, ça marche pas ^^. Ma led tressaute un millième de seconde, mais pas moyen de la laisser allumée quand j'ai un nouveau mail... J'ai testé en remplaçant "m" et "n" par "42" et "43" mais même chose...
Une idée ?