Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

THE ANDROID FOR IOT ARCHITECTURE

Slide 3

Slide 3 text

Familiar Android Stack

Slide 4

Slide 4 text

Android Things High Level Overview

Slide 5

Slide 5 text

WHAT BRILLO HAD PROMISED US ?

Slide 6

Slide 6 text

What part is used from Android ?

Slide 7

Slide 7 text

What part is used from Android ?

Slide 8

Slide 8 text

HOW ANDROID THINGS FINALLY PANNED OUT

Slide 9

Slide 9 text

The full Android Stack

Slide 10

Slide 10 text

What is present on Android Things

Slide 11

Slide 11 text

PREPARING FOR THE ANDROID THINGS ADVENTURE

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

Requirement 2: Lights and Buttons • 1xLED + 1xButton + Breadboard + Resistors • Or, get a Rainbow Hat

Slide 14

Slide 14 text

Requirement 3: Audio (In & Out) • Speaker + Mic (if needed, use a 2 to 1 plug) • Protip: Search for “office conference room speakerphones”

Slide 15

Slide 15 text

GET YOUR OPERATING SYSTEM

Slide 16

Slide 16 text

Go to “Android Things Console” LOL ! Google SEO Fail :P

Slide 17

Slide 17 text

Create a new product there

Slide 18

Slide 18 text

Select your board

Slide 19

Slide 19 text

Create new factory image

Slide 20

Slide 20 text

Flash it • For NXP devices, fastboot flash (like you flash Nexus/Motorola devices) • For Raspberry, flash SD Card with Etcher

Slide 21

Slide 21 text

WRITING ANDROID THINGS APPS

Slide 22

Slide 22 text

Tell Gradle that this is Android Things

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

What not to use ?

Slide 25

Slide 25 text

Supported Google APIs

Slide 26

Slide 26 text

Unsupported Google APIs

Slide 27

Slide 27 text

Wait a sec . . . Runtime permissions ? • Normal Permissions = At install time • Dangerous Permissions = After device reboot • No runtime dialog boxes (duh, no display)

Slide 28

Slide 28 text

Cloud IOT Core = The Firebase for Android Things

Slide 29

Slide 29 text

LET’S TAKE AN ELECTRONICS CLASS

Slide 30

Slide 30 text

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)

Slide 31

Slide 31 text

GPIO: Active High vs Active Low

Slide 32

Slide 32 text

PWM: Analog using Digital

Slide 33

Slide 33 text

BUTTONS AND LIGHTS

Slide 34

Slide 34 text

The Button driver

Slide 35

Slide 35 text

Using the Button

Slide 36

Slide 36 text

Using the Button

Slide 37

Slide 37 text

Lighting up LED via GPIO

Slide 38

Slide 38 text

THE GOOGLE ASSISTANT API

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

DEMO

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

Links and Resources • https://github.com/androidthings • https://github.com/championswimmer/googl e_assistant_iot (This project I demoed) • My Slides: https://speakerdeck.com/championswimmer

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

@championswimmer [email protected]