I’m working on a project where my computer sends me data from my gmail account. if I get an new mail (or have an unread email) this python script sends my Arduino Uno an int with value 1 otherwise an int with value 0.
Now i need my Arduino to send some strings back to my pc. I am doing this with Serial.println("");
The problem with my code is when i run it with
serial_line = ser.readline() print(serial_line)
my code doesn’t grab the unread emails anymore. Anybody know how to solve this?
Here’s the full python script:
import imaplib, serial #import modules ser = serial.Serial('COM3', 9600) #create serial object, enter in the proper port obj = imaplib.IMAP4_SSL('imap.gmail.com') #create imap object, set to gmail obj.login('firstname.lastname@example.org', 'xxxxxx') #enter in gmail credentials #runs continuously while 1: obj.select() #refresh val = len(obj.search(None, 'UnSeen').split()) #generate a value of 1 or 0 #print "The val is: %s\n" % val #print value to monitor ser.write(str(val)) #write value to serial port serial_line = ser.readline() print(serial_line)