Android Things 101

Google announced Android things in the end of Dec. That’s a special version of Android, you can refer the following picture to see how it works:

This picture comes from Google, you can see the basic components of Android things are mostly android components. The biggest difference is that google uses Things Support Library to substitute original Android Phone Components. But you still can create an android app on Android Things. That means, google just created a bridge for you and embedded system. And you can easily create an app for embedded system just like you create one on Android Phone / Pad.

The main functionality of Things Support Library is letting you control Peripheral IOs, e.g PWM / UART / GPIO etc, and User Driver which means you can register new components within Apps and extend the existing Android framework services. You can inject hardware events from Apps into framework to create more various applications for users. So, for more information, you can check Peripheral IO and User Driver.

So, let’s see how to install Android Things on boards.

First of all, you need a empty micro SD card Android Things system. In my previous experiences, you only need 16Gb sizes for that. I think that would be easy to get one.

Check you SD card status first.

df -h
System Disks Information

You can see my SD card is mounted on /dev/disk2s1, now you should download Android Things Image (I used RPi3, you can check website and choose images for your hardware.) and then unmount your SD

sudo diskutil unmount /dev/disk2s1 (you should use yours here)

After you unmounted your SD card, write img into SD card

sudo dd bs=1m if=iot_rpi3.img of=/dev/rdisk2 (my path is /dev/disk2s1, so it would be rdisk2 here, remember to change here according to your path)

After writing image into SD card, just eject SD card and put into RPi3. Let’s boot it now. You can see Android Things Logo like this:

Android Things with RPi3 ModelB

My RPi3 just connected to a hub. Its IP address is 192.168.1.126, and doesn’t connect to any wifi AP. Let’s check it by using adb tool

adb devices
adb lists devices

Seems everything is correct, let’s connect this RPi3 by using :

adb connect 192.168.1.126:5555
Connected to RPi3 by using adb tool

Ok, everything is done. But you might think : How do I connect my RPi3 with Wifi router ?

Try to use am command in adb shell

adb shell am startservice \
-n com.google.wifisetup/.WifiSetupService \
-a WifiSetupService.Connect \
-e ssid <Network_SSID> \
-e passphrase <Network_Passcode>

Remember substitute your network ssid for Network_SSID and real password for <Network_Passcode>

After doing this, you can see your device connects to your Wifi router with new IP address.

So, you can start developing your first Android Things App on this device.

Enjoy.