android.geek.nz

Making Things do stuff

Tag: I2C

Create custom I2C peripherals for Android Things

In this experiment I will demonstrate how to use an external MCU to manage tricky time-constrained tasks on behalf of Android Things. Using an ATTiny85 microcontroller I’ll interface a Dallas 1-wire temperature sensor, the ubiquitous DS18B20, to a Raspberry Pi running Android Things.

ds18b20

The DS18B20 temperature sensor

Background (why)

Since the introduction of Android Things some have questioned the limits of Android Thing’s GPIOs. Collecting data from the Raspberry Pi running Raspbian or similar will show that GPIOs on Android Things are too slow for some applications. Discussions about GPIO speed highlight a point about operating systems in general and Android Things in particular. Android Things is not a real time OS. It will miss deadlines. It will not respond to interrupts predictably enough to satisfy some of the tasks that people may be expecting it to perform. The problem here is not the OS, but the expectations.

As mentioned in this SO answer one possible solution to this problem is to have an external helper MCU handle the hard real-time stuff. Great, but what is all this real-time stuff about?

Continue reading

Adding Buttons to Android Things

In this experiment I’m going to add buttons to Android Things using the user space input driver extension mechanism provided by the platform. I’ll be using momentary push buttons connected to a Raspberry Pi running the Android Things preview image. The buttons will be connected via an I2C IO port, the PCF8574. I’ll use one GPIO on the Raspberry Pi as an ‘interrupt’ line to detect a button press, then I’ll read the button states and report button presses to the framework as input events.

The setup with buttons

Continue reading

© 2018 android.geek.nz

Theme by Anders NorenUp ↑