Chapter 1. Introduction to Edison

gsie 01in01

The Intel Edison is an ultra-small computing platform that will change the way you look at embedded electronics. It’s a powerful and adaptable piece of hardware that is compatible with a wide range of cutting-edge software solutions. Basically, Intel Edison is an entry-level Windows 8 tablet the size of a postage stamp that is sold for around $50 USD.

Intel Edison really shines for its small form and integrated wireless communications. For this reason, Edison is intended for embedded and connected devices. However, you’ll see throughout this book that Edison’s incredible computing power and flexible inputs and outputs enable a wide range of applications, from smart homes to self-driving robots to personal assistants.

So far we’ve been talking about the hardware inside the Intel Edison, but you’ll be working with the integrated Intel Edison compute module. This module is shown in Figure 1-1 and can be accessed via a 70-pin connector on the bottom of the board (shown on the right side of Figure 1-1). While this connector is small and versatile, allowing developers to build custom boards that easily mate with the module, it is not meant for direct access. For this reason, a variety of breakout boards exist to help you get started. These boards break out the functionality of your Edison to a larger module that’s easier to access.

gsie 0101
Figure 1-1. The front and back of the Intel Edison compute module

Tour of Breakout Boards

If you’re reading this book, there’s a good chance that you’ve already purchased your Intel Edison compute module and an accompanying breakout board. While the compute module itself is standard, each breakout board is unique and will change the way you prototype and interface with Edison. For ease of use in this book, I’ll be using the Arduino Breakout Board. This board is an Arduino-compatible breakout for Edison. I’ll discuss what this means later in this chapter and a lot more in Chapter 3.

If you’ve not yet purchased this kit, then head over to one of the following retailers where you can buy your board. The cost is approximately $100 USD:

Maker Shed

http://www.makershed.com/products/intel-edison-kit-for-arduino

SparkFun

https://www.sparkfun.com/products/13097

Mouser Electronics

http://www.mouser.com/new/Intel/intel-edison/

Adafruit

http://www.adafruit.com/product/2180

Seeed

http://www.seeedstudio.com/depot/Intel-Edison-for-Arduino-p-2149.html

Amazon

http://amzn.com/B00ND1KH42

Note

You might notice that the product pages all include an Intel Edison compute module with the Arduino breakout. Unfortunately, it is not possible to buy the breakout separately; the Arduino breakout always comes paired with an Edison. If you’ve already purchased a compute module or other breakout board, save it to later migrate your project to a smaller form factor. The Arduino board is the largest of the breakouts and is great for first-round prototypes.

The only other items necessary for getting started are two microUSB cables. Edison requires high-quality microUSB cables for powering the board; substandard cables (like the ones you often get for charging cell phones and other electronics) just won’t cut it, especially if you’re supplying power directly to the Edison via USB. MicroUSB cables can be found easily on Amazon or many other sites if you don’t have them already. Spend a few extra dollars for the good ones.

At the beginning of subsequent chapters, I’ll highlight any other hardware that’s necessary to follow along. The full parts list for the entire book can be found in Appendix A.

The Arduino Breakout Board

The Arduino breakout with important labeled components is shown in Figure 1-2.

gsie 0102
Figure 1-2. Intel Edison Arduino Breakout Board with labeled components

These important components are:

  1. Female 70-pin connector. This connector mates with the male 70-pin connector on the back of the Edison compute module.

  2. Buttons. These integrated buttons allow you to mechanically reset or power cycle your Intel Edison or the Arduino breakout.

  3. MicroSD slot. While Intel Edison does come with 4 GB of integrated storage, the SD card slot gives the flexibility of adding additional storage to the system.

  4. Barrel jack for power. This provides one option for powering your Edison. The barrel jack is the standard interface for a wall adapter power supply, which can be purchased for a few dollars on Amazon or SparkFun. Any supply between 7V and 15V with 500 mA or more will do. Alternatively, a battery with a barrel jack connector will also work, so long as it’s in the same voltage range and can supply at least 500 mA continuously.

  5. External USB port. Intel Edison has one full-size USB 2.0 port, selectable via the mechanical microswitch (labeled 6 in Figure 1-2). This port can be used to connect to peripheral USB devices. If you wish to connect to multiple USB devices simultaneously, an externally powered USB hub is necessary.

  6. Power mode microswitch. This switch allows you to toggle between using the full-size external USB port and the adjacent microUSB port (labeled 7 in Figure 1-2). The active port is the one that the switch is clicked toward. Note that you will need to supply external power if the USB port is selected, because the microUSB you’d otherwise use for power will be deactivated.

  7. On-The-Go (OTG) microUSB port. This microUSB port supplies power and Ethernet capabilities, transfers Arduino sketches, and allows the host computer to access Edison as a mass-storage device.

  8. Serial console USB port. Connecting this port to your host computer allows direct access to the Intel Edison operating system via serial communication. This port, however, does not supply power to the device.

  9. Power LED indicator. When the device is powered on properly, this LED should remain in its lit state.

The Arduino breakout also has input and output, or I/O, pins that match the Arduino Uno in both physical layout and functionality. Input pins are used for signals that transmit information into your Intel Edison, such as the push of a button or measurements from a thermometer. Outputs are signals emitted by your Intel Edison, often to control attached devices. For instance, Edison might output voltage signals to make lights flicker or to display images on a screen. These I/O pins are labeled in Figure 1-3. Briefly, they are:

  1. Digital input/output and pulse-width modulation

  2. Analog input

  3. Power

  4. ICSP pins (for the Serial Peripheral Interface)

gsie 0103
Figure 1-3. Intel Edison Arduino Breakout with pins labeled

Don’t be worried if you’re not familiar with these terms. You will be soon. In Chapter 3 and Chapter 4, you’ll learn how to use and control these specific I/O pins. And, by using electronics that have been prebuilt for this configuration, I’ll also illustrate why this layout is so extremely useful.

Other Breakout Options

Though you’ll be using the Arduino Breakout Board in this book, it is worth taking a moment to explain the difference between this and the other breakout options: the Intel Mini Breakout Board and the SparkFun Base Block, shown in Figure 1-4 and Figure 1-5, respectively.

gsie 0104
Figure 1-4. Intel Mini Breakout Board and Intel Edison compute module
gsie 0105
Figure 1-5. SparkFun Base Block from the top and the bottom

Both breakout boards provide access to the Edison compute module by attaching Edison to a female 70-pin connector. Both breakouts have two microUSB connectors: one for console access and one that serves as a USB On-the-Go (OTG) port. On the Intel mini breakout, the OTG port can also be used to supply power to the system. On the SparkFun Base Block, either microUSB port can be used to supply power. Both boards have LED indicators lights for Edison power and charging.

There are two additional ways to supply power to the Intel mini breakout. The pair of header pins next to the microUSBs is for supplying 7-15V power. To more easily mate with a wall plug, a barrel jack can be soldered to the pads on the underside of this portion and used in lieu of the header pins. You can also use a 7-15V battery pack with a barrel jack connector if you want a battery-powered solution. Alternatively, the pair of pins on the opposite end of the board, labeled J22, can be connected to a 3.7V lithium polymer (LiPo) battery for power. A LiPo battery will supply enough power for most of the board functionality but will not provide enough to power peripherals attached to the microUSB OTG port. The functional components of both boards are labeled in Figure 1-6 and Figure 1-7.

gsie 0106
Figure 1-6. Parts of the Intel Mini Breakout Board: (a) 70-pin connector, (b) OTG port, (c) serial console port, (d) power LEDs, (e) 7-15V input power headers, and (f) 3.7V LiPo battery headers
gsie 0107
Figure 1-7. Parts of the SparkFun Base Block: (a) 70-pin expansion header, (b) OTG port, (c) serial console port, (d) power LED, (e) data-transfer LEDs, and (f) power-reset button

The main difference between the two breakouts is the way they use Edison’s microcontroller. You’ll notice that the Intel mini breakout has four rows of solderable pin holes, which are routed from the 70-pin connector. This allows you to access the programmable inputs and outputs on Edison directly. The SparkFun Base Block, on the other hand, provides no access to the I/Os. So, how do you attach sensors and other devices to the Edison?

If you look at the top of the Base Block (Figure 1-5), you’ll notice that the 70-pin female connector runs through to a 70-pin male connector on the other side. SparkFun has made a series of modular boards for Edison, breaking out a few capabilities on each and designing them to stack using the 70-pin connectors all the way through. If you want access to a specific function, then you buy an additional breakout for that function and stack it with the base block. For example, if you want to read the values of a few digital inputs, you can buy the GPIO breakout. If you want to power your Edison using a LiPo battery, you can buy the battery block for stacking. And, of course, it is possible to stack more than two blocks together for increased functionality. The full list of SparkFun blocks can be found at SparkFun’s website.

Voltage Considerations

Digital signals have two states, low (0) or high (1), and the voltage of the signal refers to the voltage when that signal is high. Edison is a native 1.8V device, meaning it outputs a 1.8V high signal and expects to receive a 1.8V high signal back. A big reason why the Arduino breakout is so large is that it is stocked with level shifters, which convert between the 1.8V and the more common 3.3V and 5.0V (these voltages are typical of most sensors and peripheral devices in the maker space today).

Unlike the Arduino breakout, the mini breakout contains no level shifters and so won’t be able to pass or read signals from higher voltage devices without you doing the level shifting off the board. Furthermore, if you happen to forget and send a higher voltage signal into the mini breakout, you can fry your Edison, since there’s no on-board protection from higher voltages. This is the main reason why I use the Arduino breakout for the examples in this book. In Chapter 3 and Chapter 4, when you begin building systems with sensors and displays, you’ll notice how much easier life is without worrying about shifting all the signals in and out. Be sure to check the voltage ratings for the different SparkFun breakout boards as you attach them, since each breakout board may have been designed for different voltage values.

Note

Throughout the remainder of the book, wherever appropriate, I’ll highlight when code will work as is or note the modifications necessary to port an example over to one of the smaller boards.

Setup and Configuration

Now that you’ve purchased your Edison and are comfortable staring at the Arduino breakout, let’s power this guy up and get started! While Intel Edison is a full computer running a full operating system, it’s meant for use in embedded products and does not have a graphical user interface. Everything you do for setup and programming will be done at the command line, making the startup and configuration process a bit more complicated than other maker products. Fear not. Once you get the hang of the command line, programming on Edison becomes a breeze. I take you on a whirlwind overview of command-line programming in Chapter 2, but for now, follow along to connect to and configure your Edison.

First, unpack everything from the box. The setup should be fairly intuitive; screw the four plastic posts into the corner, and click the Edison compute module into the 70-pin connector on the board by pressing down on the bottom of the module. It should snap in easily with a satisfying sound and feel. Secure the compute module using the two small screws provided with the kit. When you’re finished, the assembled board should look like the one in Figure 1-8.

gsie 0108
Figure 1-8. Intel Edison assembled onto the Arduino Breakout Board
Warning

The 70-pin connector is definitely a bit fragile, so be careful if and when you pop the compute module back off the Arduino breakout board. Try to avoid torquing it too hard, as the slotted pin connectors can bend.

Next, connect the Arduino breakout to your computer. First connect the Edison’s power/external storage microUSB port (J16, closest to the power mode microswitch) to your computer. Once connected, the power LED indicator on the board will turn on, and Edison’s mountable storage system should appear on your desktop as an external drive. If this does not happen, disconnect power, then make sure the switch near the USB and port is pushed toward the microUSB and that Edison is locked fully into the 70-pin connector. Try powering it up again.

Next, connect the other microUSB (J3) port to your computer. This will allow you to log in to the Edison operating system directly. A pictorial step-by-step walkthrough of this process can also be found in the Intel documentation.

Install

Intel Edison’s software requirements depend on your host computer operating system. Since the Edison release, Intel developers have worked very hard to make the installation process for Edison as seamless as possible. In the past few months, they’ve released a standalone installer for Windows and Mac that can be downloaded from their website. For Linux host computers, the process is a little more involved, but steps are laid out here and on the Intel website.

The processes described in this section will also flash Edison with its own most up-to-date operating system. Edison runs Yocto Linux by default, a configurable and lightweight embedded Linux OS. Because Intel developers are working hard to fix bugs and enable new Edison features all the time, the Yocto OS that comes on Edison straight out of the box is not the most up-to-date version.

Custom Yocto Builds

It is possible to build your own custom Yocto image and flash it onto your Edison. This is beyond the scope of this book, but there are several tutorials on this topic available online and a guide specifically for Intel Edison.

Mac and Windows

Under “Step 2: Choose your Operating System,” select your OS from the dropdown menu. and click the button that appears to start the download. Alternatively, you can download the stand-alone installers directly from the software downloads page. The reason I include both is that Intel has a nasty little habit of moving its links and files around, and you’ll sometimes find broken links to downloads. The software downloads page, however, tends to be very consistent and up to date.

The standalone installer will download and install the most recent Arduino IDE, the necessary drivers (if you’re on Windows), and all other dependencies necessary for connecting to your Edison. Additionally, it will flash your Edison with the most up-to-date build.

Installation Options

When the installer asks you to configure the options, you’re free to choose whether you want to install the last two options—Intel XDK IoT Edition and Eclipse. You won’t be using these in this book, but they provide another fun way of interacting with and building programs for Intel Edison.

The first time the standalone installer is run, it will download quite a heavy load, so make sure you have a strong Internet connection before running it. If you do, the whole installation and flashing process should only take 10-15 minutes. Make sure to watch the installer as it runs, because it prompts you to take certain actions, such as plugging in the Arduino board, at different times during the install process. It also helps to be watching in case the installer throws an error, which has only happened to me during the board-flashing process.

If your flash fails, you’ll either have to flash the board again with the standalone installer or perform a manual flash using the Phone Flash Tool. When run subsequent times, the installer will automatically detect the Edison-specific software on your system and skip the software download and install steps. However, in my experience with Edison, the Phone Flash Tool is much more reliable for flashing boards than the standalone installer, so it’s definitely worth trying if you run into trouble. Instructions for performing this process can be found below the installer download button on the main page, as shown in Figure 1-9.

gsie 0109
Figure 1-9. Link location for performing a manual flash using Intel’s Phone Flash Tool

The Phone Flash Tool software, most recent Yocto complete image, and all the necessary drivers for install can also be found on the software page.

Linux

Intel recommends using the Phone Flash Tool for flashing your Edison from a Linux host computer. The complete details for this process can be found in Steps 1-3 on the Intel setup tutorial.

I’ve found, however, that it’s easier to flash the board from a Linux computer using the old manual process. Basically, you’ll use the Edison mounted storage device to load the newest build and then flash it directly on the board. Connect Edison to your host computer through both USB cables and wait until your host computer recognizes Edison as a mass-storage device. Then, open a new terminal on your host computer and remove everything that’s on the storage device by issuing the following three commands at the command line. If you’ve never flashed the board before or used it to transfer files, you can skip this step:

cd /media/username/Edison
rm –rf *
rm –rf .*

Next, download the latest Yocto Complete Image from the Intel downloads page. Unzip the files, and drag and drop them onto the Edison mounted storage device. After they finish copying, you’re ready to flash.

To flash, you’ll again use your terminal window. To connect to Edison, you’ll use a program called screen. If you do not yet have screen installed on your computer, install it using your distribution’s package manager. For example, under Debian and Ubuntu, you’d use the command:

sudo apt-get install screen

Now connect to Edison using screen by typing the following command:

sudo screen /dev/ttyUSB0 115200

Press Enter twice, and the login screen will be displayed. Log in using “root” as the username. At the Edison command prompt that displays, issue the command reboot ota and press Enter. Your Edison will reboot and begin flashing the newly loaded image. The flash should take a few minutes to complete. When it does, you will be prompted for your login again, which is still “root”. Go ahead and log back in.

Connecting

The procedure for connecting to Edison depends on your computer operating system. Please follow the appropriate set of instructions that follows.

Windows

Open the Windows Device Manager, and expand the “Ports (COM and LPT)” dropdown as shown in Figure 1-10. Look for the COM port associated with the “USB Serial Port.” In Figure 1-10, this is COM6.

gsie 0110
Figure 1-10. Windows Device Manager for finding Edison serial communication port

To connect to Edison interactively (to send commands at the boot prompt, for example) you’ll need a terminal program. A good Windows option is PuTTY. You can download the PuTTY installer at the PuTTY download page. Look for the file named putty-0.64-installer.exe, download it, and double-click it to install after it’s finished downloading.

To access Edison, configure Putty as shown in Figure 1-11. First, select Serial for the Connection Type, and then replace COM6 with your USB Serial Port number in the Serial line text box. Set the Speed to 115200. Before opening the connection, you can save these parameters for future use by entering a name into the Saved Sessions text box and clicking the Save button as indicated in Figure 1-11. The name of your new saved session, which is “Edison” in Figure 1-11, should appear under “Default Settings.” Click the Open button in the bottom right to initiate the connection to Edison.

To connect to Edison in the future, simply open Putty and double-click the name of your saved session.

gsie 0111
Figure 1-11. Putty configuration for connecting to Intel Edison

A blank terminal screen will appear after the connection is made. Press Enter twice, and you will be prompted for a login.

Mac

Open Terminal. If you’ve never used this program before, you can find it by searching for “terminal” in Mac Spotlight search. To connect to Edison, you’ll use a program called screen. Type the following into the terminal and then press tab:

screen /dev/tty.usbserial-

You’ll notice that the remainder of the Edison serial address autocompletes when you press tab. Complete the command by adding the configuration 115200 –L so that the entire line looks like this:

screen /dev/tty.usbserial-XXXXXXXX115200 -L

Press Enter twice, and you should see the Edison login prompt.

Linux

If you flashed your Edison using the old-fashioned method that I recommended, then you’re already screen’ed into the device. If you used the Phone Flash Tool, then you still have to connect for a first time.

To connect, open a terminal window and install screen using your distribution’s package manager. For example, under Debian and Ubuntu, you’d use the command:

sudo apt-get install screen

Now connect to Edison using screen with the following command:

sudo screen /dev/ttyUSB0 115200

Press Enter twice, and the login screen displays.

Navigating in Screen

If you’ve never used screen before, there are two important commands that you need to know: pressing Ctrl+A and then the K key will kill your current screen, and the terminal command screen –r will reattach you to a screen that is already in session.

Logging In

After connecting to Edison, you will be prompted for your login. The default login on Intel Edison is “root” with no associated password. Go ahead and enter the username now, and then press Enter. Your reward will be the Linux command line:

root@edison:~#

Congratulations! You’re successfully connected to your Edison. If you’re unsure of what to do at the Linux command line, don’t worry. Chapter 2 provides a quick overview of commands to help you navigate and program your device.

Configuring Edison and Getting Online

At the Edison command prompt, type configure_edison --setup, and press Enter. Edison will walk you through the process of setting a password for the root user, naming your device, and connecting to the Internet. After connecting to the Internet, you will see the following response:

Done. Please connect your laptop or PC to the same network as this device and go to http://XXX.XXX.X.XX or http://devicename.local in your browser.

Bad Builds

If you tried to issue the command configure_edison --setup and received an error message about --setup not being an option, then your build unfortunately failed. Take the actions recommended in the Install section for your host computer.

XXX.XXX.X.XX is your device IP address, and devicename is whatever you’ve just named your device. After configuration, Edison starts up its own node.js webserver, which is accessible from the browser on your host computer, so long as you’re on the same network. Open a browser window and check it out. You’ll see a webpage with the device name and IP address displayed against a blue background.

Firewalls and NATs

The automatic node.js server won’t necessarily work if the Edison is connecting behind a firewall or network address translation service (NAT).

It is now possible to connect to Edison wirelessly instead of using screen, eliminating the need for a USB tether. Again, you must be on the same network in order for this to work.

To wirelessly connect from the terminal, use either of the following two commands:

ssh root@IP Address
ssh [email protected]

Then press Enter and provide your password when prompted.

If you’re using Putty on Windows, Figure 1-12 shows the setup for a wireless connection.

To terminate the wireless connection on any system, either close the window or type exit at the Edison command prompt.

gsie 0112
Figure 1-12. Configuration for connecting wirelessly to Intel Edison using Putty; be sure to replace edison.local with your devicename.local

If you issue the command configure_edison or configure_edison --help at the Edison command prompt and hit Enter, you’ll see the other configure options that are preinstalled in the current build. You can run any of these with the command configure_edison option. Some of the more important possibilities for option are:

--wifi

Walks you through the process of configuring additional WiFi networks for Intel Edison. All networks added to Edison this way will be remembered and automatically joined at start-up, with network preference going in the order in which they were added.

--version

Returns the build version of the current Yocto system.

--latest-version

Pings Intel’s site for the newest officially released Yocto build for Edison.

--upgrade

Downloads and installs the newest officially released Yocto build for Edison. Using this option is like performing an automatic flash of the most recent build. If you’re already on the most recent build, this returns a status message and performs no action.

--flash <version>

You can use this option to flash any previous or current version of the officially released Yocto builds. Replace <version> with any version number of interest.

Note that flashing Intel Edison will remove previous configuration settings, so you’ll have to run configure_edison --setup to rename the device, set passwords, and configure WiFi each and every time you flash.

Finally, shutting down Intel Edison is easy: simply issue the following command and then press Enter:

shutdown now

Edison will display a series of shutdown messages ending with:

[  OK  ] Reached target Shutdown.

Then Edison will power itself off. The power LED on the Arduino board will turn off when the process is complete.

Troubleshooting

If you experience any trouble powering up the board, ensure that Edison is locked tightly into the 70-pin connector. If Edison still does not power on, try switching microUSB cables. A lot of cheaper cables can be current-limiting and might not be providing enough current to power Edison and the board. Finally, try switching to an external power supply using the barrel jack.

If you experience issues establishing tethered communication with the board, check that both microUSB cables are inserted fully. Make sure that you have selected the correct COM port or USB serial device address for your host computer and that the communication rate is set to 115200. You will still be able to connect with an incorrect rate, but you will receive only garbage printouts from Edison on your local machine.

If you experience issues with the wireless connection, make sure that Edison is still online, that your host computer is on the same network, and that you’ve correctly typed the IP address or device name when trying to connect.

If all else fails, the Intel Edison communities site has heaps of questions and answers helping people to get set up with their boards.

Going Further

Intel Edison Downloads and Documentation

This is a great place to find more information about the hardware and software that make up the Intel Edison ecosystem.

Intel Edison Learning Center

A good, general starting point for learning to work with Intel Edison.

The Yocto Project

The definitive source for information about Yocto Linux and the Yocto Linux community.

The GNU Screen User’s Manual

An overview of useful and not-so-useful commands in the screen program. Aside from connecting to Intel Edison, screen is an extremely useful program for remote connection to other computers and devices.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.171.212