Slide 1

Slide 1 text

Creating a Dashboard for Visualizing and Interacting with IoT Data Dan Gallo Sencha, Inc. @DanielJGallo

Slide 2

Slide 2 text

Dan Gallo • Technical Sales Engineer at Sencha • Background in web app development speakerdeck.com/danielgallo @DanielJGallo

Slide 3

Slide 3 text

Big data and Internet of Things (IoT) • How do we handle data from different devices and sources? • How do we visualize this data to make it meaningful, and to aid us in a decision making process?

Slide 4

Slide 4 text

?

Slide 5

Slide 5 text

Internet of Things? • Linking of smart objects to the Internet • Physical objects that have an IP address • Exchanging of data between these things, and other Internet connected systems

Slide 6

Slide 6 text

Internet of Things – uses • Smart homes – lighting, door locks, security systems, moisture sensor for leaks, smart fridges • Monitoring environment – temperature, light, humidity • Smart cities – street lighting, traffic, rail • Healthcare • Wearables

Slide 7

Slide 7 text

Internet of Things – communication • Various communication methods may be used: Technology Distance Speed Bluetooth 50-150 m / 54-164 yards 1Mbps Cellular 35-200 km / 21-124 miles 600kbps-10Mbps LoRaWAN 2-15 km / 1-9 miles 0.3-50kbps Neul 10 km / 6 miles 100kbps NFC 10 cm / 4 in 100-420kbps Sigfox 3-50 km / 2-31 miles 10-1000bps WiFi 50 m / 54 yards 150-600Mbps Z-Wave 30 m / 32 yards 9-100kbps Zigbee 10-100 m / 11-110 yards 250kbps

Slide 8

Slide 8 text

Internet of Things – devices • iotlist.co contains a good selection of available devices • Some examples:

Slide 9

Slide 9 text

Internet of Things – devices • iotlist.co contains a good selection of available devices • Some examples:

Slide 10

Slide 10 text

Internet of Things – kits • More IoT kits available now, enabling greater interest • E.g. Intel Edison and Grove IoT Starter Kit Powered by AWS • Enables various sensors to be connected and programmed • Integrates with AWS IoT • Apps can be programmed with Node.js

Slide 11

Slide 11 text

Internet of Things – growth • Cisco estimates the IoT will consist of 50 billion devices connected to the Internet by 2020 • Will require the ability to handle and analyze data from many different sources • Also hearing about the IoT much more in the news Source: http://www.cisco.com/c/en/us/solutions/internet-of-things/overview.html

Slide 12

Slide 12 text

Internet of Things – in the news https://www.technologyreview.com/s/601899/europe-builds-a-network-for-the-internet-of-things-will-the-devices-follow/ http://www.techradar.com/news/networking/netherlands-becomes-first-country-with-nationwide-internet-of-things-1324228

Slide 13

Slide 13 text

Internet of Things – in the news http://www.campaignlive.co.uk/article/vodafones-internet-things-swimsuit-detects-harmful-uv-levels/1403667

Slide 14

Slide 14 text

Internet of Things – when things go wrong http://motherboard.vice.com/read/your-dog-could-starve-if-youre-too-dependent-on-the-internet-of-things- http://www.dailydot.com/debug/smart-pet-offline-hungry-home-automation/ • Petnet - Internet connected automatic pet feeder

Slide 15

Slide 15 text

Internet of Things – when things go wrong http://www.telegraph.co.uk/technology/2016/10/12/man-spends-11-hours-trying-to-make-cup-of-tea-with-wi-fi-kettle/ https://twitter.com/markrittman/status/785905327967498240 • WiFi enabled kettle not working – a very British problem!

Slide 16

Slide 16 text

Data

Slide 17

Slide 17 text

Data • Various services available to help with integration of IoT devices and applications: • PubNub • AWS IoT • Azure IoT • These services make it easier to enable devices to communicate with each other and with applications

Slide 18

Slide 18 text

PubNub • Provides a real-time messaging service • 70+ different platform SDKs • Enables devices to communicate with each other regardless of platform

Slide 19

Slide 19 text

Example – publish messages with Node.js var pubnub = require('pubnub')({ ssl: true, publish_key: 'publish-key-here' }); pubnub.publish({ channel: 'mychannel', message: { sensor: 'temperature', value: 32.2 }, callback: function(e) { console.log('Message sent', e); } });

Slide 20

Slide 20 text

Example – subscribe to messages in a web app PUBNUB.init({ ssl: true, subscribe_key: 'subscribe-key-here' }).subscribe({ channel: 'mychannel', message: function(message) { console.log(message); } }); { sensor: 'temperature', value: 32.2 } Console output:

Slide 21

Slide 21 text

PubNub real-time data stream examples https://www.pubnub.com/developers/realtime-data-streams/

Slide 22

Slide 22 text

PubNub real-time data stream examples https://www.pubnub.com/developers/realtime-data-streams/

Slide 23

Slide 23 text

PubNub real-time data stream examples { "photosensor":"809.09", "ambient_temperature":"23.10", "radiation_level":"203", "humidity":"87.8553", "timestamp":1469761686, "sensor_uuid":"probe-019eda76" }

Slide 24

Slide 24 text

PubNub Blocks – microservices • PubNub Blocks run as microservices • JavaScript based functions that run in the cloud • Can execute certain actions when messages are published, for example: • Use the SendGrid API to send the contents of a message as an email • Use IBM Watson to translate text

Slide 25

Slide 25 text

My IoT devices

Slide 26

Slide 26 text

Intel Edison and Grove Kit • IoT kit • Integrated WiFi • Can run custom Node.js apps • Multiple sensors and inputs: Temperature, Humidity, PIR Motion, Air Quality, Moisture, Light, UV, Button • Programmable LCD backlit display for visual output • USB webcam connected

Slide 27

Slide 27 text

Intel Edison and Grove Kit

Slide 28

Slide 28 text

Sensors – Air Quality

Slide 29

Slide 29 text

Sensors – Moisture

Slide 30

Slide 30 text

Sensors – UV

Slide 31

Slide 31 text

Sensors – Light

Slide 32

Slide 32 text

Sensors – Temperature and Humidity

Slide 33

Slide 33 text

Sensors – PIR Motion

Slide 34

Slide 34 text

Input – Button

Slide 35

Slide 35 text

Input – USB HD Webcam

Slide 36

Slide 36 text

Output – LCD Backlit Display

Slide 37

Slide 37 text

LIFX smart bulb • Internet connected LED bulb • Millions of colors • Mobile app for control • REST-based API for third party apps

Slide 38

Slide 38 text

Packages

Slide 39

Slide 39 text

Johnny-Five – Robotics and IoT Platform • Node.js package that provides an out of the box way to easily interact with sensors on a wide range of IoT devices, including Intel Edison • Many APIs and examples • http://johnny-five.io

Slide 40

Slide 40 text

Building an application

Slide 41

Slide 41 text

Sencha Ext JS JavaScript application framework

Slide 42

Slide 42 text

Sencha Ext JS • JavaScript framework for mobile, tablet and desktop apps • Large selection of UI components and widgets • UI can be configured to adapt based on the device type or screen size, enabling an app to run on all platforms from one common codebase

Slide 43

Slide 43 text

Getting started • Download and install Sencha Cmd and Sencha Ext JS from sencha.com • Create a new project from the command line: • Open the project folder in an IDE of your choice sencha -sdk /downloads/ext generate app --name Dash --path /apps/Dash --modern

Slide 44

Slide 44 text

Getting started – important files • app.json contains application settings, such as theme name, version, required packages, caching configuration etc. • app.js initializes the application, and defines the initial view to create on load Ext.application({ name: 'Dash', extend: 'Dash.Application', requires: [ 'Dash.view.main.Main' ], mainView: 'Dash.view.main.Main' });

Slide 45

Slide 45 text

Getting started – concepts • Applications are structured using an MVVM architecture • Each class (view, model, controller etc.) resides within its own .js file, and normally extends from a base class • JSON syntax • A new class is defined by using Ext.define Ext.define('Dash.model.Alert', { extend: 'Ext.data.Model', fields: [{ name: 'text' }, { name: 'value', type: 'number' }, { name: 'sensorType' }] });

Slide 46

Slide 46 text

My dashboard app Server room monitoring application

Slide 47

Slide 47 text

My app – Server room monitoring app • A dashboard app for monitoring and visualizing the conditions of a Server Room • Uses real sensor data provided by the Intel Edison device • Dashboard must act on this data, e.g. if values exceed a defined threshold, issue an on-screen alert • Incorporate a panic alarm button, that displays an alert in the app when activated • Motion sensor will also issue an alert and capture a photo using the USB webcam • LCD display will show these alerts • Smart bulb will also provide a way to visualize the alerts

Slide 48

Slide 48 text

My app – Server room monitoring app • Doesn’t require a database or any web services • PubNub provides the ability to store messages for a set period, meaning we can easily retrieve recent sensor data when the application loads

Slide 49

Slide 49 text

Air quality sensor Temp & Humidity sensor Moisture sensor Light sensor Button UV sensor PIR Motion sensor USB webcam Edison publishes sensor data Edison subscribes to reset messages Captured photos published to S3 Dashboard app subscribes to sensor data Dashboard app resets motion/panic alarm PubNub Block sends photo via email If app receives panic or motion sensor alarm, flash the LIFX bulb red LCD display shows status and flashes red when alarms activated

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

Demo and code walkthrough

Slide 55

Slide 55 text

In summary

Slide 56

Slide 56 text

In summary • The Internet of Things is getting bigger • This means more data, from more sources • In order to do anything meaningful with that data, we need a way to analyze and summarize it

Slide 57

Slide 57 text

In summary • This requires a UI that can visualize information to the user in multiple ways, on a variety of form factors (from mobile to desktop), using Ext JS components such as grids, pivot grids, charts, and D3.js integration • Using a framework like Ext JS provides a mechanism to build a powerful web application to summarize this type of data • Using a real-time service like PubNub makes it easier to exchange data between devices and apps

Slide 58

Slide 58 text

In summary • Source code: https://github.com/DanielGallo/IoTServerRoom • Above repository contains the code for both the Node.js and Ext JS app

Slide 59

Slide 59 text

Questions?

Slide 60

Slide 60 text

Thanks! @DanielJGallo speakerdeck.com/danielgallo