Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Your own Google Home with Android Things on Raspberry Pi

Arnav Gupta
October 05, 2017

Your own Google Home with Android Things on Raspberry Pi

Using Android Things (0.5.1 dev preview) and gRPC Android Assistant API to build your own Google Home clone

Arnav Gupta

October 05, 2017
Tweet

More Decks by Arnav Gupta

Other Decks in Technology

Transcript

  1. 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

    View full-size slide

  2. THE ANDROID FOR IOT
    ARCHITECTURE

    View full-size slide

  3. Familiar Android Stack

    View full-size slide

  4. Android Things High Level Overview

    View full-size slide

  5. WHAT BRILLO HAD PROMISED US ?

    View full-size slide

  6. What part is used from Android ?

    View full-size slide

  7. What part is used from Android ?

    View full-size slide

  8. HOW ANDROID THINGS FINALLY
    PANNED OUT

    View full-size slide

  9. The full Android Stack

    View full-size slide

  10. What is present on Android Things

    View full-size slide

  11. PREPARING FOR THE ANDROID
    THINGS ADVENTURE

    View full-size slide

  12. 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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  15. GET YOUR OPERATING SYSTEM

    View full-size slide

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

    View full-size slide

  17. Create a new product
    there

    View full-size slide

  18. Select your board

    View full-size slide

  19. Create new factory image

    View full-size slide

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

    View full-size slide

  21. WRITING ANDROID THINGS APPS

    View full-size slide

  22. Tell Gradle that this is Android Things

    View full-size slide

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

    View full-size slide

  24. What not to use ?

    View full-size slide

  25. Supported Google APIs

    View full-size slide

  26. Unsupported Google APIs

    View full-size slide

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

    View full-size slide

  28. Cloud IOT Core = The Firebase for
    Android Things

    View full-size slide

  29. LET’S TAKE AN ELECTRONICS CLASS

    View full-size slide

  30. 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)

    View full-size slide

  31. GPIO: Active High vs Active Low

    View full-size slide

  32. PWM: Analog using Digital

    View full-size slide

  33. BUTTONS AND LIGHTS

    View full-size slide

  34. The Button driver

    View full-size slide

  35. Using the Button

    View full-size slide

  36. Using the Button

    View full-size slide

  37. Lighting up LED via GPIO

    View full-size slide

  38. THE GOOGLE ASSISTANT API

    View full-size slide

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

    View full-size slide

  40. 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

    View full-size slide

  41. 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

    View full-size slide