Simple Arduino Gmail Notifier Project

Simple python script checks for mail using imaplib and tells the arduino via serial connection. Arduino activates a simple servo motor rotating the flag.

Code:

import serial
import time
import imaplib, re

ser = serial.Serial(3)
print "Starting on " +ser.portstr;
conn = imaplib.IMAP4_SSL("imap.gmail.com", 993)
while (True):
conn.login('YOUR GMAIL USERNAME','YOUR PASSWORD')
unreadCount = int(re.search("UNSEEN (d+)", conn.status("INBOX", "(UNSEEN)")[1][0]).group(1))
if(unreadCount > 0):
print str(unreadCount) + " new mails!"
ser.write("M")
else:
print "no mail :("
ser.write("N")
time.sleep(5)

And on the arduino:

#include

int outPin = 2; // Output connected to digital pin 2
int mail = LOW; // Is there new mail?
int val; // Value read from the serial port
Servo motor;
void setup()
{

Serial.begin(9600);
Serial.flush();
motor.attach(outPin);
}

void loop()
{
// Read from serial port
if (Serial.available())
{
val = Serial.read();
Serial.println(val);
if (val == 'M') mail = HIGH;
else if (val == 'N') mail = LOW;
}

// Set the angle of the servo
if(mail)
motor.write(0);
else
motor.write(90);
}

via Redit

Other cool hacks and mods from our Archives:

1 comment to Simple Arduino Gmail Notifier Project

Leave a Reply to nikhil

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>