Build your own Google Home using - … your ow… · Requirement 1: The Board (any one)...

49

Transcript of Build your own Google Home using - … your ow… · Requirement 1: The Board (any one)...

Page 1: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or
Page 2: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

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

Page 3: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

THE ANDROID FOR IOT ARCHITECTURE

Page 4: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Familiar Android Stack

Page 5: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Android Things High Level Overview

Page 6: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

WHAT BRILLO HAD PROMISED US ?

Page 7: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

What part is used from Android ?

Page 8: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

What part is used from Android ?

Page 9: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

HOW ANDROID THINGS FINALLY PANNED OUT

Page 10: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

The full Android Stack

Page 11: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

What is present on Android Things

Page 12: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

PREPARING FOR THE ANDROID THINGS ADVENTURE

Page 13: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

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

Page 14: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Requirement 2: Lights and Buttons

• 1xLED + 1xButton + Breadboard + Resistors

• Or, get a Rainbow Hat

Page 15: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Requirement 3: Audio (In & Out)

• Speaker + Mic (if needed, use a 2 to 1 plug)

• Protip: Search for “office conference room speakerphones”

Page 16: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

GET YOUR OPERATING SYSTEM

Page 17: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Go to “Android Things Console”

LOL ! Google SEO Fail :P

Page 18: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Create a new product

there

Page 19: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Select your board

Page 20: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Create new factory image

Page 21: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Flash it

• For NXP devices, fastboot flash (like you flash Nexus/Motorola devices)

• For Raspberry, flash SD Card with Etcher

Page 22: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

WRITING ANDROID THINGS APPS

Page 23: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Tell Gradle that this is Android Things

Page 24: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Usually you’d want your app to be default and only app

Page 25: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

What not to use ?

Page 26: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Supported Google APIs

Page 27: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Unsupported Google APIs

Page 28: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Wait a sec . . . Runtime permissions ?

• Normal Permissions = At install time

• Dangerous Permissions = After device reboot

• No runtime dialog boxes (duh, no display)

Page 29: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Cloud IOT Core = The Firebase for Android Things

Page 30: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

LET’S TAKE AN ELECTRONICS CLASS

Page 31: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

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)

Page 32: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

GPIO: Active High vs Active Low

Page 33: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

PWM: Analog using Digital

Page 34: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

BUTTONS AND LIGHTS

Page 35: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

The Button driver

Page 36: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Using the Button

Page 37: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Using the Button

Page 38: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Lighting up LED via GPIO

Page 39: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

THE GOOGLE ASSISTANT API

Page 40: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

https://developers.google.com/assistant/sdk/reference/rpc/

Page 41: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or
Page 42: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or
Page 43: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

DEMO

Page 44: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or
Page 45: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or
Page 46: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

Links and Resources

• https://github.com/androidthings

• https://github.com/championswimmer/google_assistant_iot (This project I demoed)

• My Slides: https://speakerdeck.com/championswimmer

Page 47: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

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

Page 48: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

@championswimmer [email protected]

Page 49: Build your own Google Home using - … your ow… · Requirement 1: The Board (any one) •Raspberry Pi 3 •NXP Pico MX6 •NXP Pico MX7 (Recommend this) •Intel Edison •… or

@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!