Android Things Dev Preview 2 Could Be What We Need!
Android Things Dev Preview 2 Could Be What We Need!
Written by Harry Fairhead   
Friday, 10 February 2017

Android Things is Google's attempt to get into the IoT world. The first preview wasn't impressive, but now we have Developer Preview 2 and it seems to fix many of the problems. This could be the IoT OS we all use. Updated: Still not fast enough.

androidthingsbannersm

There is no doubt that using Android as an IoT OS has many attractions - mainly the ease of creating a UI and the integration with other Google Play services. However, when it comes to creating IoT programs you need something more. You not only need the ability to interface to a range of fairly standard sensors you need the speed to be able to take on both custom devices and to work with many devices at the same time. No matter what reasonable limits the OS programmers put on what can be done the IoT programmer will want more. 

In our investigation of the first preview of Things, Getting Started With Google's Android Things, it rapidly became clear that this was not yet an OS that could be used to do new things. The Java control of GPIO lines in Java was 5000 times slower than doing the same job using C.

Clearly this isn't going to be fast enough for custom drivers and it probably isn't fast enough to control banks of sensors. 

 

androidthingsbanner

 

To get the speed we need, one possibility is to make it possible to write custom drivers or even general code in C. Given Android already has a way of mixing C and Java, i.e. the NDK, it seemed surprising that this wasn't a feature of Preview 1. The good news is that it is a feature of Preview 2. 

Android Things supports the standard Android NDK. We have now released a library to provide native access to the Peripheral API (PIO), so developers can easily use their existing native code.

The key seems to be the new NativePIO library:

The native PIO APIs let you write C/C++ code to control GPIO, PWM, I2C, SPI and UART peripherals that access the same underlying peripheral service as the standard PIO APIs. This lets you write an Android Things app purely in C/C++ or extend a Java-based Android Things app with C or C++ code that uses the native PIO APIs (for example, porting existing drivers written for other embedded platforms).

The only problem seems to be that there is a lot of boilerplate code and seeming complexity. This isn't a simple C IoT program with no need to interact with a larger system. However, boilerplate code has a way of seeming less complex the more you use it so perhaps converting existing C programs might be relatively easy.

The idea of allowing IoT programmers to create user space drivers is a good one and now that you can augment this by writing in C it should make it possible to do almost anything. For example:

your driver code could read a GPIO pin and trigger a regular Android KeyEvent, or read in an external GPS via a serial port and feed this into the Android location APIs. This allows any application to inject hardware events into the framework, without customizing the Linux kernel or HAL. 

There are only two things that could make this go horribly wrong - lack of speed or lack of simplicity. At the moment it is difficult to see where the speed could be lost in the system, but for the average IoT programmer this is going to seem like a complication of something that is already hard enough.

The solution to the ease of use problem is most likely Android Studio modifications and extensions. At the moment a Things project uses the NDK in the usual way, but you have to copy the files you need manually. Clearly we need a new project wizard and a few more helpers.

Also new is USB audio support for the Edison, Joule and Pi. In fact Joule support is also new and you can now run Android Things on the Joule, Edison, Pi and NXP Pico. 

I have left the most startling development until the end - a "just one more Things" moment. Android Things now supports TensorFlow. Yes you can do AI neural networks on an IoT device. The sample provided shows object recognition using the camera. 

 

Thingstensor

TensorFlow sample identifying a dog's breed (American Staffordshire terrier) on a Raspberry Pi 3 with camera


Stay tuned for our update on Getting Started With Google's Android Things complete with an assessment of how fast and how easy it is to use C/C++ code.

As hinted in the headline, with its coverage of the low end with C/C++ and the NDK and the high end with AI, Speech API and so on, this might be the IoT OS to take notice of - but only if Google can get its act together on making it easy enough to use. 

Update:

After trying out the NDK approach to working with the GPIO lines the sad news is that it is hardly any faster than the Java. See: Getting Started With Google's Android Things - Preview 2. This is disappointing and negates many of my opinions expressed in this news item. For raw interfacing or doing anything demanding Android Things is still too slow even on a Pi 3. 

More Information

Android Things Developer Preview 2

Related Articles

Getting Started With Google's Android Things - Preview 2

Android Things - Google's IoT

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on, Twitter, FacebookGoogle+ or Linkedin.

 

 

Banner


N Queens Completion Is NP Complete
31/08/2017

The problem of putting eight queens on the chess board so as no queen attacks another is a solved problem, as is placing n queens on an nxn board. However if you place some queens on the board and ask [ ... ]



Flat UI Is Slower!
06/09/2017

The whole world is flat. The flat UI is about the only design you can use and expect respect. But old-fashioned 3D non-flat UIs are faster and this has now been reasonably demonstrated by research fro [ ... ]


More News

 

 
 

 

blog comments powered by Disqus

Last Updated ( Monday, 13 February 2017 )
 
 

   
Banner
RSS feed of news items only
I Programmer News
Copyright © 2017 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.