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:
- Implement a class that extends the
- Describe the sensor specifications and capabilities.
- 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...