iot fire starter

45
IOT FIRE STARTER A series of hands-on labs for the Internet of Things WI-Fi SSID: ThingLabs Password: ThingLabs

Upload: doug-seven

Post on 23-Jan-2017

540 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: IoT Fire Starter

IOT FIRE STARTERA series of hands-on labs for the Internet of Things

WI-Fi SSID: ThingLabsPassword: ThingLabs

Page 2: IoT Fire Starter

AGENDA• Getting Started (Preparing your dev environment)• Overview• Maker 101

• Writing Digital Output• Reading Analog Input• Input Controls Output

• Connected Things 101• Sending Data to the Cloud• Command & Control• Connecting Multiple Things

• Cloud IoT Services• Visualizing IoT Data

• Hackathon

Page 3: IoT Fire Starter

OVERVIEW

Page 4: IoT Fire Starter

Field

Gat

eway

s

Prot

ocol

Adap

ters

OSS

Proje

ct

Clou

d Ga

tewa

yEv

ent H

ub ->

IoT

Hub

Hot Path AnalyticsAzure Stream Analytics, Azure Storm

Cold / Batch Analytics & Visualizations

Azure HDInsight, AzureML, Power BI, Azure Data Factory

Hot Path Business LogicPaaS V2 & Actor Framework En

terp

rise

Proc

ess C

onne

ction

sBi

zTalk

Ser

vices

, Not

ifica

tion

Hubs

Devic

esLin

ux, A

ndro

id, i

OS, R

TOS,

Win

dows

Device Connectivity

Analytics & Operationalized Insights

BusinessConnectivity

IOT DEVICE <-> CLOUD PATTERNS

Page 5: IoT Fire Starter

Field

Gat

eway

s

Prot

ocol

Adap

ters

OSS

Proje

ct

Clou

d Ga

tewa

yEv

ent H

ub ->

IoT

Hub

Hot Path AnalyticsAzure Stream Analytics, Azure Storm

Cold / Batch Analytics & Visualizations

Azure HDInsight, AzureML, Power BI, Azure Data Factory

Hot Path Business LogicPaaS V2 & Actor Framework En

terp

rise

Proc

ess C

onne

ction

sBi

zTalk

Ser

vices

, Not

ifica

tion

Hubs

Devic

esLin

ux, A

ndro

id, i

OS, R

TOS,

Win

dows

Device Connectivity

Analytics & Operationalized Insights

BusinessConnectivity

IOT DEVICE <-> CLOUD PATTERNS

Page 6: IoT Fire Starter

LITTLE BRAIN <===============> BIG BRAINMCU + MPUMCU (e.g. ATMega) MPU

Micro-controller (MCU) MCU + MPU MPUExample Arduino Pro Mini Arduino Uno Arduino Yún Particle Photon Raspberry Pi 2 MinnowBorad

MAXMicro-controller ATmega328 ATmega328 ATmega32u4 -- -- --

Micro-processor -- -- Atheros AR9331 ARM Cortex-M3 ARM Cortex-A7 Intel Atom E38xx

GPU No No No No Yes IntegratedWi-Fi SoC No No Yes Yes No NoLinux No No Yes No Yes YesWindows 10 IoT No No No No Yes Yes

Cost $10 $30 $80 $19 $35++ $100 (1GB) -$140 (2GB)

Page 7: IoT Fire Starter

WIRING A BREADBOARD• Side rails create a circuit up and

down• Rows create a circuit (A-E & F-J)

Page 8: IoT Fire Starter

GETTING STARTEDPreparing your development environment

Page 9: IoT Fire Starter

DOWNLOADS & INSTALLATIONS• Install a Code Editor - http://Code.VisualStudio.com• Install Git - http://git-scm.com• Install Node.js - http://nodejs.org

Page 10: IoT Fire Starter

NPM INSTALLATIONS• Install Johnny-Five

npm install -g johnny-five

• Install Particle-CLInpm install -g particle-cli

• Install Nitrogen CLInpm install -g nitrogen-cli

Page 11: IoT Fire Starter

OTHER PREPARATION• Set Up a Development Directory

C:\Development\IoTLabs

• Create a Free Particle Cloud Accounthttps://build.particle.io/signup

• Create a Microsoft Azure Trial Accounthttps://azure.microsoft.com/en-us/pricing/free-trial/

Page 12: IoT Fire Starter

MAKER 101The fundamentals of maker development kits

Page 13: IoT Fire Starter

LAB 01: WRITING DIGITAL OUTPUTThe ‘Hello, World!’ of devices

Page 14: IoT Fire Starter

BILL OF MATERIALS• Particle Photon• USB to micro-USB cable (there is one included in the Photon

Development Kit)• LED (there is one included in the Photon Development Kit)• 220-Ohm 1/4 Watt resistor (there is one included in the Photon

Development Kit)

Page 15: IoT Fire Starter

CLAIM YOUR PHOTON• Apple iPhone or Google Android – Use Particle Tinker App

• Windows PC – • Download and install Photon drivers –

https://s3.amazonaws.com/spark-website/Spark.zip• From Node.js Command Prompt:

particle identify (copy the device ID)particle serial wifi (scan and select the Wi-Fi network)(Wait for Photon to restart)particle device add YOUR_DEVICE_ID_HERE

Page 16: IoT Fire Starter

UPLOAD THE VOODOOSPARK FIRMWARE• https://build.particle.io• Create a new app named VooDooSpark• Copy the code from http://tinyurl.com/VooDooSpark• Target your Photon• Validate the code• Flash the Photon

Page 17: IoT Fire Starter

OHM'S LAW• Voltage = current (in amps) x resistance• V = IR or R = V/I or I = V/R• Resistance (R) = Voltage (V) / Current (I)

• R = 5V / 15mA (1,000 milliamps = 1 amp)• R = 5 / .015• R = 333.333 Ohms (330 Ohms is close enough)

• R = 5V / 10mA• R = 5/.01• R = 500 Ohms (560 Ohms is close enough)

Page 18: IoT Fire Starter

WIRING THE PHOTON

Page 19: IoT Fire Starter

PACKAGE.JSON{ "name": "IoT-Labs-Photon", "repository": { "type": "git", "url": "https://github.com/ThingLabsIo/IoTLabs/Photon" }, "version": "0.1.0", "private": true, "dependencies": { "johnny-five": "^0.8.0", ”particle-io": "^0.8.1” }}

cd C:\Development\IoTLabs npm install

Page 20: IoT Fire Starter

GET YOUR PHOTON TOKEN• From a Node.js Command Prompt:

particle token list

Page 21: IoT Fire Starter

LAB01.JS// Define the Jonny Five and Spark-IO variables var five = require("johnny-five"); var Particle = require(”particle-io"); // Define the Johnny Five board as your Particle Photon var board = new five.Board({

io: new Particle({ token: process.env.PARTICLE_KEY || 'YOUR API KEY HERE',deviceId: process.env.PARTICLE_DEVICE || 'YOUR DEVICE ID HERE'

}) }); // Define the pin that is connected to the LED var LEDPIN = "D7";

Page 22: IoT Fire Starter

LAB 02: READING ANALOG INPUTAmbient Light Detection

Page 23: IoT Fire Starter

VOLTAGE DIVIDERA voltage divider splits input voltage input amongst two or more components.

The resisted voltage indicates the value.

Brighter light == Less resistance;

Page 24: IoT Fire Starter

WIRING THE PHOTON

Page 25: IoT Fire Starter

LAB 03: INPUT CONTROLS OUTPUTNight Light

Page 26: IoT Fire Starter

PULSE WIDTH MODULATION (PWM)

Page 27: IoT Fire Starter

WIRING THE PHOTON

Page 28: IoT Fire Starter

CONNECTED THINGS 101The fundamentals of connecting Things to the Cloud

Page 29: IoT Fire Starter

LAB 04: SENDING DATA TO THE CLOUDNitrogen

Page 30: IoT Fire Starter

Field

Gat

eway

s

Prot

ocol

Adap

ters

Clou

d Ga

tewa

y

Hot Path Analytics

Cold / Batch Analytics & Visualizations

Hot Path Business Logic Ente

rpris

e Pr

oces

s Con

nect

ions

Devic

esLin

ux, A

ndro

id, i

OS, R

TOS,

Win

dows

Device Connectivity

Analytics & Operationalized Insights

BusinessConnectivity

IOT DEVICE <-> CLOUD PATTERNS

Page 31: IoT Fire Starter

NITROGEN.IO• Nitrogen is an open-source, JavaScript cloud gateway for IoT.

• Nitrogen provides• Device Management• Security and permissions• Data Ingest• Command & Control

• Nitrogen includes a JavaScript client library for device and web applications

Page 32: IoT Fire Starter

NITROGEN: A PUB-SUB MESSAGING MODEL

Bad User

MotorizedBlinds

Rogue Light

Light Sensor

Nitrogen Service

Lighting App

Light

LightSwitch

Mobile App

Page 33: IoT Fire Starter

WIRING THE PHOTON

Page 34: IoT Fire Starter

LAB 05: COMMAND & CONTROLCommandManager

Page 35: IoT Fire Starter

OVERRIDING COMMANDMANAGER• isRelevant – should I care about the message?

• Message type is _lightState or _lightLevel and the message is either from or to this device ID

• isCommand – do I need to execute the message?• Message type is _lightLevel

• obsoletes – do I care any more? (e.g. have I already processes this)• Does the CommadManager think this is obsolete?• Is the downstream message _lightState, and

is it in response to the specified upstream message, andis the upstream message type _lightLevel

• executeQueue – do whatever needs to be done based on the message• Iterate the activeCommands and perform some action

• start – get things going• Starts the CommandManager, gets all the messages and subscribes to future messages

Page 36: IoT Fire Starter

WIRING THE PHOTON

Page 37: IoT Fire Starter

LAB 06: CONNECTING MULTIPLE THINGSPermissions

Page 38: IoT Fire Starter

PERMISSIONS• Permissions enable control over which Principals can interact (or not) with other

Principals

• Permission Types• admin• view• send• subscribe

• Permissions enable explicit authorization control• n2 permission add --action subscribe --authorized true --issueTo <PRINCIPAL ID> --principalFor <PRINCIPAL ID>

Page 39: IoT Fire Starter

WIRING THE PHOTONS

AMBIENT LIGHT DETECTOR

INDICATOR LIGHT

Page 40: IoT Fire Starter

OTHER STUFF

Page 41: IoT Fire Starter

LITTLE BRAIN <===============> BIG BRAINMCU + MPUMCU (e.g. ATMega) MPU

Micro-controller (MCU) MCU + MPU MPUExample Arduino Pro Mini Arduino Uno Arduino Yún Particle Photon Raspberry Pi 2 MinnowBorad

MAXMicro-controller ATmega328 ATmega328 ATmega32u4 -- -- --

Micro-processor -- -- Atheros AR9331 ARM Cortex-M3 ARM Cortex-A7 Intel Atom E38xx

GPU No No No No Yes IntegratedWi-Fi SoC No No Yes Yes No NoLinux No No Yes No Yes YesWindows 10 IoT No No No No Yes Yes

Cost $10 $30 $80 $19 $35++ $100 (1GB) -$140 (2GB)

Page 42: IoT Fire Starter

ANATOMY OF AN ARDUINO YÚN

Atheros AR9331 ATmega32u4 

Page 43: IoT Fire Starter

ANATOMY OF AN ARDUINO YÚN (CONT’D) AR9331 LinuxWi-Fi

Ethernet

Micro USB

USB Host

ATmega 32u4

MicroSD

Page 44: IoT Fire Starter

ANATOMY OF AN ARDUINO YÚN (CONT’D) Digital IO 1-13

Analog Output 0-53.3V, 5V, GND

GND