Javascript & Internet of Things


When JS Meets IoT

https://goo.gl/q8KkYG

Arvind Ravulavaru

@arvindr21



Author: Learning Ionic, Learning Ionic II
(Advanced IoT with JavaScript)

Blog: The Jackal of Javascript

@work


Platform Architect / Founder

Agenda


What the IoT ?

In Simpler Terms :

Internet of Things is Quite old

Well... Nearly...
35 years old

The First IoT Device*


  • A Coke Machine at Carnegie Mellon University, in 1982
  • By four exercise challenged but ingenious graduate students, Mike Kazar, David Nichols, John Zsarnay, & Ivor Durham
  • So they could check from their desks if the machine was loaded with cold coke

Did You Know :
The first webpage was created in 1991

Another Early IoT Device


  • The Internet Toaster by John Romkey in 1989
  • Connected to the internet with TCP/IP
  • Controlled via Simple Networking Management Protocol Management Information Base (SNMP MIB)
  • One control to turn on/off

The Trojan Room Coffee Pot


  • Created by Quentin Stafford-Fraser and Paul Jardetzky in 1993
  • It was located in the 'Trojan Room' within the Computer Laboratory of the University of Cambridge
  • It used to monitor the pot levels with an image being updated about 3x a minute and sent to the buildings server

Laziness is the Mother of Invention!

IoT In the Real World

Healthcare


The Heart will notify The Hospital


Consumer IoT

"IoT Helps us keep our plants hydrated

and our baby butts dry"


- Sudha Jamthe,
IoT Disruptions

Wearables


The Smart Toilet (*-*)


Roombah...!!!


Garage Openers... What's new?


IIoT

The Toothpaste Factory (*~*)


Industrial IoT


The world's most misunderstood programming language

OR

Few Reasons!

Machine Precision


0.1 + 0.2 !== 0.3

undefined can be defined


var someVar;
alert(someVar == undefined); //evaluates true
undefined = "I'm not undefined!";
var someVar;
alert(someVar == undefined); //evaluates false!

Scope can be faked


var animal = 'dog';

function getAnimal(adjective) {
    console.log(adjective + ' ' + this.animal);
};

var myObj = {
    animal: 'camel'
};

getAnimal.call(myObj, 'lovely'); //logs 'lovely camel'

null is an object


console.log(typeof null); //logs 'object'

nan is a number


console.log(typeof NaN); //logs 'Number'
console.log(NaN === NaN); //evaluates false

Automatic globals


function f() { foo = 123 };
f();
console.log(foo); // logs 123

W.L.I.I.A.


Type Coercion


'' == '0'		//false
0 == ''			//true
0 == '0'		//true
false == 'false'	//false
false == '0'		//true
false == undefined	//false
false == null		//false
null == undefined	//false
" \t\r\n" == 0		//true

(;) optional?


What the...?


$ {} + [] // 0
$ {} + [] + '' // "0"
$ ({} + {}) // "[object Object][object Object]"
$ ({} + []) // "[object Object]"
$ Array(16).join() // ",,,,,,,,,,,,,,,"
$ Array(16).join().length // 15
$ 'js' - 1 // NaN

Callback Hell


All these problems & JS?

Here is Why?


  • JS JS everywhere..
  • Event Driven nature
  • One language all the way!
  • HUGE set of libraries and frameworks
  • ES6 is here!
  • Amazing community
  • It is free! :P

How do we IoTify?


IoT Reference Architecture


Where does JS fit in?


  • Hardware
  • Gateways - Hardware/Software
  • Server/Data Aggregators
  • Web Dashboards
  • Mobile Apps
  • Desktop Apps

Hardware


Gateways - Hardware


Gateways - Software


Server/Data Aggregators


Web Dashboards


Mobile Apps


Desktop Apps


Standards


Demo

Meetup
arvind@theiotsuitcase.com

Eat - Sleep - IoT - Repeat