Reader small image

You're reading from  Intel Galileo Blueprints

Product typeBook
Published inJun 2015
Publisher
ISBN-139781785281426
Edition1st Edition
Tools
Concepts
Right arrow
Author (1)
Marco Schwartz
Marco Schwartz
author image
Marco Schwartz

Marco Schwartz is an electrical engineer, entrepreneur, and blogger. He has a master's degree in electrical engineering and computer science from Supélec, France, and a master's degree in micro engineering from the Ecole Polytechnique Fédérale de Lausanne (EPFL), Switzerland. He has more than five years' experience working in the domain of electrical engineering. Marco's interests center around electronics, home automation, the Arduino and Raspberry Pi platforms, open source hardware projects, and 3D printing. He has several websites about the Arduino, including the Open Home Automation website, which is dedicated to building home automation systems using open source hardware. Marco has written another book on home automation and the Arduino, called Home Automation With Arduino: Automate Your Home Using Open-source Hardware. He has also written a book on how to build Internet of Things projects with the Arduino, called Internet of Things with the Arduino Yun, by Packt Publishing.
Read more about Marco Schwartz

Right arrow

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('imap.gmail.com', '993')  

# Login to Gmail
obj.login('your_gmail_address','your_gmail_password')

# Print number of unread emails
print len(obj.search(None,'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('imap.gmail.com', '993')  

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

obj.login('your_gmail_address','your_gmail_password...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Intel Galileo Blueprints
Published in: Jun 2015Publisher: ISBN-13: 9781785281426

Author (1)

author image
Marco Schwartz

Marco Schwartz is an electrical engineer, entrepreneur, and blogger. He has a master's degree in electrical engineering and computer science from Supélec, France, and a master's degree in micro engineering from the Ecole Polytechnique Fédérale de Lausanne (EPFL), Switzerland. He has more than five years' experience working in the domain of electrical engineering. Marco's interests center around electronics, home automation, the Arduino and Raspberry Pi platforms, open source hardware projects, and 3D printing. He has several websites about the Arduino, including the Open Home Automation website, which is dedicated to building home automation systems using open source hardware. Marco has written another book on home automation and the Arduino, called Home Automation With Arduino: Automate Your Home Using Open-source Hardware. He has also written a book on how to build Internet of Things projects with the Arduino, called Internet of Things with the Arduino Yun, by Packt Publishing.
Read more about Marco Schwartz