Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Intel Edison Projects
Intel Edison Projects

Intel Edison Projects: Build exciting IoT projects with Intel Edison

eBook
$9.99 $29.99
Paperback
$38.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Intel Edison Projects

Setting up Intel Edison

In every Internet of Things (IoT) or robotics project, we have a controller that is the brain of the entire system. Similarly, we have the Intel Edison. The Intel Edison computing module comes in two different packages: one is a mini-breakout board; the other is an Arduino-compatible board. One can use the board in its native state as well, but in that case the we have to fabricate our own expansion board. The Edison is basically the size of an SD card. Due to its tiny size, it's perfect for wearable devices. However, it's capabilities makes it suitable for IoT applications; and above all, the powerful processing capability, makes it suitable for robotics applications. However we don't simply use the device in this state. We hook up the board with an expansion board. The expansion board provides the user with enough flexibility and compatibility for interfacing with other units. The Edison has an operating system that runs the entire system. It runs a Linux image. So, to set up your device, you initially need to configure your device both at the hardware and at the software level.

In this chapter, we will be covering the following topics:

  • Setting up the Intel Edison
  • Setting up the developer environment
  • Running sample programs on the board using Arduino IDE, Intel XDK, and others
  • Interacting with the board by using our PC

Initial hardware setup

We'll concentrate on the Edison package that comes with an Arduino expansion board. Initially, you will get two different pieces:

  • The Intel® Edison board
  • The Arduino expansion board

The following figure shows the architecture of the device:

Architecture of Intel Edison. Picture Credits: http://www.software.intel.com

We need to hook these two pieces up in a single unit. Place the Edison board on top of the expansion board so that the GPIO interfaces meet at a single point. Gently push the Edison against the expansion board. You will hear a click. Use the screws that come with the package to tighten the setup. Once this is done, we'll now set up the device both at hardware level and software level to be used further. The following are the steps we'll cover in detail:

  1. Downloading the necessary software packages
  2. Connecting your Intel® Edison to your PC
  3. Flashing your device with the Linux image
  4. Connecting to a Wi-Fi network
  5. SSH-ing your Intel® Edison device

Downloading the necessary software packages

To move forward with the development on this platform, we need to download and install a couple of software packages, which includes the drivers and the IDEs. The following is the list of the software along with the links that are required:

Drivers and miscellaneous downloads

Plugging in your device

After the software and drivers have all been installed, we'll connect the device to a PC. You need two Micro-B USB cables(s) to connect your device to the PC. You can also use a 9V power adapter and a single Micro-B USB cable, but for now we won't use the power adapter. The main use of the power adapter will come in a later section of this book, especially when we'll be interfacing with other devices that require USB.The following figure shows different sections of an Arduino expansion board of the Intel Edison:

Different sections of an Arduino expansion board of Intel Edison

A small switch exists between the USB port and the OTG port. This switch must be towards the OTG port because we're going to power the device from the OTG port and not through the DC power port. Once it is connected to your PC, open your device manager and expand the ports section. If all the installations of the drivers were successful, then you'll see two ports:

  • Intel Edison virtual com port
  • USB serial port

Flashing your device

Once your device is successfully detected and installed, you need to flash your device with the Linux image. For this we'll use the flash tool provided by Intel:

  1. Open the flash lite tool and connect your device to the PC:
Intel phone flash lite tool
  1. Once the flash tool is opened, click on Browse... and browse to the .zip file of the Linux image you have downloaded.
  2. After you click on OK, the tool will automatically unzip the file.
  1. Next, click on Start to flash:
Intel® Phone flash lite tool — stage 1
  1. You will be asked to disconnect and reconnect your device. Do this, and the board should start flashing. It may take some time before the flashing is completed. Don't tamper with the device during this process.
  2. Once the flashing is completed, we can configure the device:
Intel® Phone flash lite tool — complete

Configuring the device

After flashing successfully, we'll now configure the device. We're going to use the PuTTY console for the configuration. PuTTY is an SSH and telnet client, developed originally by Simon Tatham for the Windows platform. We're going to use the Serial section here.

Before opening the PuTTY console, open up the Device manager and note the port number for the USB serial port. This will be used in your PuTTY console:

Ports for Intel® Edison in PuTTY

Next, select Serial on the PuTTY console and enter the port number. Use a baud rate of 115,200. Press Open to open the window for communicating with the device:

PuTTY console — login screen

Once you are in the PuTTY console, you can execute commands to configure your Edison. The following is the set of tasks we'll do in the console to configure the device:

  1. Provide a name for your device.
  2. Provide a root password (SSH your device).
  3. Connect your device to Wi-Fi.

Initially, when in the console, you will be asked to log in. Type in root and press Enter. You will see root@edison, which means that you are in the root directory:

PuTTY console login success

Now, we are in the Linux Terminal of the device. Firstly, we'll enter the following command for the setup:

configure_edison -setup

Press Enter after entering the command, and the entire configuration will be straightforward:

PuTTY console set password

Firstly, you will be asked to set a password. Type in a password and press Enter. You need to type in your password again for confirmation. Next, we'll set up a name for the device:

PuTTY console set name

Give a name for your device. Please note that this is not the login name for your device. It's just an alias for your device. Also the name should be atleast five characters long. Once you've entered the name, it will ask for confirmation: press y to confirm. Then it will ask you to set up Wi-Fi. Again select y to continue. It's not mandatory to set up Wi-Fi, but it's recommended. We need the Wi-Fi for file transfer, downloading packages, and so on:

PuTTY console set Wi-Fi

Once the scanning is completed, we'll get a list of available networks. Select the number corresponding to your network and press Enter. In this case, it's 5, which corresponds to avirup171 which is my Wi-Fi. Enter the network credentials. After you do that, your device will be connected to Wi-Fi. You should get an IP address after your device is connected:

PuTTY console set Wi-Fi -2

After successful connection, you should get this screen. Make sure your PC is connected to the same network. Open up the browser in your PC, and enter the IP address shown in the console. You should get a screen similar to this:

Wi-Fi setup completed

Now, we've finished with the initial setup. However, the Wi-Fi setup normally doesn't happen in one go. Sometimes your device doesn't get connected to Wi-Fi and sometimes we cannot get the page shown previously. In those cases, you need to start wpa_cli to manually configure Wi-Fi.

Refer to the following link for the details:

http://www.intel.com/content/www/us/en/support/boards-and-kits/000006202.html

With Wi-Fi setup completed, we can move forward to set up our developer environment. We'll cover the following programming languages and the respective IDEs:

  • Arduino processor language (C/C++)
  • Python
  • Node.js

Arduino IDE

The Arduino IDE is a famous, and widely used, integrated developer environment that not only covers Arduino boards but also many other boards of Intel including Galileo, Edison, Node MCU, and so on. The language is based on C/C++. Once you download the Arduino IDE from the link mentioned at the beginning of this chapter, you may not receive the Edison board package. We need to manually download the package from the IDE itself. To do that, open up your Arduino IDE, and then go to Tools | Board: "Arduino/Genuino Uno" | Board Manager...:

Arduino IDE

You now need to click on Boards Manager and select Intel i686 Boards. Click on the version number and then click on Install. Boards Manager is an extremely important component of the IDE. We use the Boards Manager to add external Arduino-compatible boards:

Boards Manager

Once installed, you should see your board displayed under Tools Boards:

Board installation successful

Once successfully installed, you will now be able to program the device using the IDE. Like every starter program, we'll also be burning a simple program into the Intel Edison which will blink the on-board LED at certain intervals set by us. Through this, the basic structure of the program using the Arduino IDE will also be clear. When we initially open the IDE, we get two functions:

  • void setup()
  • void loop()

The setup function is the place where we declare whether the pins are to be configured in output mode or input mode. We also start various other services, such as serial port communication, in the setup method. Depending on the usecase, the implementation changes. The loop method is that segment of the code that executes repeatedly in an infinite sequence. Our main logic goes in here. Now we need to blink an LED with an interval of 1 second:

#define LED_PIN 13 
void setup()
{
pinMode(LED_PIN, OUTPUT);
}

void loop()
{
digitalWrite(LED_PIN, HIGH);
delay(1000);
digitalWrite(LED_PIN, LOW);
delay(1000);
}

In the preceding code, the line #define LED_PIN 13 is a macro for defining the LED pin. In the Arduino expansion board, an LED and a resistor is already attached to pin 13, so we do not need to attach any additional LEDs for now. In the setup function, we have defined the configuration of the pin as output using the pinMode function with two parameters. In the loop function, we have initially set the pin to high by using the digitalWrite function with two parameters, and then we've defined a delay of 1,000 miliseconds which is equivalent of 1 second. After the delay, we set the pin to low and then again define a delay of 1 second. The preceding code explains the basic structure of the Arduino code written in the Arduino IDE.

To burn this program to the Edison device, first compile the code using the compile button, then select the port number of your device, and finally click the Upload button to upload the code:

Arduino IDE — blink

The port number can be selected under Tools | port.

Now that we know how to program using an Arduino, let's have a look at how it actually works or what's happening inside the Arduino IDE.

A number of steps actually happen while uploading the code:

  1. First, the Arduino environment performs some small transformations to make sure that the code is correct C or C++ (two common programming languages).
  2. It then gets passed to a compiler (avr-gcc), which turns the human readable code into machine readable instructions (or object files).
  3. Then, your code gets combined with (linked against), the standard Arduino libraries that provide basic functions such as digitalWrite() or Serial.print(). The result is a single Intel hex file, which contains the specific bytes that need to be written to the program memory of the chip on the Arduino board.
  4. This file is then uploaded to the board, transmitted over the USB or serial connection via the bootloader already on the chip or with external programming hardware.

Python

Edison can also be programmed in Python. The code needs to be run on the device directly. We can either directly program the device, using any editor, such as the VI editor, or write the code in the PC first, and then transfer it using any FTP client, like FileZilla. Here we'll first write the code using Notepad++ and then transfer the script. Here also, we'll be executing a simple script which will blink the on-board LED. While dealing with Python and hardware, we need to use the MRAA library to interface with the GPIO pins. This is a low-level skeleton library for communication on GNU/Linux platforms. It supports almost all of the widely-used Linux-based boards. So, initially you need to install the library on the board.

Open up PuTTY and log in to your device. Once logged in, we'll add AlexT's unofficial opkg repository.

To do that, add the following lines to /etc/opkg/base-feeds.conf using the VI editor:

src/gz all http://repo.opkg.net/edison/repo/all
src/gz edison http://repo.opkg.net/edison/repo/edison
src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32

Next, update the package manager and install git by executing the following commands:

opkg update
opkg install git

We'll clone Edison-scripts from GitHub to simplify certain things:

git clone https://github.com/drejkim/edison-scripts.git ~/edison-scripts

Next we'll add ~/edison-scripts to the path:

echo 'export PATH=$PATH:~/edison-scripts' >> ~/.profile
source ~/.profile

We'll now run the following scripts to complete the process. Please note that the previous steps will not only configure the device for MRAA, but will also set up the environment for later projects in this book.

Firstly, run the following script. Just type:

resizeBoot.sh
Then go for
installPip.sh

The previous package is the Python package manager. This will be used to install essential Python packages to be used in a later part of this book. Finally, we'll install Mraa by executing the following command:

installMraa.sh

MRAA is a low-level skeleton library for communication on GNU/Linux platforms. Libmraa is a C/C++ library with bindings to Java, Python, and JavaScript to interface with the IO on Galileo, Edison, and other platforms. In simple words, it allows us to operate on the IO pins.

Once the preceding steps have completed, we are good to go with the code for Python. For that, open up any code editor, such as Notepad++, and type in the following code:

import mraa 
import time


led = mraa.Gpio(13)
led.dir(mraa.DIR_OUT)

while True:
led.write(1)
time.sleep(0.2)
led.write(0)
time.sleep(0.2)

Please save the preceding code as a .py extension such as blink.py, and now, we'll explain it line by line.

Initially, using the import statements, we import two libraries: MRAA and time. MRAA is required for interfacing with the GPIO pins:

led = mraa.Gpio(13)
led.dir(mraa.DIR_OUT)

Here we initialize the LED pin and set it to the output mode:

while True:
led.write(1)
time.sleep(0.2)
led.write(0)
time.sleep(0.2)

In the preceding block, we put our main logic in an infinite loop block. Now, we will transfer this to our device. To do that again, go to the PuTTY console and type ifconfig. Under the wlan0 section, note down your IP address:

IP address to be used

Now open up FileZilla and enter your credentials. Make sure your device and your PC are on the same network:

  • Host: The IP address you got according to the preceding screenshot: 192.168.0.101
  • Username: root because you will be logging in to the root directory
  • Password: Your Edison password
  • Port: 22

Once entered, you will get the folder structure of the device. We'll now transfer the Python code from our PC to the device. To do that, just locate your .py file in Windows Explorer and drag and drop the file in the FileZilla console's Edison's folder. For now, just paste the file under root. Once you do that and if it's a success, the file should be visible in your Edison device by accessing the PuTTY console and executing the ls command.

Another alternative is to locate your file on the left-hand side of FileZilla; once located, just right-click on the file and click Upload. The following is the typical screenshot of the FileZilla windows:

FileZilla application

Once transferred and successfully listed using the ls command, we are going to run the script. To run the script, in the PuTTY console, go to your root directory and type in the following command:

python blink.py

If the file is present, then you should get the LED blinking on your device. Congrats! You have successfully written a Python script on your Edison board.

Intel XDK for IoT (Node.js)

Another IDE we will be covering is the powerful cross-platform development tool by Intel: Intel XDK. This will be used to run our Node.js scripts. Ideally we run our Node.js scripts from the XDK, but there is always an option to do the same by just transferring the .js file to your device using an FTP client such as FileZilla and use node FileName.js to run your script. From the list of downloaded software provided at the beginning of this chapter, download and install the XDK and open it. You may be required to sign in to the Intel developer zone. Once done, open your XDK. Then, under IoT embedded applications, select a Blank IoT Node.js Template:

Screenshot for XDK

Once opened, replace all the existing code with the following code:

var m = require('mraa'); //require mraa 
console.log('MRAA Version: ' + m.getVersion()); //write the mraa version to the console

varmyLed = new m.Gpio(13); //LED hooked up to digital pin 13 (or built in pin on Galileo Gen1 & Gen2 or Edison)
myLed.dir(m.DIR_OUT); //set the gpio direction to output
varledState = true; //Boolean to hold the state of Led

functionperiodicActivity()
{
myLed.write(ledState?1:0);
ledState = !ledState;
setTimeout(periodicActivity,1000);
}
periodicActivity(); //call the periodicActivity function

If you have a close look at the code, then you may notice that the structure of the code remains more or less similar as that of the other two platforms. We initially import the MRAA library:

var m = require('mraa');
console.log('MRAA Version: ' + m.getVersion());

We also display the version of MRAA installed (you can skip this step). The next task is to initialize and configure the pin to be in output or input mode:

varmyLed = new m.Gpio(13); 
myLed.dir(m.DIR_OUT);
varledState = true;

We use ledState to get the present state of the LED. Next, we define the logic in a separate function for blinking:

functionperiodicActivity() 
{
myLed.write(ledState?1:0);
ledState = !ledState;
setTimeout(periodicActivity,1000);
}
periodicActivity();

Finally, we call the function. On close inspection of the code, it's evident that the we have used only one delay in milliseconds as we are checking the present state using the tertiary operator. In order to execute the code on the device, we need to connect our device first.

To connect your device to the XDK, go to the IoT Device section, and click on the dropdown. You may see your device in the dropdown. If you see it, then click on Connect:

XDK screenshot connection pane

If the device is not listed, then we need to add a manual connection. Click on Add Manual Connection, then add the credentials:

Screenshot for manual connection

In the address, put in the IP which was used in FileZilla. In the Username, insert root, and the password is the password that was set before. Click on Connect and your device should be connected. Click on Upload to upload the program and Run to run the program:

Screenshot for uploading and executing the code

After uploading, the LED that is attached to pin 13 should blink. Normally, when dealing with complex projects, we go for blank templates so that it's easy to customize and do the stuff we need.

For more examples and details on the XDK are available at: https://software.intel.com/en-us/getting-started-with-xdk-and-iot

Summary

In this chapter, we've covered the initial setup of the Intel Edison and configuring it to the network. We have also looked at how to transfer files to and from the Edison, and set up the developer environment for Arduino, Python, and Node.js. We did some sample programming, blinking an LED, using all three platforms. Through this, we've gained a fair knowledge of operating the Edison and developing simple to complex projects.

In Chapter 2, Weather Station (IoT), we'll build a mini-weather station and will be able to deploy a project on the Intel Edison.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Learn to build advanced level robots with Intel Edison and Arduino
  • Efficiently build and program home automation and IoT projects with Intel Edison
  • Master the skills of creating enticing projects with Intel Edison.

Description

Change the way you look at embedded electronics with Intel Edison. It is a small computing platform packed with a set of robust features to deliver hands-on performance, durability, and software support. This book is a perfect place to kickstart development and rapid prototyping using Intel Edison. It will start by introducing readers to the Intel Edison board and explaining how to get started with it. You will learn how to build a mini weather station, which will help you to acquire temperature and smoke level and push it to the IoT platform. Then you will see how to build a home automation device and control your appliances using an Android app. Furthermore, we will build a security system using a webcam to detect faces and perform voice recognition. Toward the end, the book will demonstrate how you can build two robots, which will be based on different line sensing sensors and can be controlled by a PC. The book will guide the readers through each and every step of execution of a project, using Intel Edison.

Who is this book for?

If you are a hobbyist, robot engineer, IoT enthusiast, programmer, or developer who wants to create autonomous projects with Intel Edison, then this book is for you. Prior programming knowledge would be beneficial.

What you will learn

  • Program your device using the Arduino processor language, Python, and Node.js
  • Interface different sensors with the Intel Edison
  • Build a home automation system using MQTT, Android, and WPF
  • Perform face detection using Intel Edison
  • Develop a high-speed line follower robot
  • Control a robot using a PC application and an custom controller

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 30, 2017
Length: 264 pages
Edition : 1st
Language : English
ISBN-13 : 9781787283626
Vendor :
Intel
Category :
Concepts :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : May 30, 2017
Length: 264 pages
Edition : 1st
Language : English
ISBN-13 : 9781787283626
Vendor :
Intel
Category :
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 151.97
BeagleBone: Creative Projects for Hobbyists
$79.99
ESP8266 Robotics Projects
$32.99
Intel Edison Projects
$38.99
Total $ 151.97 Stars icon
Banner background image

Table of Contents

6 Chapters
Setting up Intel Edison Chevron down icon Chevron up icon
Weather Station (IoT) Chevron down icon Chevron up icon
Intel Edison and IoT (Home Automation) Chevron down icon Chevron up icon
Intel Edison and Security System Chevron down icon Chevron up icon
Autonomous Robotics with Intel Edison Chevron down icon Chevron up icon
Manual Robotics with Intel Edison Chevron down icon Chevron up icon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.