Android Things - The IoT platform for everyone.

47
Rebecca Franks riggaroo.co.za @riggaroo The IoT platform for everyone

Transcript of Android Things - The IoT platform for everyone.

Page 1: Android Things - The IoT platform for everyone.

Rebecca Franksriggaroo.co.za

@riggaroo

TheIoTplatformforeveryone

Page 2: Android Things - The IoT platform for everyone.

Hello

Rebecca Franks

Android Engineering Lead at Dynamic Visual Technologies

Google Developer Expert for Android

riggaroo.co.za

@riggaroo

Page 3: Android Things - The IoT platform for everyone.

Expectation vs Reality

Page 4: Android Things - The IoT platform for everyone.
Page 5: Android Things - The IoT platform for everyone.
Page 6: Android Things - The IoT platform for everyone.

What is Android Things?

Page 7: Android Things - The IoT platform for everyone.

Android Things is an extension of the Android platform for IoT and embedded devices.

Page 8: Android Things - The IoT platform for everyone.

CamerasGatewaysHVAC ControlSmart Meters

Point of SaleInventory ControlInteractive AdsVending Machines

Security SystemsSmart DoorbellsRoutersEnergy Monitors

Asset TrackingFleet ManagementDriver AssistPredictive Service

Ideal for powerful, intelligent devices that need to be secure.

Page 9: Android Things - The IoT platform for everyone.

How is Android Things different?

Android Studio

Android SDKs& Developer Tools

Firebase Libraries

Google Cloud Platform SDKs

Any other compatible Android/Java libraries...

Page 10: Android Things - The IoT platform for everyone.

IoT Developer Console

Automatic Security Updates

Signed Images Verified Boot

Easy and Secure Deployment

Page 11: Android Things - The IoT platform for everyone.

SoMArchitecture

Google Managed BSP

Scaling to Production

Page 12: Android Things - The IoT platform for everyone.

Android Things for Developers

Page 13: Android Things - The IoT platform for everyone.
Page 14: Android Things - The IoT platform for everyone.
Page 15: Android Things - The IoT platform for everyone.

Displays are Optional

Consider Alternate UI

Page 16: Android Things - The IoT platform for everyone.

Cons

● Only Dev Preview

● Weave not yet available for Android Things

● Very new - Not many examples online - mostly Python

● Some APIs not supported - ie hardwareAcceleration

● Closed Source

Page 17: Android Things - The IoT platform for everyone.

Electronics Basics

Page 18: Android Things - The IoT platform for everyone.

Components

Breadboard - Construction base for prototyping electronics

Jumper Wire - Used to interconnect the components of a breadboard

Page 19: Android Things - The IoT platform for everyone.

LEDs - Emits visible light when an electric current passes through it

Push Switches - Allows electricity to flow between its two contacts

Components

Page 20: Android Things - The IoT platform for everyone.

Resistor -Used to reduce current flow

Source: http://www.electronicshub.or g/resistor-color-code/

Components

and many more...

Page 21: Android Things - The IoT platform for everyone.

Ohm’s Law

The current through a conductor between two points is directly proportional to the voltage across the two points.

V = I * R V is Voltage (volts)I is Current (amps) R is Resistance (ohms)

I = 0.023AV = 5V

R = 5V / 0.023A R = ± 217 ohms

Page 22: Android Things - The IoT platform for everyone.

Building an Android Things app

Page 23: Android Things - The IoT platform for everyone.

Pinout Diagram

Page 24: Android Things - The IoT platform for everyone.

Fritzing Diagrams

Page 25: Android Things - The IoT platform for everyone.

Integrating with Hardware

GPIO

PWM

I2C

SPI

UART

Input

Sensors

GPS

Peripheral Driver

Library

Peripheral I/O

User Drivers

Page 26: Android Things - The IoT platform for everyone.

Let’s try live coding..

Page 27: Android Things - The IoT platform for everyone.

In case of emergency

Page 28: Android Things - The IoT platform for everyone.

● A Raspberry Pi 3 or alternative - Running Android Things

● Create standard project in Android Studio

● Add to app level build.gradle:

provided 'com.google.android.things:androidthings:...'

Getting Started

Page 29: Android Things - The IoT platform for everyone.

<application ...>

<uses-library android:name="com.google.android.things"/>

<activity ...>

...

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

</application>

AndroidManifest.xml

Page 30: Android Things - The IoT platform for everyone.

Button button = new Button("BCM6", Button.LogicState.PRESSED_WHEN_LOW);

button.setOnButtonEventListener(new Button.OnButtonEventListener() {

@Override

public void onButtonEvent(final Button button, final boolean pressed) {

//...

Log.i(TAG, "Button value changed:" + pressed);

ledGpio.setValue(pressed);

}

});

Button Press

compile 'com.google.android.things.contrib:driver-button:0.2'

Page 31: Android Things - The IoT platform for everyone.

//get access to the pin

PeripheralManagerService service = new PeripheralManagerService();

ledGpio = service.openGpio("BCM6");

ledGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);

ledGpio.setValue(true);

//remember to close the peripheral

ledGpio.close();

Turn on an LED

Page 32: Android Things - The IoT platform for everyone.

Turn it on or off using Firebase Realtime DB

FirebaseDatabase.getInstance().getReference("ledKitchen")

.addValueEventListener(new ValueEventListener() {

@Override

public void onDataChange(final DataSnapshot dataSnapshot) {

Boolean value = (Boolean) dataSnapshot.getValue();

ledGpio.setValue(value);

//.. handle exceptions

}

//..

});

Page 33: Android Things - The IoT platform for everyone.

Demo

Page 34: Android Things - The IoT platform for everyone.

Other Examples

Page 35: Android Things - The IoT platform for everyone.

https://github.com/riggaroo/android-things-distributed-piano

Distributed Piano

Page 36: Android Things - The IoT platform for everyone.

https://github.com/riggaroo/android-things-electricity-monitor

Firebase Realtime Database

Electricity Monitor

Page 37: Android Things - The IoT platform for everyone.

final DatabaseReference onlineRef = firebaseDatabase.child(".info/connected");

final DatabaseReference isPowerOnRef = firebaseDatabase.child("/online");

onlineRef.addValueEventListener(new ValueEventListener() {

@Override

public void onDataChange(final DataSnapshot dataSnapshot) {

if (dataSnapshot.getValue(Boolean.class)) {

isPowerOnRef.setValue(true);

isPowerOnRef.onDisconnect().setValue(false);

}

}

//..

});

Electricity Monitor - Firebase

Page 38: Android Things - The IoT platform for everyone.

https://github.com/androidthings/sample-tensorflow-imageclassifier

Image Classifier

Page 39: Android Things - The IoT platform for everyone.
Page 40: Android Things - The IoT platform for everyone.
Page 41: Android Things - The IoT platform for everyone.
Page 42: Android Things - The IoT platform for everyone.
Page 43: Android Things - The IoT platform for everyone.
Page 44: Android Things - The IoT platform for everyone.

Image Classifier

Page 45: Android Things - The IoT platform for everyone.

Rebecca Franksriggaroo.co.za@riggaroo

Google's IoT Developers Communityhttps://g.co/iotdev

Google's IoT Solutionshttps://iot.google.com

Android Things SDKhttps://developer.android.com/things

Page 46: Android Things - The IoT platform for everyone.

Rebecca Franksriggaroo.co.za@riggaroo

www.devconf.co.za/rate

Page 47: Android Things - The IoT platform for everyone.

● https://www.myelectronicslab.com/tutorial/raspberry-pi-3-gpio-model-b-block-pinout/

● https://developers.google.com/weave/● https://techcrunch.com/2015/10/24/why-iot-security-is-so-critical/● https://github.com/androidthings/sample-simplepio/● https://developer.android.com/things/index.html● https://github.com/riggaroo/android-things-electricity-monitor● https://github.com/riggaroo/android-things-distributed-piano● https://github.com/riggaroo/android-things-button-examples

Links & References