Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Android Things: An Android IoT Tutorial

DZone's Guide to

Android Things: An Android IoT Tutorial

Android Things is easy to start using. Learn how to get everything all set up so you can start using Android with your IoT projects!

· Mobile Zone
Free Resource

Launching an app doesn’t need to be daunting. Whether you’re just getting started or need a refresher on mobile app testing best practices, this guide is your resource! Brought to you in partnership with Perfecto

Android Things is the new OS announced by Google. This is an Android-based OS for the Internet of Things (IoT). If you are new to IoT, take a look at my article  explaining IoT.  As the name Android Things implies, it is a modified version of Android OS that runs on our smartphones. This OS joins the Android family with Android, Android TV, and Android Auto.

What Is Android Things?

Android Things is the new OS developed by Google for IoT. If we look at the past, Google made another attempt to jump into IoT ecosystem with Brillo that was not largely successful. Even if Android Things is still in the developer preview version,  it introduces some important features that make it different from Brillo. Android Things supports only three IoT devices:

  • Intel Edison
  • NXP Pico
  • Raspberry Pi 3

The list, by now, is quite limited but the OS is still in the preview version so more devices will be added in the future.

Android Things is a modified version of Android and it has a subset of the Android API. This aspect is very important because Android developers can move to Android things smoothly. They use the Android development experience.  Of course, the APIs related to Maps authentication are not supported.

The overall development process used for Android apps is still valid for Android Things, even the IDE is the same. All these aspects will have a great positive impact on this OS future. It is the first OS that uses Java as development language (as Android), while others OS or IoT boards are based on C/C++. Moreover, developers can reuse Google cloud platform components like Firebase in the development process.

Further reading: Getting started with Android Thigs, the new IoT OS.

How to Install Android Things

Now we know what is Android Internet of things known as Android Things we can start installing it. In this article, we will use Raspberry Pi 3 as a development board. What do we need?

This is the list of things we need to get started with Android Things OS:

  • Raspberry Pi 3
  • Micro SD Card 8 Gb or more
  •  Windows or OS X

Image title

At the beginning, it is necessary to format the SD card using FAT 32. If you are using a Mac, go to Disk Utility and format the card:

Image title

All done. You are ready to install the developer preview image. Download the image for Raspberry. Once the download is ready, we can install it:

sudo dd bs=1m if=path_of_your_image.img of=/dev/rdiskn

One important step is to identify the disk number (n). You can do it using OS X Information and looking for the Card reader device:

android things disk

The BSD number is the number we are looking for. In this case, n=1. During the installation process, you don’t have messages and you have simply to wait until the process is complete. At the end, you get a message saying that the disk is unreadable, it is ok, it works!

It is time to insert the new OS disk into your Raspberry Pi.

Verify Android Things Installation

Finally, we can verify if the installation is correct powering on the Raspberry Pi. You can use a USB cable connected to your PC to start Raspberry. At the beginning, you need to connect Raspberry to the LAN using a cable and you need an HDMI cable to connect the board to a TV or monitor. If you don’t want to use an HDMI cable you can use Vysor a Chrome plugin.

When the boot process finishes, the result is shown below:

Image title

If you get this screenshot it means that Android Internet of things is running on the Raspberry Pi 3.

Now, it is possible to connect to the Android Things using adb as we do in Android. Moreover, it is possible to get the device list using adb devices:

Image title

That’s all. Android Things is up and running. Now, you can start developing your first IoT project as we will see in the next article.

New API in Android Internet of things

Even if Android Things is a subset of Android, this new OS introduces some important APIs that are specific to the IoT domain. When we create an IoT project, we have to communicate with external sensors or actuators.  Thus, Android Things uses two industry standards in Peripheral I/O:

  • GPIO for sensors
  • PWM for DC motors, lights, etc.

Moreover, some content providers (Calendar, Telephony, etc.) are not supported.

An interesting aspect is that Android Things supports UI interface like a “normal” Android app.

Conclusion

After a few days, I can say that Android Things is an interesting IoT OS based on Android. This is very important because the development process is the same used for an Android app.  Developers can reuse the Android knowledge and experience. In this way, the transition is smooth. Of course, Android Things is still a developer preview so many things could change but the beginning is very promising.

Keep up with the latest DevTest Jargon with the latest Mobile DevTest Dictionary. Brought to you in partnership with Perfecto.

Topics:
android ,api ,mobile ,iot

Published at DZone with permission of Francesco Azzola, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}