Book Image

Android Things Projects

By : Francesco Azzola
Book Image

Android Things Projects

By: Francesco Azzola

Overview of this book

Android Things makes developing connected embedded devices easy by providing the same Android development tools, best-in-class Android framework, and Google APIs that make developers successful on mobile. With this book, you will be able to take advantage of the new Android framework APIs to securely build projects using low-level components such as sensors, resistors, capacitors, and display controllers. This book will teach you all you need to know about working with Android Things through practical projects based on home automation, robotics, IoT, and so on. We’ll teach you to make the most of the Android Things and build enticing projects such as a smart greenhouse that controls the climate and environment automatically. You’ll also create an alarm system, integrate Android Things with IoT cloud platforms, and more. By the end of this book, you will know everything about Android Things, and you’ll have built some very cool projects using the latest technology that is driving the adoption of IoT. You will also have primed your mindset so that you can use your knowledge for profitable, practical projects.
Table of Contents (15 chapters)
Title Page
About the Author
About the Reviewers
Customer Feedback


Android Things is the new OS developed by Google for building professional IoT projects using Android. Throughout the course of this book, you will gain deep knowledge of Android Things and get ready for the next technological revolution. You will learn how to create real-life IoT projects covering all the aspects of Android Things.

What this book covers

Chapter 1, Getting Started with Android Things, introduces IoT and explains why it has such huge impact on everyday life. This chapter also introduces Android Things and explains how to use it in your first IoT project.

Chapter 2, Creating an Alarm System Using Android Things, shows how to use two-state sensors (or binary devices) in Android Things. This chapter also covers creating an alarm system that detects motion and sends a notification to a user's smartphone.

Chapter 3, How to Make an Environmental Monitoring System, shows how to connect sensors to Android Things and how to read data using the I2C bus. These concepts are applied to an IoT project that monitors the environmental parameters and uses an RGB LED to visualize it.

Chapter 4, Integrate Android Things with IoT Cloud Platforms, covers how to use Android Things in an IoT cloud architecture. This chapter describes how to stream real-time data from sensors to IoT cloud platforms.

Chapter 5, Create a Smart System to Control Ambient Light, demonstrates how to use a simple integration pattern to integrate Android Things with Arduino using the HTTP protocol.

Chapter 6, Remote Weather Station, covers how to use Android Things in Machine to Machine (M2M) architecture. In this chapter, we will build a remote weather station that monitors temperature, humidity, pressure, and light, and sends data using the MQTT protocol.

Chapter 7, Build a Spying Eye, shows how to develop an Android Things app that controls servo motors using Pulse Width Modulation (PWM) and how to use the camera with Android Things.

Chapter 8, Android with Android Things, covers how to develop Android companion apps that interact with Android things.

What you need for this book

To build the examples in this book, you need to have Windows OS or Mac OS X. Moreover, in order to develop, compile, and install the Android Things app, you have to install Android Studio as specified during the chapters.

Who this book is for

This book is for Android enthusiasts, hobbyists, IoT experts, and Android developers who want to gain deep knowledge of Android Things. The main focus is on implementing IoT projects using Android Things. This book also covers Android Things API and how to use them in IoT. The reader will use sensors, resistors, capacitors, and IoT cloud platforms.


In this book, you will find a number of text styles 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:

"We can include other contexts through the use of the include directive."

A block of code is set as follows:

adb shell am startservice
-a WifiSetupService.Connect
-e ssid <Your_WIFI_SSID>
-e passphrase <WIFI_password>

Any command-line input or output is written as follows:

sudo dd bs=1m if=path_of_your_image.img of=/dev/rdiskn

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in text like this:

"When the board is connected to your PC or Mac, it appears in the Platform Flash Tool Light."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book what you liked or disliked. Reader feedback is important to us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. 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 at

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.

Downloading the example code

You can download the example code files for this book from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you. You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at We also have other code bundles from our rich catalog of books and videos available at Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from


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, 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. To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted 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. Please contact us at [email protected] with a link to the suspected pirated material. We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.