Arduino Android Blueprints 1st Edition Schwartz all chapter instant download
Arduino Android Blueprints 1st Edition Schwartz all chapter instant download
com
https://ebookname.com/product/arduino-android-
blueprints-1st-edition-schwartz/
OR CLICK BUTTON
DOWNLOAD EBOOK
https://ebookname.com/product/arduino-for-secret-agents-1st-edition-
schwartz/
ebookname.com
https://ebookname.com/product/programming-arduino-with-labview-1st-
edition-marco-schwartz/
ebookname.com
https://ebookname.com/product/node-js-blueprints-tsonev/
ebookname.com
https://ebookname.com/product/scanner-data-and-price-indexes-robert-c-
feenstra/
ebookname.com
Make a Difference A Spectacular Breakthrough in the Fight
Against Poverty 1st Edition Gary Macdougal
https://ebookname.com/product/make-a-difference-a-spectacular-
breakthrough-in-the-fight-against-poverty-1st-edition-gary-macdougal/
ebookname.com
https://ebookname.com/product/spiritual-gifts-1st-edition-jozef-rulof/
ebookname.com
https://ebookname.com/product/hacking-mythtv-11th-edition-edition-
jarod-wilson/
ebookname.com
https://ebookname.com/product/english-through-pictures-book-1-and-a-
first-workbook-of-english-updated-edition-i-a-richards/
ebookname.com
Arduino Android Blueprints
Marco Schwartz
Stefan Buttigieg
BIRMINGHAM - MUMBAI
Arduino Android Blueprints
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the authors, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
ISBN 978-1-78439-038-9
www.packtpub.com
Credits
He runs several websites around Arduino, including the Open Home Automation
website, which is dedicated to building home automation systems using open
source hardware.
He has written another book on home automation and Arduino, called Home
Automation with Arduino and another book on how to build the Internet of Things
projects with Arduino, called Internet of Things with the Arduino Yún, Packt Publishing.
Stefan Buttigieg is a medical doctor, mobile developer, and entrepreneur.
He graduated as a Doctor of Medicine and Surgery at the University of Malta,
and he is currently enrolled at the University of Sheffield where he is undertaking
a Master's degree in Health Informatics.
His main interests are in mobile development, specifically, Android and iOS,
open source healthcare projects, user interface design, mobile user experience,
and project management.
I'd like to thank Pack Publishing for again giving me the opportunity
to review their book after Talend for Big Data, and I hope you can find
this book as inspiring as it has been for me reviewing it.
Did you know that Packt offers eBook versions of every book published, with PDF
and ePub files available? You can upgrade to the eBook version at www.PacktPub.
com and as a print book customer, you are entitled to a discount on the eBook copy.
Get in touch with us at service@packtpub.com for more details.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser
[ ii ]
Table of Contents
[ iii ]
Table of Contents
[ iv ]
Preface
When directly comparing Arduino and Android, one can see that they are two
incredibly different platforms with different targets. Arduino is mostly focused on
connecting physical everyday objects to embedded microcontrollers. On the other
hand, Android intends to provide the necessary operating system and framework
to operate countless smartphones around the world.
This reality also reflects the contrasting realities of the authors, who come from very
different backgrounds and cultures; Stefan hails from the Island of Malta, and he
brings with him a medical background and passion for the intersection of technology
and medicine, whereas Marco originates from France and has an electrical
engineering background.
The power of combining the efforts of Arduino and Android platforms bring about
incredibly implemented practical projects that enhance daily life. Keeping this
motivation in mind is what brought two authors from contrasting backgrounds
together to work on this book. We believe in the intersection of technology and real
life and visualize a future where technology will keep on forming an integral part of
our day-to-day life.
Chapter 2, Controlling an Arduino Board via Bluetooth, teaches us how to link Arduino
and Android for the first time. We will build an Arduino system with a Bluetooth
Low Energy module, and control a simple LED from an Android application.
Preface
Chapter 3, Bluetooth Weather Station, teaches us how to build our first useful
application using Arduino and Android. We will build a weather measurement
station, and visualize the measurements via an Android application, which we
will build from scratch.
Chapter 4, Wi-Fi Smart Power Plug, teaches us how to build a DIY version of a popular
device: a wireless power switch. We will use an Android application to communicate
with the switch via Wi-Fi, control it, and measure the energy consumption of the
connected device.
Chapter 6, Android Phone Sensor, explains how to turn things around, and use the
sensors from our phone to control the Arduino board. Applying this, we will
use the gyroscope of the phone to control the angle of a servomotor.
Chapter 8, Control an Arduino Board via NFC, shows how to use the NFC chip present
in many Android phones to activate a relay connected to an Arduino board.
Chapter 9, Bluetooth Low Energy Mobile Robot, uses everything we learned so far in the
book to build a mobile robot based on the Arduino. The robot will be controlled via
Wi-Fi from an Android application.
Chapter 10, Pulse Rate Sensor, is dedicated to a medical application that measures
the heart rate. We will connect a heart rate sensor to Arduino and monitor the
measurements via Bluetooth Low Energy.
You will also need several Arduino libraries depending on the chapter, but the links
to these libraries are given in the relevant chapters.
[2]
Preface
• Android Studio
• Android 4.3 or higher on your Android phone
For example, this book is for you if you are already using the Arduino platform
and you want to build mobile applications to control your projects remotely.
Conventions
In this book, you will find a number of styles of text that distinguish between
different kinds of information. Here are some examples of these styles, and an
explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows:
"Your Arduino folder is where all the sketches are stored, and you can define this
folder in the preferences of the Arduino IDE."
New terms and important words are shown in bold. Words that you see on
the screen, in menus or dialog boxes for example, appear in the text like this:
"Depending on your device, this option might vary slightly, but as from
Android 4.2 and higher, the Developer options screen is hidden by default."
[3]
Preface
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or may have disliked. Reader feedback is important for
us to develop titles that you really get the most out of.
If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide on www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to
help you to get the most from your purchase.
[4]
Preface
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in the text or
the code—we would be grateful if you could report this to us. By doing so, you can
save other readers from frustration and help us improve subsequent versions of this
book. If you find any errata, please report them by visiting http://www.packtpub.
com/submit-errata, selecting your book, clicking on the Errata Submission Form
link, and entering the details of your errata. Once your errata are verified, your
submission will be accepted and the errata will be uploaded to our website or added
to any list of existing errata under the Errata section of that title.
Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media.
At Packt, we take the protection of our copyright and licenses very seriously. If you
come across any illegal copies of our works, in any form, on the Internet, please
provide us with the location address or website name immediately so that we can
pursue a remedy.
We appreciate your help in protecting our authors, and our ability to bring
you valuable content.
Questions
If you have a problem with any aspect of this book, you can contact us at
questions@packtpub.com, and we will do our best to address the problem.
[5]
Setting Up Your Workspace
The first chapter of this book will teach you the basics of the Arduino and Android
development so that you can be sure you have the basics required for the more
advanced tutorials you will find in the rest of this book.
On the Arduino side, we will build a very simple project with a relay module
(which is basically a switch that can be controlled with Arduino) and a temperature
and humidity sensor. We will also see the basics of the Arduino IDE and the basic
commands of the aREST library, which is a framework to easily control Arduino
boards. We will use this library in several chapters of this book to make it really easy
to control the Arduino board from an Android device. In this first chapter, we will
simply try out the commands of the aREST library by having the Arduino board
connected to your computer via a USB.
From the Android development point of view, we will work together to set up a
development environment and ensure that your computer and the Android device
are ready for development purposes. We will start off with a simple Android app
that displays the legendary text, Hello World.
Android Studio is in beta but the software is updated on a frequent and regular
basis by a dedicated team at Google, which makes it the natural choice to develop
our Android projects.
Setting Up Your Workspace
You will also need a DHT11 (or DHT22) sensor, along with a 4.7K resistor, for
temperature and humidity measurements. A resistor is basically a device to limit
the current flowing into an electrical device. Here, it is necessary to ensure the
correct functioning of the DHT sensor.
Finally, you will need a small breadboard and jumper wires to make the different
hardware connections.
[8]
Chapter 1
The following is the list of all hardware parts you will need for this project,
along with links to find these parts on the Web:
On the software side, you will need the Arduino IDE that we will also use in the
rest of this book. You can get it at http://arduino.cc/en/Main/Software.
The installation process of the IDE is very simple; you simply have to open the
file and follow the onscreen instructions.
You will need the library for the DHT11 sensor, which can be found at
https://github.com/adafruit/DHT-sensor-library.
Preparing for Android development requires that we get ready to design and
develop the app, and the following checklist will guide you with having the
basics ready for any project:
We will also work together to make sure that you have everything properly set up.
[9]
Setting Up Your Workspace
Mac
Open Terminal and type the following command:
java –version
Windows
Open Command Prompt and type the following command:
java -version
[ 10 ]
Chapter 1
Installing Java
If you do not have Java installed, or if your version is below 6.0, install the Java JDK
by clicking on the following customized and shortened link and choosing the version
that applies for you:
http://j.mp/javadevkit-download
[ 11 ]
Setting Up Your Workspace
The main recommendation for these projects is that you install a version of
JDK 6.0 or higher.
Select the JDK for your operating system. On an Intel-based Mac, you can follow
this useful table to see whether your Mac is 32-bit or 64-bit:
You can check for Processor Name by clicking on the Apple logo in the top-left
corner of your screen followed by About my Mac.
In the case of Windows, to see whether your computer is running a 32-bit or 64-bit
version of Windows, you need to do the following:
[ 12 ]
Random documents with unrelated
content Scribd suggests to you:
Fig. 144. Lepidodendron Veltheimianum Sternb.
A. Leaf-cushion and leaf-scar seen in surface-view at a; on the rest
of the specimen a slightly lower surface is exposed. (After Stur.)
B. Diagrammatic longitudinal section to explain the differences
between its two surfaces a and b shown in fig. A.
The shaded portion c represents the rock matrix, the surfaces
ab, ed, mark the outer and inner edge of the outer portion of the
bark of the Lepidodendron stem.
lt, leaf-trace; p, p′, parichnos.
Fig. 145.
A. Diagrammatic surface-view and longitudinal section of a
Lepidodendron leaf-cushion.
B. Aerenchyma below the leaf-scar. (After F. E. Weiss.)
The parichnos scars are shown on the leaf-scar and cushion in fig.
146, C. In the lower leaf-cushion shown in fig. 146, E, the infra-foliar
parichnos scars, p, are clearly seen, but the preservation of the leaf-
scar is not sufficiently good to show them on that part of the fossil. In
the upper cushion (fig. 146, E) the position of the parichnos arms is
shown on the leaf-scar, but the infra-foliar parichnos scars are
hidden by two small spiral shells. The genus Spirorbis, to which
these shells are referred, appears to have persisted from the Silurian
epoch to the present day. The comparatively frequent occurrence of
Spirorbis shells on the leaves and other parts of Palaeozoic plants,
has recently been dealt with in a paper by Barrois[245] who discusses
in detail the habitats of these small animals from the point of view of
the conditions under which the plants were preserved. In a note by
Malaquin appended to Barrois’ paper the belief is expressed that
Spirorbis lived on pieces of Palaeozoic plants which lay under water.
The fact that with one exception all the Spirorbis shells on the
specimen of Lepidodendron, of which two leaf-cushions are shown in
fig. 146, E, occur on the large parichnos scars on the cheeks of the
cushions, suggests the possibility that the escape of gases from the
parichnos tissue may have rendered the position attractive to the
Spirorbis. It can hardly be accidental that the shells occur on the
parichnos strands. This fact recalls the view held by Binney[246] and
accepted with favour by Darwin[247] that Lepidodendron and other
coal-forest trees may have lived with the lower parts of the stems in
sea water.
Above the leaf-scar is a fairly deep triangular or crescentic pit (fig.
146, C, l) known as the ligular pit from the occurrence on younger
shoots of a delicate organ like the ligule of Isoetes (fig. 132)
embedded in a depression in the upper part of the leaf-cushion. The
ligule was first figured in Lepidodendron by Solms-Laubach[248] and
described in English material by Williamson under the name of the
adenoid organ[249].
In some Lepidodendron stems a second triangular depression
may occur above the ligular pit, the meaning of which is not clear:
this has been called the triangulum by Potonié[250]. Stur[251] suggested
that it may represent the position occupied by a sporangium in
Lepidodendron cones.
It is important to remember that as a branch increases in girth the
leaf-cushions are capable of only a certain amount of growth: when
the limit is reached they are stretched farther apart and thus the
narrow groove which separates them is converted in older stems into
a comparatively broad and flat channel, thus altering the surface
characters.
Fig. 146. Lepidophloios and Lepidodendron leaf-cushions.
A, B, D, F, G, H, I. Lepidophloios. (Fig. A should be reversed.)
C, E. Lepidodendron aculeatum.
A, B. From a specimen in the Sedgwick Museum, Cambridge (leaf-
cushion 3 cm. broad).
C. From a specimen in the Sedgwick Museum, Cambridge (leaf-cushion 4
cm. long).
D. From a section in the Cambridge Botany School Collection.
E. From a specimen in the Bunbury Collection, Cambridge Botany
School, showing Spirorbis shells (leaf-cushion 2 cm. long).
F. From a section in the Williamson Collection, British Museum No. 1,
973.
G, H, I. From sections in the Cambridge Botany School Collection.
iii. Lepidophloios.
Before proceeding further with the genus Lepidodendron a short
account may be intercalated of the external features of a
lepidodendroid type of stem which it is customary to describe under
a distinct generic title Lepidophloios. This name is convenient for
diagnostic purposes though it seems clear that apart from the form of
the leaf-cushion (fig. 146, A) we are at present unable to recognise
any well-defined differences between the two forms Lepidodendron
and Lepidophloios. For general purposes the name Lepidodendron
will be used as including plants possessing leaf-cushions of the type
already described as well as those with the Lepidophloios form of
cushion.
The generic name Lepidophloios was first used by Sternberg[254]
for a Carboniferous species which he had previously described as
Lepidodendron laricinum. In 1845 Corda[255] instituted the name
Lomatophloios for specimens possessing the same external
characters as those for which Sternberg had chosen the name
Lepidophloios. The leaf-cushions of Lepidophloios differ from those
of the true Lepidodendron in their relatively greater lateral extension
(cf. fig. 146, A and C), in their imbricate arrangement and in bearing
the leaf, or leaf-scar, at the summit. In some species referred to
Lepidophloios the cushions are however vertically elongated and in
this respect similar to those of Lepidodendron: an example of this
type is afforded by Lepidophloios Dessorti a French species
described by Zeiller[256]. In younger branches the cushions may be
directed upwards having the leaf-scar at the top; but in the majority
of specimens the cushions are deflexed as in figs. 146, D; 160, A.
The shoot of Lycopodium dichotomum shown in fig. 121, B, with the
leaves in the reversed position bears a close resemblance to a
branch of Lepidophloios.
The photograph of Lepidophloios scoticus Kidst.[257] reproduced in
fig. 160, A, illustrates the dichotomous branching of the stem and the
form of the cushions with the leaf-scars pointing downwards. In the
fertile branch of the same species shown in fig. 160, B, the leaf-scars
face upwards.
In most species the cushions are simply convex without a median
keel, but in some cases a median ridge divides the cushion into two
cheeks as in the genus Lepidodendron. The leaf-scar bears three
small scars, the larger median scar marking the position of the leaf-
trace, while the lateral scars are formed by the two arms of the
parichnos: in some examples of deflexed cushions, though not in all,
a ligular pit occurs on the cushion a short distance above the leaf-
scar.
The drawing reproduced in fig. 146, A, showing the leaf-scar on
the upper edge of the cushion should have been reversed with the
leaf-scars pointing downwards. This figure represents part of the
surface of a specimen consisting of the outer cortex of a stem with
leaf-cushions 3 cm. broad. The thickness of this specimen is 4 cm.: a
section through the line ab is represented in fig. 146, D (reproduced
in the correct position, with the leaf-scars, sc, pointing downwards):
internal to the cushions is a band of secondary cortex (the shaded
strip on the outer edge of the section) which was formed on the
outside of the phellogen. The phellogen is a cylinder of actively
dividing cells in the outer part of the cortex of the stem, often spoken
of as the cork-cambium or cortical meristem, which produces a
considerable amount of secondary cortical tissue on its inner face
and a much smaller amount towards the stem surface. This delicate
cylinder frequently forms a natural line of separation between the
outer shell of bark and the rest of the stem. In the specimen before
us, the thin-walled cells of the phellogen were ruptured before
petrification and the outer shell of bark was thus separated as a
hollow cylinder from the rest of the stem: this cylinder was then
flattened, the two inner surfaces coming into contact. Fig. 146, D,
represents a section of one half of the thickness of the flattened
shell.
This separation of the outer cortex, and its preservation apart from
the rest of the stem, is of frequent occurrence in fossil
lycopodiaceous stems. The flattened outer cortical shell of a
Lepidophloios, specifically identical with that shown in fig. 146, A and
D, was erroneously described by Dr C. E. Weiss in 1881 as a large
lepidodendroid cone[258].
Fig. 146, B, affords a view of the inner face of the specimen of
which the outer surface is seen in fig. 146, A: the surface shown in
the lower part of the drawing, on which the boundaries of the
cushions are represented by a reticulum, corresponds to the inner
edge of the strip of secondary cortical tissue represented by the
vertically shaded band in fig. 146, D.
The shaded surface in fig. 146, B, represents a slightly deeper
level in the stem which corresponds to the outer edge of the
vertically shaded band of fig. 146, D: the narrow tapered ridges (fig.
146, B) represent the leaf-traces passing through the secondary
cortex, and the fine vertical shading indicates the elongated
elements of which this strip of secondary cortex is composed.
In the longitudinal section diagrammatically reproduced in fig. 146,
D, cut along the line ab of fig. 146, A, the parenchymatous tissue of
the stout cushions has been partially destroyed, as at a; at s is seen
the section of a Stigmarian rootlet which has found its way into the
interior of a cushion. Each leaf-trace is accompanied by a parichnos
strand as in the true Lepidodendron; at the base of the leaf-cushion
the parichnos branches into two arms which diverge slightly right and
left of the leaf-trace, finally entering the base of the leaf lamina as
two lateral strands (fig. 147, p). At one point in fig. 146, D the section
has shaved a leaf-trace represented by a black patch resting on the
parichnos just above the line ef, but it passes through one of the
parichnos arms p′ which debouches on to the leaf-scar sc at p. Had
the section been cut along the line cd of fig. 146, A the leaf-trace
would have been seen in a position similar to that occupied by the
parichnos p′ in fig. 146, D.
Fig. 147. Lepidophloios leaf-cushion in tangential section. (From a
section in the Williamson Collection, British Museum, No. 1973.)
Fig. 147, A, affords a good example of a tangential section through
a Lepidophloios leaf-cushion, 1 cm. broad, like that represented in
fig. 146, A, showing the vascular bundle lt, the two parichnos
strands, p, composed of large thin-walled cells (cf. Isoetes, fig. 133,
H, I), and the ligular pit near the upper edge of the section enclosing
the shrunken remains of the ligule (fig. 147, B, l).
LEPIDODENDRON