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
Credits
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface

How to control GPIO pins


Now that we know how to read the environment parameters, we can implement the application logic to control other peripherals according to the values acquired. As described in the previous sections, the Android Things monitoring app uses the temperature and pressure to controls two devices:

  • An RGB LED that shows the current pressure state
  • A RED LED that shows if the temperature is lower than a threshold

To make the app work, we have to fix the pressure threshold values. To simplify the development process we can suppose that there are two thresholds:

  • Threshold one, that we will call LEVEL_1, is 1022.9 mb
  • Threshold two, that we will call LEVEL_2, is 1009.14 mb

The app logic that we will implement works in this way:

  • If the current pressure is over the LEVEL_1 then the RGB LED will have the green and red color turned on (yellow)
  • If the current pressure is between LEVEL_1 and LEVEL_2 the RGB LED will have only the green color turned on
  • If the current pressure is below LEVEL_2...