O'Reilly logo

Android Things Projects by Francesco Azzola

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Low-level sensor driver

The Bmx280.java is the class that makes the heavy work and if we want to implement the new feature that reads the humidity we have to modify it. Moreover, you need the manufacturer datasheet (https://cdn-shop.adafruit.com/datasheets/BST-BME280_DS001-10.pdf) in order to know how to exchange data with the sensor. Let us examine it.

To open a connection to an external sensor we need an instance of the PeripheralManagerService class:

PeripheralManagerService pioService = new PeripheralManagerService();

Then, the class opens the connection using:

I2cDevice device = pioService.openI2cDevice(bus, I2C_ADDRESS);

Where:

  • The bus is the SDA pin we have used to connect the sensor to the Android Things board.
  • The I2C_ADDRESS is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required