Book Image

Intel Galileo Blueprints

By : Marco Schwartz
Book Image

Intel Galileo Blueprints

By: Marco Schwartz

Overview of this book

Table of Contents (19 chapters)
Intel Galileo Blueprints
About the Author
About the Reviewers
Free Chapter
Setting Up the Galileo Board and the Development Environment

Printing the unread e-mails on the LCD screen

We can now print the number of unread e-mails on the LCD screen.

The code for this function is composed of two parts:

  • The Python script to connect to Gmail

  • The code to read the number of unread e-mails that you have in Gmail

We'll also need the Arduino sketch to get this number and display it on the LCD screen.

Let's look at the complete Python script first:

# Import library
import imaplib

# Connect to Gmail
obj = imaplib.IMAP4_SSL('', '993')  

# Login to Gmail

# Print number of unread emails
print len(,'UnSeen')[1][0].split())

Now, let's analyze it. The first thing that this code does is import the imaplib library:

import imaplib

Then, it connects to Gmail:

obj = imaplib.IMAP4_SSL('', '993')  

After this, it will enter the Gmail e-mail ID and password. You should replace the dummy characters with your own credentials: