SlideShare a Scribd company logo
Using Android Things
to Detect &
Exterminate
Reptilians
Android is
EVERYWHERE (01)
(01)
Reptilians too are everywhere, but they suck.
Using Android Things to Detect & Exterminate Reptilians
Android Things
"If you can build an
app, you can build a
device!"
8-bit Distributed Piano (02)
(02)
https://riggaroo.co.za/android-things-building-distributed-piano/
Play Music Like a Scientist
Beer Can Music Player (03)
(03)
http://nilhcem.com/android-things/discovering-the-I2C-api-creating-a-capacitive-sensor-driver
Notification Cat (04)
(04)
http://nilhcem.com/android-things/bluetooth-low-energy
Google Assistant powered Robot
(05)
(05)
http://nilhcem.com/android-things/create-your-google-assistant-robots
OK, BUT, WHY?
I mean... I can use an Arduino too
Perfect for
• Doing some computation locally
• Using Google Services
• A secure platform
• Prototype and production
Perfect for
• Doing some computation locally
• Using Google Services
• A secure platform
• Prototype and production
Perfect for
• Doing some computation locally
• Using Google Services
• A secure platform
• Prototype and production
Perfect for
• Doing some computation locally
• Using Google Services
• A secure platform
• Prototype and production
Compatible boards (06)
• Raspberry Pi 3
• NXP i.MX7D/i.MX6UL
• Intel Edison/Joule (discontinued)
(06)
https://developer.android.com/things/hardware/developer-kits.html
Raspberry Pi 3 - NXP i.MX7D
Using Android Things to Detect & Exterminate Reptilians
SOM (System on module)
SOM (System on module)
Edison Candle (07)
(07)
https://github.com/androidthings/edison-candle
SOMs are pre-certified for
regulator approvals
Perfect for
• Doing some computation locally
• Using Google Services
• A secure platform
• Prototype and production
Facts
• Humans don't use their brain to its full capacity
• Humans are distracted by media, entertainment, and
politics.
• Borders, country lines lead to endless wars and conflicts
Reason?
REPTILIANS
Reptilian conspiracy theory (08)
(08)
https://www.theatlantic.com/national/archive/2013/04/12-million-americans-believe-lizard-people-run-our-country/
316706/
Reptilian
• Altered our DNA so we don't fully use our brain
• Control humans with media / politics
• Have, through the generations, ruled the world
Using Android Things
to Detect &
Exterminate
Reptilians
Detect
TensorFlow (09)
(09)
http://nilhcem.com/android/custom-tensorflow-classifier
TensorFlow codelabs
• TensorFlow for Poets (10)
• TensorFlow for Poets 2: Optimize for Mobile (11)
• Android Things Image Classifier (12)
(12)
https://codelabs.developers.google.com/codelabs/androidthings-classifier/index.html
(11)
https://codelabs.developers.google.com/codelabs/tensorflow-for-poets-2/
(10)
https://codelabs.developers.google.com/codelabs/tensorflow-for-poets/
Inception v3
• Deep learning model for image recognition
• Transfer learning
Gather lots of images
Using Android Things to Detect & Exterminate Reptilians
Transfer learning
python tensorflow/examples/image_retraining/retrain.py 
--bottleneck_dir=~/tf_files/bottlenecks 
--how_many_training_steps 4000 
--model_dir=~/tf_files/inception 
--output_graph=~/tf_files/retrained_graph.pb 
--output_labels=~/tf_files/retrained_labels.txt 
--image_dir ~/tf_files/reptilians
Generated files
• retrained_graph.pb
• retrained_labels.txt
Generated files
$ cat retrained_labels.txt
human
reptile
reptilian
Mobile model optimizations
python tensorflow/python/tools/optimize_for_inference.py 
--input=~/tf_files/retrained_graph.pb 
--output=~/tf_files/optimized_graph.pb 
--input_names="Mul" 
--output_names="final_result"
TensorFlow Android Classify
sample (13)
(13)
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android
TensorFlow Inference
val inferenceInterface = TensorFlowInferenceInterface(getAssets(), MODEL_FILE)
val labels = loadLabels() // [ "reptilian", "reptile", "human" ]
fun doRecognize(image: Bitmap) {
val pixels = image.toPixelsArray()
inferenceInterface.feed(INPUT_NODE, pixels, NETWORK_STRUCTURE)
inferenceInterface.run(arrayOf(OUTPUT_NODE))
val outputs = FloatArray(labels.size)
inferenceInterface.fetch(OUTPUT_NODE, outputs)
}
TensorFlow Inference
labels = [ "reptilian", "reptile", "human" ]
outputs = [ 0.0098f , 0.0039f , 0.9863f ]
Test data
Using Android Things to Detect & Exterminate Reptilians
Using Android Things to Detect & Exterminate Reptilians
Using Android Things to Detect & Exterminate Reptilians
Using Android Things to Detect & Exterminate Reptilians
AndroidManifest.xml
<application>
<uses-library android:name="com.google.android.things" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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>
MainActivity
class MainActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
"Hi! I use RelativeLayouts, lol"
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:src="@drawable/background"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:src="@drawable/reptilian"
android:layout_width="280dp"
android:layout_height="224dp"
android:layout_gravity="bottom|center_horizontal" />
</FrameLayout>
Using Android Things to Detect & Exterminate Reptilians
"Layouts are dusty"
build.gradle
dependencies {
compileOnly 'com.google.android.things:androidthings:0.5.1-devpreview'
}
Peripheral I/O APIs
Arduino Starter Kit
Peripheral I/O APIs (14)
• GPIO
• PWM
• I²C
• I²S
• SPI
• UART
(14)
https://developer.android.com/things/sdk/pio/index.html
Using Android Things to Detect & Exterminate Reptilians
Blinking LEDs
Using Android Things to Detect & Exterminate Reptilians
val pioService = PeripheralManagerService()
val ledGpio = pioService.openGpio("BCM4")
Magic happens here
ledGpio.value = true
Thread.sleep(1000)
ledGpio.value = false
LEDs (15)
(15)
https://fullmoonwanderer.deviantart.com/art/Reptilian-LED-resin-eyes-552330846
PeripheralManagerService
fun openGpio(…): Gpio
fun openPwm(…): Pwm
fun openSpiDevice(…): SpiDevice
fun openUartDevice(…): UartDevice
fun openI2cDevice(…): I2cDevice
fun openI2sDevice(…): I2sDevice
fun writeBuffer(device: I2cDevice, data: ByteArray) {
device.write(data, data.size)
}
Drivers are standard
Android libraries (16)
(17)
(17)
https://github.com/amitshekhariitbhu/awesome-android-things
(16)
https://github.com/androidthings/contrib-drivers
Using Android Things to Detect & Exterminate Reptilians
Using Android Things to Detect & Exterminate Reptilians
Using Android Things to Detect & Exterminate Reptilians
build.gradle
compile 'com.google.android.things.contrib:driver-ssd1306:0.4'
MainActivity.kt
val display = Ssd1306("I2C1")
display.setPixel(x = 0, y = 0, on = true)
val display = Ssd1306("I2C1")
val bmp = BitmapFactory.decodeResource(resources, R.drawable.background)
BitmapHelper.setBmpData(display, 0, 0, bmp, false)
display.show()
Using Android Things to Detect & Exterminate Reptilians
Android Things
TensorFlow Sample
(18)
(18)
https://github.com/androidthings/sample-tensorflow-imageclassifier
Camera
Cucumbers (?!?) (19)
(19)
https://cloud.google.com/blog/big-data/2016/08/how-a-japanese-cucumber-farmer-is-using-deep-learning-and-
tensorflow
Detect when
someone is
approaching
Ultrasonic Sensor (HC-SR04)
Ultrasonic Sensor
(HC-SR04)
1. Trigger
2. Echo
No Android Things
compatible drivers
Arduino to the rescue
Arduino to the rescue
Arduino to the rescue
void loop() {
distance = getDistanceInCentimeters();
Serial.println(distance);
delay(1000);
}
Arduino to the rescue
Read data from USB (20)
Hcsr04LiveData(this)
.observe({lifecycle}) { distanceInCm ->
Log.i(TAG, "Distance (cm): $distanceInCm")
}
(20)
https://github.com/Nilhcem/usbfun-androidthings
Using Android Things to Detect & Exterminate Reptilians
HC-SR04
Hcsr04LiveData(this)
.observe({lifecycle}) { distanceInCm ->
if (distanceInCm < 25) {
takePicture()
}
}
git commit -m "Kill reptilian when detected"
if (detected.isReptilian()) {
exterminate()
}
Exterminate
Option #1: Gun
Servo motor
Servo motor
Servo motor
PWM servo
compile 'com.google.android.things.contrib:driver-pwmservo:0.3'
Moving the servo
val servo = Servo("PWM0")
servo.setAngleRange(0.0, 180.0)
servo.setPulseDurationRange(1.0, 2.0)
servo.enable = true
servo.angle = servo.minimumAngle
Moving the servo
servo.angle = 42.0
Using Android Things to Detect & Exterminate Reptilians
Option #2:
Flamethrower
Using Android Things to Detect & Exterminate Reptilians
Flamethrower (21)
(21)
https://www.youtube.com/watch?v=fh6oJZZ27Ro
Remote control
• Nearby Connections API
• Bluetooth LE
• Embedded http server
• Whatever you want
Option #3: Chainsaw
Relay module (22)
(22)
http://nilhcem.com/android-things/google-assistant-smart-home
Magic happens here
relay.value = true
Using Android Things to Detect & Exterminate Reptilians
Using Android Things to Detect & Exterminate Reptilians
Using Android Things to Detect & Exterminate Reptilians
val colorAnimator = ValueAnimator.ofFloat(0f, 360f).apply {
duration = 8000
repeatCount = ValueAnimator.INFINITE
repeatMode = ValueAnimator.REVERSE
addUpdateListener { animator ->
val leds = getLedsColors(animator.animatedValue)
ledstrip.write(leds)
}
start()
}
val path = Path().apply {
moveTo(0f, 0f)
lineTo(0.001f, 400f / 2000f) // 0 secs -> 2.5 fps
lineTo(3f / 23f, 400f / 2000f) // 3 secs -> 2.5 fps
lineTo(6f / 23f, 20f / 2000f) // 6 secs -> 50.0 fps
lineTo(18f / 23f, 20f / 2000f) // 18 secs -> 50.0 fps
lineTo(1f, 1f) // 23 secs -> 0.5 fps
}
val frameDelayAnimator = ValueAnimator.ofInt(0, 2000).apply {
duration = 23000
repeatCount = 0
interpolator = PathInterpolator(path)
start()
}
Using Android Things
to Detect &
Exterminate
Reptilians
Using Android Things to Detect & Exterminate Reptilians
Conclusion
Android Things is Fun
Easy to get started
Reptilians suck (23)
(23)
Unless Reptilians are just an analogy to tell you not to blindly trust media and get you think about reality in a different way
Be a maker
Try Android Things, really
Using Android Things to
Detect & Exterminate Reptilians
• Twitter:
@Nilhcem
• Slides:
bit.ly/reptilethings

More Related Content

PDF
Home Automation with Android Things and the Google Assistant
PDF
The 2016 Android Developer Toolbox [NANTES]
PDF
Android Wear Essentials
PDF
The 2016 Android Developer Toolbox [MOBILIZATION]
PDF
Architecture Patterns in Practice with Kotlin. UA Mobile 2017.
PDF
Advanced programming with #nodecopter
PDF
Drones, Flying robots and Javascript
PPTX
Get started with YUI
Home Automation with Android Things and the Google Assistant
The 2016 Android Developer Toolbox [NANTES]
Android Wear Essentials
The 2016 Android Developer Toolbox [MOBILIZATION]
Architecture Patterns in Practice with Kotlin. UA Mobile 2017.
Advanced programming with #nodecopter
Drones, Flying robots and Javascript
Get started with YUI

What's hot (20)

PDF
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
PDF
Letswift19-clean-architecture
PDF
libGDX: Scene2D
PDF
Reactive programming with RxJS - ByteConf 2018
KEY
Android workshop
PPTX
Java final project of scientific calcultor
PPTX
Using Redux-Saga for Handling Side Effects
TXT
bullismo e scuola primaria
DOCX
ios,objective tutorial
PDF
The Ring programming language version 1.5.1 book - Part 45 of 180
PDF
When Bad Things Come In Good Packages
PDF
You will learn RxJS in 2017
PPTX
Raspberry Pi with Java (JJUG)
PDF
Interactive Music II ProcessingとSuperColliderの連携 -2
PDF
RxJS Operators - Real World Use Cases (FULL VERSION)
PDF
Sequence diagrams
PDF
Environmental effects - a ray tracing exercise
PDF
RxJS - 封裝程式的藝術
PDF
Say It With Javascript
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
Letswift19-clean-architecture
libGDX: Scene2D
Reactive programming with RxJS - ByteConf 2018
Android workshop
Java final project of scientific calcultor
Using Redux-Saga for Handling Side Effects
bullismo e scuola primaria
ios,objective tutorial
The Ring programming language version 1.5.1 book - Part 45 of 180
When Bad Things Come In Good Packages
You will learn RxJS in 2017
Raspberry Pi with Java (JJUG)
Interactive Music II ProcessingとSuperColliderの連携 -2
RxJS Operators - Real World Use Cases (FULL VERSION)
Sequence diagrams
Environmental effects - a ray tracing exercise
RxJS - 封裝程式的藝術
Say It With Javascript
Ad

Similar to Using Android Things to Detect & Exterminate Reptilians (20)

PPSX
Automated malware analysis
PDF
IstSec'14 - İbrahim BALİÇ - Automated Malware Analysis
PDF
ARE 2011 AR Authoring
PPTX
Android Programming made easy
PDF
Kandroid for nhn_deview_20131013_v5_final
PDF
Discover System Facilities inside Your Android Phone
PDF
Android Internals (This is not the droid you’re loking for...)
PPT
Gdc09 Minigames
PDF
426 lecture 4: AR Developer Tools
PDF
COSC 426 Lect. 3 -AR Developer Tools
PPTX
Arduino based IoT Application Programming_20180814.pptx
PDF
Better With Friends: Android+NFC+Arduino
PDF
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
PDF
0xdroid -- community-developed Android distribution by 0xlab
PDF
Kinect v2 Introduction and Tutorial
KEY
Google maps and GPS, camera, SD card, tips &amp; tricks
PDF
Core Android
PDF
Building Your Robot using AWS Robomaker
PPTX
Lab Handson: Power your Creations with Intel Edison!
PPTX
PVS-Studio, a solution for resource intensive applications development
Automated malware analysis
IstSec'14 - İbrahim BALİÇ - Automated Malware Analysis
ARE 2011 AR Authoring
Android Programming made easy
Kandroid for nhn_deview_20131013_v5_final
Discover System Facilities inside Your Android Phone
Android Internals (This is not the droid you’re loking for...)
Gdc09 Minigames
426 lecture 4: AR Developer Tools
COSC 426 Lect. 3 -AR Developer Tools
Arduino based IoT Application Programming_20180814.pptx
Better With Friends: Android+NFC+Arduino
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
0xdroid -- community-developed Android distribution by 0xlab
Kinect v2 Introduction and Tutorial
Google maps and GPS, camera, SD card, tips &amp; tricks
Core Android
Building Your Robot using AWS Robomaker
Lab Handson: Power your Creations with Intel Edison!
PVS-Studio, a solution for resource intensive applications development
Ad

Recently uploaded (20)

PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
Machine Learning_overview_presentation.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Encapsulation theory and applications.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Dropbox Q2 2025 Financial Results & Investor Presentation
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Electronic commerce courselecture one. Pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
20250228 LYD VKU AI Blended-Learning.pptx
A comparative analysis of optical character recognition models for extracting...
Machine Learning_overview_presentation.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Encapsulation theory and applications.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
The Rise and Fall of 3GPP – Time for a Sabbatical?
Programs and apps: productivity, graphics, security and other tools
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Unlocking AI with Model Context Protocol (MCP)
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
MIND Revenue Release Quarter 2 2025 Press Release
MYSQL Presentation for SQL database connectivity
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...

Using Android Things to Detect & Exterminate Reptilians