Getting Started with Android Things
Basically, Android Things refers to the summation of Android and the Internet of Things. IoT is very autonomous it means the Internet of Things, whatever the IoT device is, it can sense through sensors and do its respective task without very much human interaction and Android Things revolves around IoT devices. For IoT devices, sensors play the most important role in sending and analyzing data into the cloud. It comes with the idea that any device which we use in our daily life can be connected to the Internet. Now, to build those products there has to be an element of computing power inside those devices and there we need a computer, a chip, and an Operating System which have internet connectivity so there come Android Things. Google has made it very easy for software to connect with the hardware by releasing Android Things OS. Anyone who has knowledge of android and java can use it to build IoT devices to connect the hardware to the internet and get the task done.
Getting Started with Android Things
Get the board and flash Android Things into the board, you can choose from the following:
- Raspberry Pi 3: It uses a quad-core cortex a53 chip at 64 bit.
- Intel Edison: It uses an Intel x86 chip.
- NXP Pico: It uses a cortex a7 based chip.
- Peripherals: Includes a breadboard, resistor, jumper wire, LED, switch, etc.
- A Rainbow HAT: for Android Things
- Power Supply: with a minimum of a 5volt.
- SD card
While there are many boards available in the market but in this article, we will mainly focus on Raspberry Pi 3 because it is very reliable.
1. Assembling the Hardware:
Plug the Rainbow HAT into your Raspberry Pi. Make sure the pins are lined up and not off by one row. and then connect it to the power supply.
2. Installing Android Things:
- Visit Android things Console using Google or any web Browser.https://partner.android.com/things/console/u/0/?hl=pt-br&pli=1#/
- Select tools from the menu in the top-left corner.
- Now, click on the download button to download the setup utility tool.
- Now, unzip the downloaded file and choose according to your environment (Windows, Linux, or Mac).
- Open Terminal and navigate to that downloaded folder and then mount an SD card. Now run the script, for example in mac OS
- Some options will flash on your terminal screen. Choose Option one to install Android Things.
- Select the Hardware you are using.
- Now you’ll see an option that allows you to choose a custom image or default image, for beginners use the default image. The default image will be downloaded.
- As soon as you download the image, make sure to plug in your SD card and then press enter. Select the drive by using arrow keys and press Enter. Type y to confirm your selection and press Enter. The image will be copied into your SD card.
- Once it’s completed, it’ll say Setup Complete. Type n in the terminal to select that you don’t want to set up the Wi-Fi. You’ll connect the board to the Wi-Fi later. You can safely eject the SD card from the computer now.
For Raspberry Pi, you will need an HDMI monitor, an HDMI cable, and a mouse. Follow the steps:
- Insert your SD card into the Raspberry pi board and connect your external monitor to the board via the HDMI cable. Now, connect your mouse to a USB port and make sure the board is connected to the power supply.
- Click Continue.
- You will see the option for pairing.
- Install the Android Things toolkit app (companion app) on your android phone from the Google play store. After installing open it.
- Set up your account and accept the terms.
- And then tap on pair your device, and then pair your device using the code that will be flashed on your monitor screen.
- Select on Wi-Fi network and connect it to your Wi-Fi network using its password.
- After that you can test the peripherals like Rainbow Hat etc.
- Click Finish.
- After this, a screen will pop up tap on NOT NOW.
- In your Monitor, in the network section, there will be your saved network to which you are connected and the IP address.
- Open terminal and type the following command
adb connect ip-address # your ip address
You will be connected to the internet.
4. Exploring Android Things Projects:
Update your SDK tools. Import Things library. Android Things library will be included and the android manifest file will already be updated with the IOT_LAUNCHER intent filter so that it launches automatically on boot.
and in android manifest
<activity android:name=”.ButtonActivity”> <intent-filter> <action android:name=”android.intent.action.MAIN” /> <category android:name=”android.intent.category.LAUNCHER” /> </intent-filter> <! — Launch activity automatically on boot → <intent-filter> <action android:name=”android.intent.action.MAIN”/> <category android:name=”android.intent.category.IOT_LAUNCHER”/> <category android:name=”android.intent.category.DEFAULT”/> </intent-filter> </activity>
5. Communication with Hardware:
Android Things helps in communicating between the peripherals I/O API and the sensors and the actuators.