Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
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
Toc

Table of Contents (15) Chapters close

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

How to read data from sensors


Now we are ready to start acquiring data from I2C sensors. Usually, in order to use an I2C peripheral, we need a driver. A driver is a set of classes that handle the communication between the Android Things board and the peripheral. Moreover, these classes handle the specific protocols implemented by the peripheral. We will describe how to implement a low-level protocol in the next sections. By now, we can use a pre-built driver that is a library we have to include in our project. All the drivers officially supported by Android Things are available at GitHub under the folder contrib-drivers at https://github.com/androidthings/contrib-drivers.

Let us start:

  1. Create a new Android Things project by cloning the repository as described in the first chapter.
  2. Open build.gradle and add the following line under the dependencies:
compile 'com.google.android.things.contrib:driver-bmx280:xx'

Where xx is the version of the driver.

Now you are ready to use the BMP280/BME280 sensor...

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