Slide 1

Slide 1 text

BENDING THE IOT TO YOUR WILL WITH JAVASCRIPT Brandon Satrom | @BrandonSatrom | [email protected]

Slide 2

Slide 2 text

THE CURRENT STATE OF THE INTERNET OF THINGS

Slide 3

Slide 3 text

“ ” - Nikola Tesla MOBILE, CIRCA 1926 When wireless is perfectly applied the whole earth will be converted into a huge brain, which in fact it is, all things being particles of a real and rhythmic whole… and the instruments through which we shall be able to do this will be amazingly simple compared with our present telephone. A man will be able to carry one in his vest pocket.

Slide 4

Slide 4 text

34 BILLION Devices online by 2020 Spent on the IoT (2016-2021) $6 TRILLION

Slide 5

Slide 5 text

THE EVER-PRESENT GARTNER HYPE CYCLE PEAK OF INFLATED EXPECTATIONS TECHNOLOGY TRIGGER TROUGH OF DISILLUSIONMENT SLOPE OF ENLIGHTENMENT PLATEAU OF PRODUCTIVITY VISIBILITY TIME IOT TODAY IOT TOMORROW!

Slide 6

Slide 6 text

THE EXIT “THE TROUGH,” THE IOT MUST SOLVE REAL PROBLEMS

Slide 7

Slide 7 text

SMARTFIN

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

ENVIROFIT

Slide 10

Slide 10 text

FROM CLOSED TO OPEN

Slide 11

Slide 11 text

FROM CLOSED TO OPEN

Slide 12

Slide 12 text

IoT Solutions are about much more than embedded hardware & firmware

Slide 13

Slide 13 text

“THE IOT” IS A NEW, FOREIGN WORLD FOR MANY HARDWARE ENGINEERS What a typical hardware engineer understands today

Slide 14

Slide 14 text

JAVASCRIPT: THE COMMON DENOMINATOR

Slide 15

Slide 15 text

THREE TYPES OF IOT APPS 1 2 3 IOT WEB APPS IOT MOBILE APPS IOT CLOUD APPS

Slide 16

Slide 16 text

IoT Builders are the real full-stack developers

Slide 17

Slide 17 text

THREE TYPES OF IOT APPS 1 2 3 IOT WEB APPS IOT MOBILE APPS IOT CLOUD APPS

Slide 18

Slide 18 text

HOW WEB APPS ENABLE THE IOT 1 IOT WEB APPS DATA AGGREGATION AND VISUALIZATION EXTENSIBLE AND PLATFORM-AGNOSTIC

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

OPTIONS FOR BUILDING IOT WEB APPS 1 2 GET DATA FROM YOUR DEVICES BUILD YOUR APP MQTT TCP Pub/Sub Particle Pub/Sub

Slide 21

Slide 21 text

PARTICLE PUBLISH AND SUBSCRIBE double tempC = 0; void setup() { Particle.variable("temp", tempC); pinMode(A0, INPUT); } void loop() { analogvalue = analogRead(A0); tempC = (((analogvalue * 3.3) / 4095) - 0.5) * 100; if (tempC > 120) { Particle.publish("temp/critical", tempC); } else if (tempC > 80) { Particle.publish("temp/warning", tempC); } } void setup() { !// Subscribes to temp/warning AND temp/critical Particle.subscribe("temp", handleTemp); } void handleTemp(const char *event, const char *data) { double temp = extractTemp(data); if (temp > 120) { deactivatePump(); } else if (temp > 80) { reducePumpSpeed(); } }

Slide 22

Slide 22 text

https://api..com/v1

Slide 23

Slide 23 text

YOU NEED A GOOD API

Slide 24

Slide 24 text

THE PARTICLE DEVICE CLOUD API # API Call # GET /v1/events/{EVENT_NAME} # EXAMPLE REQUEST curl -H "Authorization: Bearer {ACCESS_TOKEN_GOES_HERE}" \ https:!//api.particle.io/v1/events/temp/critical # Will return a stream that echoes text when your event is published event: temp/critical data: {"data":"125","ttl":"60","published_at":"2018-05-28 T19:20:34.638Z", "deviceid":"0123456789abcdef"}

Slide 25

Slide 25 text

THE PARTICLE JS LIBRARY const Particle = require('particle-api-js'); const particleAPI = new Particle(); const token = process.env.PARTICLE_TOKEN; const particle = { listDevices: () !=> { return new Promise((resolve, reject) !=> { particleAPI .listDevices({ auth: token }) .then(devices !=> resolve(devices)) .catch(err !=> reject(err)); }); }, deviceFunctions: deviceName !=> { return new Promise((resolve, reject) !=> { particleAPI .listDevices({ auth: token }) .then(devices !=> { const device = devices.body.filter(device !=> device.name !!=== deviceName)[0]; return device.id; .then(id !=> { return particleAPI.getDevice({ deviceId: id, auth: token }); }) .then(device !=> { resolve(device.body.functions); }).catch(err !=> reject(err)); }); }};

Slide 26

Slide 26 text

DEMO THE PARTICLE JS LIBRARY

Slide 27

Slide 27 text

THREE TYPES OF IOT APPS 1 2 3 IOT WEB APPS IOT MOBILE APPS IOT CLOUD APPS

Slide 28

Slide 28 text

HOW MOBILE APPS ENABLE THE IOT VISUALIZATION AND CONTROL PORTABLE AND UBIQUITOUS 2 IOT MOBILE APPS

Slide 29

Slide 29 text

EXAMPLE: THE BLYNK APP

Slide 30

Slide 30 text

OPTIONS FOR BUILDING IOT MOBILE APPS 1 2 3 NATIVE APPS GENERIC CONTROLLER APP CROSS-PLATFORM

Slide 31

Slide 31 text

SDKS FOR MOBILE DEVELOPMENT myPhoton!.getVariable("temperature", completion: { (result:Any?, error:Error?) !-> Void in if let _ = error { print("Failed reading temperature from device") } else { if let temp = result as? NSNumber { print("Room temp is \(temp.stringValue) degrees") } } }) List devices = ParticleCloudSDK.getCloud().getDevices(); for (ParticleDevice device : devices) { if (device.getName().equals("myDevice")) { doSomethingWithMyDevice(device); break; } } ParticleDevice myDevice = null; List devices = ParticleCloud.SharedCloud.GetDevicesAsync(); foreach (ParticleDevice device in devices) { if (device.Name().equals("myDeviceName")) myDevice = device; } [myPhoton getVariable:@"temperature" completion:^(id result, NSError *error) { if (!error) { NSNumber *temperatureReading = (NSNumber *)result; NSLog(@"Room temperature is %f degrees",temperatureReading.floatValue); } else { NSLog(@"Failed reading temperature from Photon"); } }];

Slide 32

Slide 32 text

THE NATIVESCRIPT PARTICLE PLUGIN listDevices(): void { this.devices.splice(0, this.devices.length); this.set(HelloWorldModel.SELECTED_DEVICE_KEY, undefined); this.particle.listDevices() .then(devices !=> { if (devices.length !!=== 0) { this.set(HelloWorldModel.MESSAGE_KEY, "No devices have been claimed in this account."); } else { this.set(HelloWorldModel.MESSAGE_KEY, "Select a device below:"); } this.devices.push(devices); }) .catch(error !=> this.set(HelloWorldModel.MESSAGE_KEY, error)); } onDeviceTap(args): void { this.set(HelloWorldModel.SELECTED_DEVICE_KEY, this.devices.getItem(args.index)); this.set(HelloWorldModel.MESSAGE_KEY, `Selected: ${this.selectedDevice.name}`); }

Slide 33

Slide 33 text

DEMO PARTICLE + NATIVESCRIPT

Slide 34

Slide 34 text

THREE TYPES OF IOT APPS 1 2 3 IOT WEB APPS IOT MOBILE APPS IOT CLOUD APPS

Slide 35

Slide 35 text

HOW CLOUD APPS ENABLE THE IOT INSIGHT & CONTROL (NEARLY) INFINITE COMPUTATIONAL POWER 3 IOT CLOUD APPS

Slide 36

Slide 36 text

EXAMPLE: ELECTRIC IO

Slide 37

Slide 37 text

OPTIONS FOR BUILDING IOT CLOUD APPS 1 2 3 CLOUD BACKHAUL CLOUD WORKFLOW CLOUD PROCESSING

Slide 38

Slide 38 text

THE PARTICLE IOT RULES ENGINE

Slide 39

Slide 39 text

NODE-BASED, WITH CLOUD INTEGRATIONS WHAT CAN I DO WITH THE IOT RULES ENGINE? Real-time alerting Device commands Data management Visualizations & analytics Fleet-wide Remote Diagnostics OTA firmware automation Node.js runtime Built-in Cloud Integrations

Slide 40

Slide 40 text

DEMO THE IOT RULES ENGINE

Slide 41

Slide 41 text

A WORD ABOUT “REAL IOT”

Slide 42

Slide 42 text

“ ” - L.P. Jacks WORK == PLAY The master in the art of living makes little distinction between work and play

Slide 43

Slide 43 text

SOLVING REAL PROBLEMS THROUGH PLAY

Slide 44

Slide 44 text

SOLVING REAL PROBLEMS THROUGH PLAY

Slide 45

Slide 45 text

BECOME A FULLER-STACK DEVELOPER TODAY!

Slide 46

Slide 46 text

THANKS! @BRANDONSATROM [email protected]