Arduino Meets Linux: The Users Guide to Arduino Yn Development
Copyright 2015 Bob Hammell.
EBooks are not transferable. All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher, except in the case of brief quotations embodied in critical reviews and certain other non-commercial uses permitted by copyright law.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image, the names, logos, and images are used only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The information in this publication is provided by Bob Hammell on an AS IS basis. Bob Hammell makes no warranties, express or implied, regarding use of the information alone or in combination with your products. Neither the author nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made.
Published in the United States of America by Bob Hammell.
ISBN-10 (Print): 1-514-23022-4
ISBN-13 (Print): 978-1-514-23022-0
ISBN-13 (ePub): 978-1-329-19359-8
Any source code or supplementary materials referenced by the author in this text are available for readers at www.arduinomeetslinux.com.
Table of Contents
Features and connectors of the Arduino Yn Connecting the Arduino Yn to a network Changing your password Opening the advanced configuration panel Uploading sketches to the Arduino
Connecting to the Arduino Yn and transferring files from another computer Using the command prompt Editing text files with GNU nano Writing shell scripts Installing Linux software Resetting the operating system Backing up the Arduino Yn
Running Python scripts on the Yn Writing your own Python functions Working with classes and objects Using packages and modules Reading and writing to files Handling the errors in scripts
Storing data in the AR9331s memory from the ATmega32u4 Running Linux commands and scripts Working with files in the Linux file system Using the Mailbox and sending messages Communicating over local networks and the Internet
Setting up a website on the Arduino Yn Server-side scripting with CGI and Python Project 1 Building a web-based temperature monitor Making web services and APIs Project 2 Controlling an LED matrix through a web API
Connecting a parallel 16x2 LCD display to the Arduino Yn Using a USB audio interface Playing MP3 files from Python scripts
How USB devices communicate Using PyUSB to communicate with a USB device Working with Microsoft Xbox 360, Sony PlayStation, and PC game controllers
Connecting to an accelerometer module Using pin headers to fit a ProtoShield to an Arduino Yn Using the Mouse class to turn the Yn into a USB mouse
Hosting a USB keyboard Using Temboo and Microsoft Translator Translating text from an Arduino sketch Using the Keyboard class to turn the Yn into a USB keyboard Reading the position of a rotary switch
Recording from a microphone Translating speech to text with the AT&T Speech API Responding to voice commands Translating text to speech Playing a .wav file
Preface
The Arduino Yn is a very powerful and very flexible development board. It combines the best aspects of the Arduino platform an easy-to-use integrated development environment (IDE), simple access to hardware pins, and a helpful community with the power and customization options of a Linux-based computer.
To do this, the Arduino Yn includes both an ATmega32u4 microprocessor from the Atmel Corporation (as used in other Arduinos) and a 400 MHz, 32-bit MIPS central processing unit (CPU) from Atheros. The inclusion of the MIPS chip means that the Yn can perform tasks that other Arduinos do not have the speed or memory resources to do. And because the Yn runs the Linux operating system, you can use programming languages and software programs that you cannot run on other Arduinos.
The Yn gives you a choice:
- You can use the Linux side of the Yn to add faster processing and more-capable networking to your ATmega32u4 projects writing the main parts of your projects in Arduino sketches;
- Or you can use the ATmega32u4 to add a friendly hardware interface to your Linux-based projects.
For Arduino users who do not have experience and knowledge of running Linux on embedded devices and programming in that environment, it can be difficult to learn how to make use of the extra power.
Whats in this Book?
My aim in writing Arduino Meets Linux is to show you how you can use the full power of the Arduino Yn. The chapters and projects in this book guide you through:
- Working with the Arduino Yn;
- Using the Linux operating system; and
- Developing projects that use both the ATmega32u4 and the Atheros AR9331 to create devices that are extremely difficult (or even impossible) to build using other Arduinos.
To program the ATmega32u4 on the Yn, you can use the Arduino IDE. This book introduces the libraries and functions that are specific to the Yn and that are built-in to the Arduino IDE. Every feature of the Yn is included, with sample code to help you learn to use these features.
To write programs and build projects on the Linux side of the Yn, you can use a variety of techniques and programming languages. Arduino Meets Linux concentrates on using the Linux command line and the Python scripting language. If you dont have any experience of using Linux operating systems or programming in Python, dont worry. You can find introductions to these subjects in the book.
Because the Yn is extremely capable at communicating over local networks and over the Internet, I have also included projects that demonstrate:
- Hosting your own web sites and web services on the Yn;
- Fetching information from third-party web services across the Internet; and
- Using Temboo to simplify how you can access many web services.
I hope that you find these projects interesting. But remember, my hope is that you learn how to make use of the Arduino Yn and develop your own ideas. The techniques and explanations in my projects are intended to help you build your own. For that reason, I recommend that you read through all of the chapters in this book and build the projects. You can learn far more by making and experimenting than I can put into words.
Who Should Read this Book?
If the Yn is your first Arduino, you should take some time to study the beginners tutorials at http://www.arduino.cc. If you ignore the Atheros AR9331, the Arduino Yn works almost identically to an Arduino Uno or Arduino Leonardo.
To an extent, Arduino Meets Linux assumes that the Yn is not your first Arduino. Although I have taken precautions to explain concepts that may be new to you, you should have a basic grasp of the fundamentals of building projects on the Arduino platform. This includes: writing sketches in Arduino C in the IDE; and safely building simple, electronic circuits.
If your main computer is a Windows PC or Apple Mac, and you have never used Linux before, then this book will help you. Everything you need to know is included. And the skills that you learn working with Linux on the Arduino Yn will help you if you ever want to use a Linux operating system on another development board or computer.
Arduino Meets Linux is for Arduino users who want to expand their skill set and learn to take advantage of the extra power and resources that only the Arduino Yn has.
Next page