Share

engineering

2min read

First experiment with Android Things™

First experiment with Android Things™

Dave Smith’s short post on Google+ inspired me to experiment with Android Things™ for the first time. The native Android mechanism was cleverly used to create a candle and I thought that going with it even further would be an interesting idea.

Environment

I used Raspberry Pi 3 to run Android Things and surprisingly for me, everything worked just fine. I prepared a MicroSD card for Raspberry Pi 3, created sample project in Android Studio and after a while, a small LED powered by Android Things was working. The only thing that made me a bit frustrated was the instability of the ADB connection to Raspberry Pi 3. The device often turned to OFFLINE state and needed at least one ADB restart (kill-start-connect) to set up the connection again.

Typically for Android app, the main element is an Activity. It could look intuitive because Android Things app doesn’t require any GUI but Activity as a main component is rooted in Android Framework. Android Things brings the concept of User Drivers which is some kind of bridge between well-known Android API and hardware connected to R Pi3 with a bunch of wires. The simple example is the driver for a button. A user can register driver in the system that converts high-low signal on some specific PIN to Android KeyEvent and the KeyEvent is provided to an Activity by Android Framework (a KeyEvent couldn’t be provided to a Service)

Candle

The candle can be activated by pressing the button or by the darkness detector. The truth is that from the source code perspective, the button and the darkness detector (simple photoresistor with voltage divider pattern) look the same. The way in which the domain will be described in the code depends mostly on a developer. On one hand, it gives great flexibility, on the other - it could become the source of unreadability.

candle_bb_720.png

The schema of the candle is pretty simple. There is just one factor that makes me a little bit skeptical. Even though the schema is simple, it is worth mentioning that in spite of 1 button, 4 resistors, 1 photoresistor and 2 diodes, I also had to use processor with 4 cores 1.2GHz and 1GB RAM. We have to be aware that Android Things is actually the trimmed version of Android, which means that a device has to handle Linux with Dalvik. There seem to be a lot of resources as for an embedded system.

Check out our Github for full source code of the candle.

Share

Paweł

Lead Software Engineer

Did you enjoy the read?

If you have any questions, don’t hesitate to ask!

Did you enjoy the read?

If you have any questions, don’t hesitate to ask!