Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Android Things Projects

You're reading from  Android Things Projects

Product type Book
Published in Jun 2017
Publisher Packt
ISBN-13 9781787289246
Pages 232 pages
Edition 1st Edition
Languages
Author (1):
Francesco Azzola Francesco Azzola
Profile icon Francesco Azzola

Table of Contents (15) Chapters

Title Page
Credits
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface
Getting Started with Android Things Creating an Alarm System Using Android Things How to Make an Environmental Monitoring System Integrate Android Things with IoT Cloud Platforms Create a Smart System to Control Ambient Light Remote Weather Station Build a Spying Eye Android with Android Things

How to implement a custom sensor driver


Now that we know how I2C protocol works, we can start developing our custom driver. A powerful feature of Android Things is the capability to add new peripherals developing specific drivers. In other words, it is possible to extend the sensor framework including new sensors. In this way, Android Things does not make a difference between a built-in sensor and the new sensors. It is possible to handle them in the same way we handle built-in sensors. It is important to notice that the driver that handles the sensor depends on the sensor protocol built on top of I2C bus.

In order to implement a new sensor driver in Android Things we have to follow these steps:

  1. Implement a class that extends the UserSensorDriver.
  2. Describe the sensor specifications and capabilities.
  3. Register the sensor driver.

To better understand how these classes are used and the role they play, it is useful to analyze how the BMP280/BME280 sensor driver is implemented. This can help us to...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}