Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Intel Galileo Blueprints

You're reading from   Intel Galileo Blueprints Discover the true potential of the Intel Galileo board for building exciting projects in various domains such as home automation and robotics

Arrow left icon
Product type Paperback
Published in Jun 2015
Publisher
ISBN-13 9781785281426
Length 192 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Marco Schwartz Marco Schwartz
Author Profile Icon Marco Schwartz
Marco Schwartz
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Intel Galileo Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Setting Up the Galileo Board and the Development Environment FREE CHAPTER 2. Creating a Weather Measurement and Data Logging Station 3. Controlling Outputs Using the Galileo Board 4. Monitoring Data Remotely 5. Interacting with Web APIs 6. Internet of Things with Intel Galileo 7. Controlling Your Galileo Projects from Anywhere 8. Displaying the Number of Unread Gmail E-mails on an LCD Screen 9. Automated Remote Gardening with Intel Galileo 10. Building a Complete Home Automation System 11. Building a Mobile Robot Controlled by the Intel Galileo Board 12. Controlling the Galileo Board from the Web in Real Time Using MQTT Index

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 chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images