Programming the Intel Edison: Getting Started with Processing and Python
1/5
()
About this ebook
- Explore the capabilities and features of the Edison
- Connect Sparkfun, Break-out, and Arduino boards
- Program your Edison through the Arduino IDE
- Set up USB, GPIO, WiFi, and Bluetooth connections
Read more from Donald Norris
Programming with STM32: Getting Started with the Nucleo Board and C/C++ Rating: 3 out of 5 stars3/5Raspberry Pi Electronics Projects for the Evil Genius Rating: 3 out of 5 stars3/5Python for Microcontrollers: Getting Started with MicroPython Rating: 0 out of 5 stars0 ratingsRaspberry Pi Projects for the Evil Genius Rating: 0 out of 5 stars0 ratingsHome Automation with Raspberry Pi: Projects Using Google Home, Amazon Echo, and Other Intelligent Personal Assistants Rating: 0 out of 5 stars0 ratingsThe Internet of Things: Do-It-Yourself at Home Projects for Arduino, Raspberry Pi and BeagleBone Black Rating: 0 out of 5 stars0 ratingsBuild Your Own Quadcopter: Power Up Your Designs with the Parallax Elev-8 Rating: 0 out of 5 stars0 ratings
Related to Programming the Intel Edison
Related ebooks
Microsoft .NET Gadgeteer: Electronics Projects for Hobbyists and Inventors Rating: 0 out of 5 stars0 ratingsVisual Studio Condensed: For Visual Studio 2013 Express, Professional, Premium and Ultimate Editions Rating: 0 out of 5 stars0 ratingsProgramming and Customizing the Multicore Propeller Microcontroller: The Official Guide Rating: 4 out of 5 stars4/5Build Your Own Quadcopter: Power Up Your Designs with the Parallax Elev-8 Rating: 0 out of 5 stars0 ratings30 BeagleBone Black Projects for the Evil Genius Rating: 0 out of 5 stars0 ratingsAdvanced Penetration Testing with Kali Linux: Unlocking industry-oriented VAPT tactics (English Edition) Rating: 0 out of 5 stars0 ratingsMATLAB Optimization Techniques Rating: 0 out of 5 stars0 ratingsSmart Home Automation with Linux and Raspberry Pi Rating: 3 out of 5 stars3/5Beginning Android C++ Game Development Rating: 0 out of 5 stars0 ratings.NET DevOps for Azure: A Developer's Guide to DevOps Architecture the Right Way Rating: 0 out of 5 stars0 ratingsPHP Programming Solutions Rating: 0 out of 5 stars0 ratingsEmbedded Software Design and Programming of Multiprocessor System-on-Chip: Simulink and System C Case Studies Rating: 0 out of 5 stars0 ratingsPro TypeScript: Application-Scale JavaScript Development Rating: 4 out of 5 stars4/5Local Computer Network Technologies Rating: 0 out of 5 stars0 ratingsWireless Networking Rating: 2 out of 5 stars2/5.NET IL Assembler Rating: 0 out of 5 stars0 ratingsBits on Chips Rating: 0 out of 5 stars0 ratingsComputer Science on your Mobile Rating: 0 out of 5 stars0 ratingsIPv6 Network Programming Rating: 0 out of 5 stars0 ratingsWi-Fi Home Networking Rating: 3 out of 5 stars3/5Beginning Backbone.js Rating: 3 out of 5 stars3/5Mastering the Raspberry Pi Rating: 3 out of 5 stars3/5Building JavaScript Games: for Phones, Tablets, and Desktop Rating: 0 out of 5 stars0 ratingsThe Dev-c++ Reference Manual Rating: 5 out of 5 stars5/5Apple I Replica Creation: Back to the Garage Rating: 4 out of 5 stars4/5DOS Today: Running Vintage MS-DOS Games and Apps on a Modern Computer Rating: 0 out of 5 stars0 ratingsC# Deconstructed: Discover how C# works on the .NET Framework Rating: 0 out of 5 stars0 ratingsCWDP Certified Wireless Design Professional Official Study Guide: Exam PW0-250 Rating: 5 out of 5 stars5/5Learn Java for Web Development: Modern Java Web Development Rating: 0 out of 5 stars0 ratings
Electrical Engineering & Electronics For You
Beginner's Guide to Reading Schematics, Third Edition Rating: 0 out of 5 stars0 ratingsHow to Diagnose and Fix Everything Electronic, Second Edition Rating: 4 out of 5 stars4/5Practical Electrical Wiring: Residential, Farm, Commercial, and Industrial Rating: 4 out of 5 stars4/5Beginner's Guide to Reading Schematics, Fourth Edition Rating: 4 out of 5 stars4/5Electronics Explained: Fundamentals for Engineers, Technicians, and Makers Rating: 5 out of 5 stars5/515 Dangerously Mad Projects for the Evil Genius Rating: 4 out of 5 stars4/5DIY Lithium Battery Rating: 3 out of 5 stars3/52022 Adobe® Premiere Pro Guide For Filmmakers and YouTubers Rating: 5 out of 5 stars5/5Electricity for Beginners Rating: 5 out of 5 stars5/5Electric Circuits Essentials Rating: 5 out of 5 stars5/5Electrical Engineering 101: Everything You Should Have Learned in School...but Probably Didn't Rating: 5 out of 5 stars5/5Electrician's Pocket Manual Rating: 0 out of 5 stars0 ratingsElectrical Engineering: Know It All Rating: 4 out of 5 stars4/5The Homeowner's DIY Guide to Electrical Wiring Rating: 5 out of 5 stars5/5Upcycled Technology: Clever Projects You Can Do With Your Discarded Tech (Tech gift) Rating: 5 out of 5 stars5/5Off-Grid Projects: Step-by-Step Guide to Building Your Own Off-Grid System Rating: 0 out of 5 stars0 ratingsStarting Electronics Rating: 4 out of 5 stars4/5Schaum's Outline of Basic Circuit Analysis, Second Edition Rating: 5 out of 5 stars5/5DIY Drones for the Evil Genius: Design, Build, and Customize Your Own Drones Rating: 4 out of 5 stars4/5Electronic Circuits for the Evil Genius 2/E Rating: 0 out of 5 stars0 ratingsTwo-Stroke Engine Repair and Maintenance Rating: 0 out of 5 stars0 ratingsSchaum's Outline of Basic Electricity, Second Edition Rating: 5 out of 5 stars5/5The Fast Track to Your Technician Class Ham Radio License: For Exams July 1, 2022 - June 30, 2026 Rating: 5 out of 5 stars5/5THE Amateur Radio Dictionary: The Most Complete Glossary of Ham Radio Terms Ever Compiled Rating: 4 out of 5 stars4/5Matlab: A Practical Introduction to Programming and Problem Solving Rating: 4 out of 5 stars4/5Basic Electronics: Book 2 Rating: 5 out of 5 stars5/5Programming Arduino: Getting Started with Sketches Rating: 4 out of 5 stars4/5Basic Electricity Rating: 4 out of 5 stars4/5How Do Electric Motors Work? Physics Books for Kids | Children's Physics Books Rating: 0 out of 5 stars0 ratings
Reviews for Programming the Intel Edison
1 rating0 reviews
Book preview
Programming the Intel Edison - Donald Norris
About the Author
Donald Norris has a degree in electrical engineering and an MBA specializing in production management. He is currently teaching undergrad and grad courses in the IT subject area at Southern New Hampshire University. He has also created and taught several robotics courses there. He has over 30 years of teaching experience as an adjunct professor at a variety of colleges and universities.
Mr. Norris retired from civilian government service with the U.S. Navy, where he specialized in acoustics related to nuclear submarines and associated advanced digital signal processing. Since then, he has spent more than 20 years as a professional software developer using C, C#, C + +, Python, Node.js, and Java, as well as 5 years as a certified IT security consultant.
Mr. Norris started a consultancy, Norris Embedded Software Solutions (dba NESS LLC), which specializes in developing application solutions using microprocessors and microcontrollers. He likes to think of himself as a perpetual hobbyist and geek and is always trying out new approaches and out-of-the-box experiments. He is a licensed private pilot, photography buff, amateur radio operator, avid runner, and, last but very important, a grandfather to a brand new baby girl—here’s to you, Evangeline.
Copyright © 2016 by McGraw-Hill Education. All rights reserved. Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a data base or retrieval system, without the prior written permission of the publisher.
ISBN: 978-1-25-958789-4
MHID: 1-25-958789-4
The material in this eBook also appears in the print version of this title: ISBN: 978-1-25958833-4, MHID: 1-25-958833-5.
eBook conversion by codeMantra
Version 1.0
All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trademarked name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark. Where such designations appear in this book, they have been printed with initial caps.
McGraw-Hill Education eBooks are available at special quantity discounts to use as premiums and sales promotions or for use in corporate training programs. To contact a representative, please visit the Contact Us page at www.mhprofessional.com.
Information has been obtained by McGraw-Hill Education from sources believed to be reliable. However, because of the possibility of human or mechanical error by our sources, McGraw-Hill Education, or others, McGraw-Hill Education does not guarantee the accuracy, adequacy, or completeness of any information and is not responsible for any errors or omissions or the results obtained from the use of such information.
TERMS OF USE
This is a copyrighted work and McGraw-Hill Education and its licensors reserve all rights in and to the work. Use of this work is subject to these terms. Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hill Education’s prior consent. You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohibited. Your right to use the work may be terminated if you fail to comply with these terms.
THE WORK IS PROVIDED AS IS.
McGRAW-HILL EDUCATION AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. McGraw-Hill Education and its licensors do not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error free. Neither McGraw-Hill Education nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting therefrom. McGraw-Hill Education has no responsibility for the content of any information accessed through the work. Under no circumstances shall McGraw-Hill Education and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the possibility of such damages. This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or otherwise.
This book is dedicated to Linda Norris, who is a kind, loving, and generous person, and mother to Shauna, Heath, and Derek. She is also Mimi to grandchildren Hudson and Evangeline.
CONTENTS AT A GLANCE
1 Introduction
2 Getting Started with the Intel Edison Arduino Board
3 Working with Processing and the Intel Arduino IDE
4 Edison-Controlled Robotic Car
5 Connecting to Edison Linux with the Command-Line Prompt
6 Debian Linux and Python Basics
7 Python Classes, Methods, and the libmraa Library
8 Hardware Interfaces
9 Web Server and Database
10 Wearables
Index
CONTENTS
Preface
1 Introduction
The Edison Computing Module
Intel Arduino Development Board
Intel Edison Breakout Board
Sparkfun Block for Intel Edison–Console
Summary
2 Getting Started with the Intel Edison Arduino Board
Intel Edison Arduino IDE
Powering the Arduino Development Board
USB Communications
Blink Sketch
Modifying the Blink Sketch
Summary
3 Working with Processing and the Intel Arduino IDE
The Processing Language and the Intel Edison Arduino IDE
Processing Language Basics
Input and Output Statements
Data Variables
Average Voltage Measurement Sketch
Switch Demo Sketch
Mini-Servo Sketch Example
Ping Sensor Sketch
Summary
4 Edison-Controlled Robotic Car
BOE-BOT Car
How an Analog Servo Works
Continuous Rotation (CR) Servos
Servo1 Sketch
Autonomous Operation
Operating the Robot Car
Summary
5 Connecting to Edison Linux with the Command-Line Prompt
Intel Edison Breakout Board
Setting Up Your First USB Communications Session
FTDI Drivers
Windows Drivers
Connecting to the Client Computer
Updating/Upgrading the Edison Firmware
configure_edison Application
Date and Time
Web Server
Python
C/C++
Node.js
Summary
6 Debian Linux and Python Basics
How to Install the Debian Linux Distribution
Step-by-Step Edison Debian Load Procedure
WiFi Setup
SSH
Basic Python
Python Help
Data Types, Variables, and Constants
User-Defined Functions
Interpolated Sensor Measurements
Summary
7 Python Classes, Methods, and the libmraa Library
Basic OO Concepts
The Class
Installing the libmraa Library
mraa Version Check
Blink Program
Servo Control Program
CR Servo Control Program
Analog Motor Control Program
EMC Class Implementations
Summary
8 Hardware Interfaces
Serial Protocols
UART Serial Protocol
I2C Serial Protocol
SPI Serial Protocol
I2S Serial Protocol
Parallel Protocols
GPIO
SD Card Interface
Clock Outputs
Summary
9 Web Server and Database
LAMP
Apache Web Server and the PHP Scripting Language
MySQL Database Installation
Adding a New User to a MySQL Database
Python Database Connection
Home Temperature Measurement System
TMP36 Temperature Sensor
Initial Test
Multiple Sensor System
Multiple Sensor Software
Temperature Database
Inserting Data into a MySQL Database Using a Program
Database Access Using a Web Browser
Narrowing the Database Reports
Summary
10 Wearables
Sparkfun Console Module
Stackable Architecture
Chapter Project
Battery Module
9DOF Module
The Project Software
sudo
The Project Stack
Initial Project Stack Test
Battery Operations
Paho and Eclipse.org
MQTT
Quality of Service (QoS)
Wills
Reconnecting
Edison MQTT Publisher Client
Auto Start
MQTT Brokers
MQTT Subscriber Clients
Mac MQTT Subscriber Client
Android Smartphone Subscriber Client
Summary
Index
PREFACE
This book will serve both as an introduction to the Intel Edison computing module and also as a reliable and concise Getting Started Guide for interested readers. This computing module was introduced at the Intel Developers Forum 2014 held in San Francisco on September 10, 2014. Intel described the Edison’s value as follows:
The Intel® Edison development platform is designed to lower the barriers to entry for a range of inventors, entrepreneurs, and consumer product designers to rapidly prototype and produce IoT and wearable computing products.
The Edison’s form factor, which will be described in detail later, is most definitely slated for applications demanding extremely compact hardware and, simultaneously, consuming miniscule power.
The Edison computing module is the latest in a progression of embedded technology devices that Intel has created over a long time frame. The Galileo Gen 2 development board was the most recent technology platform that just preceded the Edison. In many ways, the Galileo and Edison are quite similar except for one key aspect: The Galileo board may be used as is,
meaning that all it needs is a power supply and interconnectivity to be accessed and operated. The Edison, on the other hand, requires some type of support board to provide both power and interconnectivity. The Edison’s need for a support board is the reason that I believe Intel labeled it as a computing module instead of a development board.
The Edison contains some remarkable hardware despite its very small size. It was purposefully designed to be used as a very capable embedded control module operating within an encompassing system. Intel’s design philosophy was to make the module extremely compact with ultra-low power consumption. These attributes make it ideal to function as a wearable
computer, which is described in much greater detail later in the book.
The foregoing was just a brief glimpse into what I will discuss in much greater detail in this book. Let’s now delve into the Edison and see what makes it tick.
1
Introduction
In this chapter, I will show you what makes up the Intel Edison computing module and introduce two supporting development boards that will be used in programming the Edison as well as allowing it to connect with other system components.
The Edison Computing Module
Figure 1-1 is a top view of the Edison module shown next to a U.S. nickel coin for a size comparison. It is quite small, barely larger than a typical U.S. postage stamp, with overall approximate dimensions of 34.9 × 25.4 × 3.2 mm. Under the metal cover is an Intel dual-core Silvermont Atom processor running at a 500-MHz clock speed. There is also a 100-MHz clocked Quark coprocessor included, which is designed to assist the Atom processor with input/output (I/O) operations. Unfortunately, as of the time of this writing, Intel has not released any software that will support the Quark coprocessor; therefore, it will not be discussed any further in this book. I would suggest periodically checking the Intel Edison website, http://www.intel.com/edison to see if the Quark supporting software has become available. I am sure that informative examples will also be provided to help you utilize the coprocessor.
Figure 1-1 Top view of the Edison computing module.
There is also 4 GB of flash memory and 1 GB of RAM available to support the internal Edison processors. The flash memory comes preprogrammed with a Linux distribution created by Intel engineers using the Yocto framework. I will discuss this default Linux distribution in Chapter 2, in which I show you how to initially operate and communicate with the module.
There is also a Broadcom BCM43340 chip contained in the module, which implements b/g/n (11 Mbit/s, 56 Mbit/s, 100 Mbit/s internet speeds) and direct WiFi, as well as Bluetooth Low Energy (BLE) wireless communication. Both the WiFi and Bluetooth (BT) connections share the same onboard PCB chip antenna, which is visible at the lower left-hand corner in Figure 1-1. An external antenna connector using a μFL standard format is located just above the chip antenna and should be used if extended-range radio frequency (RF) operations are required. The internal chip antenna is fairly limited and will likely operate reliably only within 10 meters (m) of the WiFi access point, which is typically the wireless router in most home networks. Of course, BT communications was always designed to be close range, or not to exceed 10 m. One more point that you should know is that the antenna (internal or external) is multiplexed, or shared, between WiFi and BT operations. This might become problematic if maximum data bandwidth operations are attempted using both modes simultaneously.
The Broadcom chip also supports a hardware WiFi access-point (AP) mode, which might be very useful in certain applications. The only provision is that the module software must also support this type of operation. Fortunately, the default Linux distribution supports the AP mode, which allows for significant flexibility in configuring a network containing the Edison. Intel also provided support for BlueZ 5.0, which implements all the important and widely used BT profiles.
Now it is time to flip the module over and discuss the other side. Figure 1-2 shows the Edison’s backside, where you can see another metal cover and a high-density connector.
Figure 1-2 Bottom view of the Edison computing module.
I have already discussed what’s under the cover and will now focus on the connector. It is a 70-pin connector manufactured by the Hirose company. It is considered high density because of the very tight spacing between the connector pins, which are 35 pins spread across 14 mm with 0.4 mm between pins. To put this in a common perspective, most hobbyist’s solderless breadboards have a 0.1-inch, or 2.54-mm, spacing between insertion points. The contacts on the Hirose connector are about six times closer than those on a breadboard. The practical meaning for this situation is that the Edison can be used only with a development board with the matching male connector already installed on a PCB. It is just not feasible to manually solder 70 wires to a freestanding male Hirose 70-pin connector. It might be possible to solder a few wires to such