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

Android Things - The IoT platform for everyone - App Builders Switzerland

Android Things - The IoT platform for everyone - App Builders Switzerland

Presented at App Builders Switzerland - 25 April 2017

Internet Of Things on Android!

2a37bf1e025cc1523124774c760df91a?s=128

Rebecca Franks

April 25, 2017
Tweet

Transcript

  1. The IoT platform for everyone #appbuilders17 @riggaroo

  2. Android Engineering Lead at Dynamic Visual Technologies Google Developer Expert

    for Android & Internet of Things riggaroo.co.za @riggaroo Rebecca Franks
  3. What is Android Things?

  4. Android Things is an extension of the Android platform for

    IoT and embedded devices.
  5. Cameras
 Gateways
 HVAC Control
 Smart Meters Point of Sale
 Inventory

    Control
 Interactive Ads
 Vending Machines Security Systems
 Smart Doorbells
 Routers
 Energy Monitors Asset Tracking
 Fleet Management
 Driver Assist
 Predictive Service Ideal for powerful, intelligent devices that need to be secure.
  6. Android Things for Developers

  7. How is Android Things different? Android Studio Android SDKs &

    Developer Tools Firebase Libraries Google Cloud Platform SDKs Any other compatible Android/Java libraries...
  8. None
  9. Development Boards

  10. None
  11. None
  12. Displays are Optional

  13. Consider Alternate UI

  14. Cons • Only in developer preview • Known issues -

    hardware graphics acceleration is off etc • Weave not yet available for Android Things • Very new platform – not many samples • A bit slow for things that need precise timing • Not open source yet (?)
  15. Electronics for Software Developers

  16. Electronic Components Breadboard - Construction base for prototyping electronics Jumper

    Wire - Used to interconnect the components of a breadboard
  17. LEDs - Emits visible light when an electric current passes

    through it Push Switches - Allows electricity to flow between its two contacts Electronic Components
  18. Resistor -Used to reduce current flow Source: http://www.electronicshub.org/resistor-color-code/ Electronic Components

    and many more...
  19. Electronic Components Raspberry Pi Rainbow HAT • Seven APA102 multicolor

    LEDs • Four 14-segment alphanumeric displays (green LEDs) • HT16K33 display driver chip • Three capacitive touch buttons • Atmel QT1070 capacitive touch driver chip • Blue, green, and red LEDs • BMP280 temperature and pressure sensor • Piezo buzzer • Breakout pins for servo, 12C, SPI, and UART (all 3v3)
  20. 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.023A V = 5V R = 5V / 0.023A R = ± 217 ohms
  21. Pinout Diagrams

  22. Hardware Integration on Android Things GPIO PWM I2C SPI UART

    Peripheral I/O COMPLEX EASY! https://github.com/androidthings/contrib-drivers Button PWM Servo RGB LED Strip GPS Temperature Sensor Capacitive touch buttons Github - Peripheral Driver Library
  23. Let’s build an App

  24. Circuit Setup – LED button control

  25. In case of emergency

  26. • 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
  27. <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
  28. 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'
  29. //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
  30. 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
 }
 //..
 });
  31. Demo

  32. Other Examples

  33. https://github.com/riggaroo/android-things-distributed-piano Distributed Piano - Google Nearby API

  34. https://github.com/riggaroo/android-things-electricity-monitor Firebase Realtime Database Electricity Monitor

  35. 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 – Companion App – onDisconnect()
  36. Electricity Monitor – Cloud Functions on Firebase const functions =

    require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); exports.sendPowerNotification = functions.database.ref("/online").onWrite((event) => { }); const data = event.data; if (!data.changed()) { return; } const onOff = data.val() ? "on": "off"; const payload = { notification: { body: `Your electricity is now ${onOff}` } }; return admin.messaging().sendToTopic("Power_Notifications", payload, ..);
  37. https://github.com/androidthings/sample-tensorflow-imageclassifier TensorFlow Offline Image Classifier

  38. None
  39. Rebecca Franks riggaroo.co.za @riggaroo Google's IoT Developers Community https://g.co/iotdev Google's

    IoT Solutions https://iot.google.com Android Things SDK https://developer.android.com/things
  40. • 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