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);
- The bus is the SDA pin we have used to connect the sensor to the Android Things board.
- The I2C_ADDRESS is ...