Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Intel Galileo Blueprints

You're reading from  Intel Galileo Blueprints

Product type Book
Published in Jun 2015
Publisher
ISBN-13 9781785281426
Pages 192 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Marco Schwartz Marco Schwartz
Profile icon Marco Schwartz

Table of Contents (19) Chapters

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

Chapter 8. Displaying the Number of Unread Gmail E-mails on an LCD Screen

In the previous chapter, we developed software that allowed us to control our Galileo board from anywhere.

In this chapter, you will learn how to integrate another existing application into our Galileo board. We will use its onboard Ethernet connection to connect to our Gmail account. We won't need the help of our computer in doing this: we will simply display the e-mail data on an external LCD screen using the Galileo board.

In this project, we will get the number of unread e-mails in your Gmail account, and display this count on the LCD screen.

Let's start!

Hardware and software requirements


To complete this project, we will need only two major components. First is the Galileo board, of course, and the second one is the LCD screen.

The board that I've used is, again, the Intel Galileo Gen 2 board.

For the LCD screen, I've used the Saint Smart LCD. It's an IIC/I2C/TWI 20x4 LCD with a contrast control knob selector and a backlight. If you don't have this specific type of LCD, you can use any other I2C LCD: it won't be a problem.

You will also need a MicroSD card to store your data.

Here is the picture of the Saint Smart LCD that I have used in this project:

Here is the list of all the components used in this project:

On the software side, you will need the library for the LCD screen you are using. Note that the library depends on the manufacturer...

Hardware configuration


When you get everything you need in place, you may start configuring the hardware. The configuration is pretty simple.

Start by connecting the LCD screen to the Galileo board. To do so, connect the VCC pin of the LCD to the 5V port of the board. Then, connect the LCD's GND to the board's GND pin. Connect the SDA and SCL pins accordingly. You can see the board's SDA and SCL pins labeled as such.

Here is a picture of how the final configuration looks:

Once the configuration is finished, insert the MicroSD card into the Galileo board and connect it to the Ethernet.

Testing the LCD screen


We are now ready to test the LCD screen. The following is the complete code that I've used to do so:

// Libraries
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SD.h>
#include <Ethernet.h>

// LCD Screen
LiquidCrystal_I2C lcd(0x27,20,4);

void setup()
{
  // Initialize LCD screen
  initDisplay();
  
}

void loop()
{
  // Print message on the LCD screen
  lcd.setCursor(0,0);
  lcd.println("This is a test of the LCD screen!");
}

// Initialize LCD screen
void initDisplay()
{
  lcd.init();      
  lcd.backlight();
  lcd.clear();
}

Let's look at the code line by line:

The first part of the code includes the libraries that we need in order to carry out this project. The four libraries that you should include are Wire.h, LiquidCrystal_I2C.h, SD.h, and Ethernet.h:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SD.h>
#include <Ethernet.h>

Then, we declare the LCD instance. If you have used a different screen...

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...

Summary


In this chapter, we looked at how to connect another existing application to our Galileo board. We connected the LCD screen to Arduino and created a code to integrate the e-mail data into the screen.

For future projects, you may opt to read other e-mail data from Gmail or connect to other web services. You can also integrate other apps into the board- for example, you can print new Tweets on the LCD (after all, a tweet is just 140 characters long, at most).

The next chapter is perfect for those with green thumbs. We will be automating our garden using the Galileo board.

lock icon The rest of the chapter is locked
You have been reading a chapter from
Intel Galileo Blueprints
Published in: Jun 2015 Publisher: ISBN-13: 9781785281426
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 $15.99/month. Cancel anytime}