Build your own Google Home using Raspberry Pi and Android Things
A powerful electronics platform running the familiar
Android stack with full Java API support
Arnav Gupta Co-Founder & Android Mentor @ Coding Blocks
THE ANDROID FOR IOT ARCHITECTURE
Familiar Android Stack
Android Things High Level Overview
WHAT BRILLO HAD PROMISED US ?
What part is used from Android ?
What part is used from Android ?
HOW ANDROID THINGS FINALLY PANNED OUT
The full Android Stack
What is present on Android Things
PREPARING FOR THE ANDROID THINGS ADVENTURE
Requirement 1: The Board (any one)
• Raspberry Pi 3
• NXP Pico MX6
• NXP Pico MX7 (Recommend this)
• Intel Edison
• … or crack open an old Android phone you’re not using :P
Requirement 2: Lights and Buttons
• 1xLED + 1xButton + Breadboard + Resistors
• Or, get a Rainbow Hat
Requirement 3: Audio (In & Out)
• Speaker + Mic (if needed, use a 2 to 1 plug)
• Protip: Search for “office conference room speakerphones”
GET YOUR OPERATING SYSTEM
Go to “Android Things Console”
LOL ! Google SEO Fail :P
Create a new product
there
Select your board
Create new factory image
Flash it
• For NXP devices, fastboot flash (like you flash Nexus/Motorola devices)
• For Raspberry, flash SD Card with Etcher
WRITING ANDROID THINGS APPS
Tell Gradle that this is Android Things
Usually you’d want your app to be default and only app
What not to use ?
Supported Google APIs
Unsupported Google APIs
Wait a sec . . . Runtime permissions ?
• Normal Permissions = At install time
• Dangerous Permissions = After device reboot
• No runtime dialog boxes (duh, no display)
Cloud IOT Core = The Firebase for Android Things
LET’S TAKE AN ELECTRONICS CLASS
Basic Electronics supported
• GPIO – Digital Inputs and Outputs
• PWM – (Fake) Analog Inputs and Outputs
• Serial Communication
– I2C (Synchronous, Low Speed, 2-wire)
– SPI (Synchronous, HighSpeed, multi-wire)
– UART (Asynchronous, Only 1 peripheral)
GPIO: Active High vs Active Low
PWM: Analog using Digital
BUTTONS AND LIGHTS
The Button driver
Using the Button
Using the Button
Lighting up LED via GPIO
THE GOOGLE ASSISTANT API
https://developers.google.com/assistant/sdk/reference/rpc/
DEMO
Links and Resources
• https://github.com/androidthings
• https://github.com/championswimmer/google_assistant_iot (This project I demoed)
• My Slides: https://speakerdeck.com/championswimmer
Weighing Pros and Cons of Android Things
• We get > 50% of powerful Android Stack
• Code sharing with Android applications
• Easier to attach ad-hoc UI
• Future: Easy delivery via Play Store
• Google Backing (duh!)
• Uses a lot of resources (vs Linux Kernel + C/Cpp bin)
• Dodgy async and multi-threading (electronics are always sync)
• Can make similar projects using JS libs in < 5% code
• High code complexity trap
@championswimmer [email protected]
@greatindiandev bit.ly/gidslinkedin www.developersummit.com
Conference and Deep Dive Sessions
April 24-28, IISc Bangalore
TM
2018
Register early and get the best discounts!