iot fire starter

Post on 23-Jan-2017

540 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

WI-Fi SSID: ThingLabsPassword: ThingLabs

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

OVERVIEW

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

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

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)

WIRING A BREADBOARD• Side rails create a circuit up and

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

GETTING STARTEDPreparing your development environment

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

NPM INSTALLATIONS• Install Johnny-Five

npm install -g johnny-five

• Install Particle-CLInpm install -g particle-cli

• Install Nitrogen CLInpm install -g nitrogen-cli

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/

MAKER 101The fundamentals of maker development kits

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

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)

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

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

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)

WIRING THE PHOTON

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

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

particle token list

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";

LAB 02: READING ANALOG INPUTAmbient Light Detection

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

The resisted voltage indicates the value.

Brighter light == Less resistance;

WIRING THE PHOTON

LAB 03: INPUT CONTROLS OUTPUTNight Light

PULSE WIDTH MODULATION (PWM)

WIRING THE PHOTON

CONNECTED THINGS 101The fundamentals of connecting Things to the Cloud

LAB 04: SENDING DATA TO THE CLOUDNitrogen

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

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

NITROGEN: A PUB-SUB MESSAGING MODEL

Bad User

MotorizedBlinds

Rogue Light

Light Sensor

Nitrogen Service

Lighting App

Light

LightSwitch

Mobile App

WIRING THE PHOTON

LAB 05: COMMAND & CONTROLCommandManager

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

WIRING THE PHOTON

LAB 06: CONNECTING MULTIPLE THINGSPermissions

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>

WIRING THE PHOTONS

AMBIENT LIGHT DETECTOR

INDICATOR LIGHT

OTHER STUFF

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)

ANATOMY OF AN ARDUINO YÚN

Atheros AR9331 ATmega32u4 

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

Ethernet

Micro USB

USB Host

ATmega 32u4

MicroSD

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

Analog Output 0-53.3V, 5V, GND

GND

THINGLABS.IODSEVEN@MICROSOFT.COM

IVAN.JUDSON@MICROSOFT.COM

top related