Android Things: Android Internet of things tutorial
Android Internet of things called Android Things is the new OS announced by Google. This is an Android-based OS for Internet of things (IoT). If you are new to IoT, give a look at my article about what is 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 didn’t have a big success. Even if Android Things is still in the developer preview version, it introduces some important features that make it different from Brillo. Android Internet of 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 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.
How to install Android Internet of 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
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:
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:
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:
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:
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.
Reference: | Android Things: Android Internet of things tutorial from our JCG partner Francesco Azzola at the Surviving w/ Android blog. |