Getting Started with Android Things
I’ve been excited at the prospect of IoT and building with Android Things for a long time
I had visions of building complex and exciting projects over my winter vacation. I finally decided the time was right, and started down the rabbit hole with a simple Google search “android things kit”.
This lead to questions such as
- what board should I get?
- should I just get a developer kit?
- how do I actually install Android Things?
- how do I connect a button or add a sensor?
I quickly discovered that I had a lot of questions to go along with the myriad of ideas running through my head.
I decided to refocus my initial expectations and choose a less daunting initial project.
Since I’m not very familiar with the hardware aspect of things, I decided to avoid that as much as possible during my first foray in building with Android Things. I decided I wanted to go from 0 to a typical phone/tablet “Hello World” built on an Android Things install.
Selecting the Hardware
One of my first challenges was just learning about what hardware platforms were compatible with Android Things and which were easily available.
Finding out what the options are
Documentation for the various developer kits can be found on the Android developers website.
There’s a handy chart with several options including links for more information and where to buy
Where to buy
There are a couple good options to purchase your hardware depending on which platform you want to go with.
What I chose
After looking around a bit, and a recommendation from Rebecca Franks I decided to go with the PICO-PI-IMX7 kit.
Honestly the recommendation from Rebecca sold me on it, but I was also happy at the thought of a kit with a screen, a camera AND the Rainbow Hat. I knew this would give me plenty to learn and play with to keep me busy for quite a while.
You can find more about this kit here:
What I Ordered
Unfortunately, this kit was backordered when I was ready to order. Being the impatient consumer/developer that I am, I decided to roll the dice a bit and purchase my kit piecemeal.
So instead, I ordered the following I ended up with just about everything that comes with the full kit (I’ll mention what was missing later).
Shipping was surprisingly fast, and after ordering I waited less than a week to receive my kit.
How to setup?
Setting up the Android Things hardware was split into 2 steps
- connect the hardware components
- installing Android Things on the hardware
Connecting your components
I’ve never worked with anything like the Pico before, but I have build a few computers and the process was similar.
I followed these instructions, which 1 exception.
Remember when I mentioned my piecemeal order was missing 1 thing? Well it turns out the kit I ordered didn’t include the standoffs or screws to properly connect the Rainbow Hat.
After some initial disappointment, I regrouped and realized it really wasn’t a big deal at the moment because my goal was to keep things simple (for me) and initially avoid as much of the hardware aspect as possible.
Without the Rainbow Hat it was still perfectly possible to flash Android Things and install a simple UI-based app.
After that little hiccup, I was able to finish assembling the hardware and had wifi, a camera and a touchscreen display to play with.
Hardware Assembly Notes
While connecting the hardware a couple of things stood out to me.
Properly connecting the wifi antenna required a lot more force than I anticipated. It’s made worse by the fact that the connection point is quite small.
Connecting the ribbon cables for the camera and screen was both delicate and lacked feedback. Releasing the lock that allows you to insert the cable required very little force (especially compared to the antenna) and when you slide in the cable there wasn’t really any “click” or other feedback that it was connected properly. I just slid the connection until it seemed like it wouldn’t go any further then re-secured the locking mechanism.
The ribbon cable and power cable for the screen both have to be twisted a bit to get everything connected properly. You can kind of see it in the photos above. I was a little worried at first, but after several days like that everything still works fine.
Installing Android Things
After assembling the components, it was time to install Android Things to the board.
You can do this 2 ways. The easy way… or the hard way. (It’s not really hard, but it is more involved).
The “hard” way includes creating your own custom image based on your specific board and product details. Since this is more geared towards the later stages of prototyping & later development, you can probably safely ignore this for now. I accidentally went down this route initially, and it’s definitely more straightforward to use the easy way.
The “easy” way lets the Android Things Setup Utility do the work for you
These instructions follow the easy way, and make the install process pretty smooth
Once the setup utility is executed, it will walk you through the setup process in several steps. The following screenshots show several of the key points of the process.
First you are asked to choose what you want to do, and what board you are working with
Once the image has been flashed, you’re prompted to setup the wifi.
After flashing the image and setting up the wifi, I had Android Things running on my device.
Looks like #android to me !! Seems like a good sign
How to Build & Deploy?
Create a new project
Creating a new Android Things project is very straightforward.
- Start a new project
- Select Android Things as the desired form factor
- In my case, I wanted a UI so I selected “Android Things Empty Activity”
- Click “Next” and my project was ready
At this point, I was back in familiar territory.
Since the project creation tools set everything up for me, I didn’t have to worry about what went on under the hood to work with Android Things. However, I was curious anyways and noticed a few things.
The Android Things dependency was automatically added to the
The manifest had 2 items of interest
- an intent filter to handle
The full explanation for these can be found here. In short, the
IOT_LAUNCHER category on the intent filter indicates which activity should be launched when run on an IOT device, and the
uses-library declaration makes the Android Things library available at runtime.
Building Hello World
From here, building a Hello World UI application for Android Things was no different than for a phone/tablet once the initial project setup was finished.
I kept this very simple and added a single button that, when tapped, showed a “Hello World” toast.
Once the code was ready, I deployed the project like I would to a phone/tablet and my new app was running on my personally constructed Android Things hardware.
Right now it’s not very exciting, but the code can be found on GitHub
HelloAndroidThings – Hello World sandbox for discovering Android Thingsgithub.com
I have a lot of ideas for what I want to build, but I also recognize that I have a lot to learn.
Before going much further with additional projects, I’m going to take a bit of a step back and learn a bit about the basics of working with electronics and how I might go about connecting further peripherals in the future.
If you’re a novice in this area like me, then look for my future post on what I find. Hopefully we can learn together.
While I was getting started, I found a number of resources really useful and wanted to include them here
Macy Kuang has some nice posts and videos about how to start working with Android Things
Dave Smith has a very nice, high-level overview of the Android Things platform. This is a great place to start if you have no idea what Android Things is.