Upload
tom-collins
View
851
Download
12
Embed Size (px)
Citation preview
Westminster Impact HubLondon, UK. 29/5/2015
Hack Risk Allianz Hackathon
Getting started with the Internet of Things
Tom Collins@snillocmot
What is IoT?
An extension of the traditional web
providing intelligent features
through embedded computing,
which allows dumb objects
to autonomously react, inform and learn
from the context of Humans and Things
Tom Collins@snillocmot
How is IoT?
The convergence of
cheaper and accessible
cloud, network and processing power,
with smaller and smarter computers
and a variety of hardware I/O sources
Tom Collins@snillocmot
Where is IoT?
Where is IoT?
Where is IoT?
By 2020...$7.1 trillion market value
50 billion connected devices
30 million every day
1 in 3 ‘knowledge workers’ will be
replaced by a digital workforce and smart machines
Why IoT?
To improve quality of life and drive new business
through connecting physical, cyber and social domains
Connected devices
Problems
● Millions of apps● Still stuck in remote control mode● Siloed solutions (An API doesn’t make it IoT)● Big innovation captures the consumers eye,
but not enough immediate ROI for business to adopt
SmartLivingIoT Starter KitA Computer (Arduino Ethernet, Intel Edison or Raspberry PI) & Grove shield
A bunch of sensors and actuators● Button● Blue LED (5mm)● Rotary Angle Sensor (P)● Light Sensor (P)● Vibration Motor● Temperature Sensor● Infrared receiver● Infrared emitter● LED Bar● PIR Motion sensor
Check out the kits athttp://www.smartliving.io/kits
ExamplesTCP/IP, MQTT, IPv6, CoAP, REST, XBEE, ZigBee, ZWave, Serial, custom radios, IPoAC, etc
CONNECTIVITY
LandscapeEND POINTS
aka ThingsMIDDLEWARE
routergateways
fog servicescloud bridges
brokers
ExamplesOpenHAB, TheThingSystem, ZIPR, Dowse, Ponte, WebSphere, RabbitMQ, Dweet
IOT SERVICES
SmartLivingIFTTTXively
TempoIQInitialStateWaylay.io
Millions of other single use services...
ExamplesPersistence, (E.g TempoIQ), automation (E.g IFTTT), intelligence, third party integrators (ERP connectors)
APPS
Companion appsWidgiots
FreeboardNode redWyliodrin
ExamplesWidgIoTs, SmartLiving Web & Mobile Apps, FreeboardCustom RF
END POINTSaka Things
CONNECTIVITY MIDDLEWARE IOT SERVICES APPS
LED
POTArduino DBBroker Manage
WidgetRules
Blinking IoT Led
TrustyEthernet cable
Potentiometer Sensor CodeDevice.Send(String(potRead), pot); //Reads and sends pot
LED Actuator codeif (command == "false") { digitalWrite(led, LOW); //Turns LED off } else if (command == "true") { digitalWrite(led, HIGH); //Turns LED on}
SmartLiving API’shttpServer = "api.smartliving.io"; mqttServer = "broker.smartliving.io";
Automation RuleWhen
Arduino.pot > 500Then
Arduino.led = trueElse
Arduino.led = false
SmartLiving ToolboxEND POINTS CONNECTIVITY MIDDLEWARE IOT SERVICES APPS
ArduinoRaspberry
Pi
Android Makers
App
Virtual actuator
Virtual sensors
iOS App
Web app WidgetsZWave Devices
Solu
tio
nsD
ev T
oo
ls
C Lib
Android Gateway
Arduino Gateway
PUBSUB Clients
REST Clients
Raspberry Pi Makers Gateway
Management
Telemetry DB
Rule Engine
Automation Scripting
Rule Wizard
SERIALTCP/IP
ZWAVE
XBEE
Python Lib
JS Lib
WidgetLib
Node.js Lib
Go Lib
433 Mhz
IR!!?
Polymer Widgets
Web Services
ZigBee
Custom microcont
rollers
Java Lib
Plenty of existing
resources here
SmartLiving pub:sub Broker
ZWave IPv6
Gateway
Library & API’S
Endpoints (Hardware and libs)
● Arduino/C● Python● Node.js● C#● Javascript (HTML5-browser-as-a-sensor)
Middleware
● Python Gateway● C++ Gateway● XBee Gateway
IOT Services
● REST API - Gateway, Device, Asset, Rules,
Users ● Telemetry API - Sensor data, actuator
commands
● Automation rules, scripting & API
Apps
● Javascript Widgets
Arduino - setupvoid setup(){ pinMode(ledPin, OUTPUT); // initialize the digital pin as an output. Serial.begin(9600); // init serial link for debugging byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0xE1, 0x3E}; // Adapt to your Arduino MAC Address
if (Ethernet.begin(mac) == 0) // Initialize the Ethernet connection: { Serial.println(F("DHCP failed,end")); while(true); //we failed to connect, halt execution here. }
delay(1000); //give the Ethernet shield a second to initialize: if(Device.Connect(ðClient, httpServer)) //connect the device with the IOT platform. {
Device.AddAsset(knobPin, "Potentiometer", "A rotary sensor pot",false, "int"); //pin, name, desc, assetType, dataPro
Device.AddAsset(ledPin, "LED", "A blinky light emitting diode", true, "bool"); //pin, name, desc, assetType, dataPro
Device.Subscribe(pubSub); } }
Arduino - sensor read loopvoid loop(){ unsigned long curTime = millis(); if (curTime > (time + 1000)) // publish light reading every 5 seconds to sensor 1 { unsigned int lightRead = analogRead(knobPin); // read from light sensor (photocell) if(prevVal != lightRead){
Device.Send(String(lightRead), knobPin); prevVal = lightRead;
} time = curTime; } Device.Process(); }
Arduino - actuator callbackvoid callback(char* topic, byte* payload, unsigned int length) { String msgString; {
char message_buff[length + 1];strncpy(message_buff, (char*)payload, length);message_buff[length] = '\0';
msgString = String(message_buff); } int* idOut = NULL; { int pinNr = Device.GetPinNr(topic, strlen(topic)); //Find what topic hooks to the pin
if (pinNr == ledPin) { if (msgString == "false") { digitalWrite(ledPin, LOW); //led off idOut = &ledPin; } else if (msgString == "true") { digitalWrite(ledPin, HIGH); //led on idOut = &ledPin; } } } Device.Send(msgString, *idOut); //Acknowledges the LED was activated and confirm in the user interface}
Python Pi - Summary
IOT.connect()IOT.addAsset(knobPin, sensorName, "Push button", False, "int")IOT.addAsset(ledPin, actuatorName, "Light Emitting Diode", True, "bool")IOT.subscribe()
while True: try: if grovepi.digitalRead(sensorPin) == 1: if sensorPrev == False: IOT.send("true", sensorPin) sensorPrev = True elif sensorPrev == True: IOT.send("false", sensorPin) sensorPrev = False sleep(.3)
Node.js - Summaryvar a0 = new mraa.Aio(0); //setup access analog input Analog pin #0 (A0)var d8 = new mraa.Gpio(8); //LED hooked up to digital pin 13 (or built in pin on Galileo Gen1 & Gen2)d8.dir(mraa.DIR_OUT); //set the gpio direction to output
smartliving.addAsset("2", "Missile launcher", "Fires 10xD missiles at incoming spacecraft, and also a neat LED for some visual feedback...", true, "bool", confirmEnroll());smartliving.addAsset("3", "Thermoreactor turbine temperature ", "Monitors the temperature of main alpha turbine", false, "int", confirmEnroll());
smartliving.subscribe(smartliving.baseMQTTUrl, 1883);
vloop();
function vloop(){ var analogValue = a0.read(); //read the value of the analog pin
smartliving.send(analogValue, "3") setTimeout(vloop,1000);}
smartliving.registerActuatorCallback("2", function() { d8.write(ledState?1:0); //if ledState is true then write a '1' (high) otherwise write a '0' (low) ledState = !ledState; //invert the ledState});
Rules
FYI● Rule wizard doesn’t support complex operators like &&, ||● Create a script and run it in the cloud if you need crazy logic
Hackathon Ethos
Fake it, until you make it (literally)
● Hackathons always have network issues
● Hardware is normally limited or even shared
● Mock data is easy● Things always go wrong● Fancy UI elements always look
good
KISS, Hardware is Hard, Retrofit
● Nest is just a potentiometer, temp, PIR sensor
● GNL is just a LED & Push Button● Hue is just a RGB● Wemo is just a Relay
MVP Mentality
● Build small think big (What’s the story behind your use case)
● High impact features first
Brainstorming IoT
The problem - Short sharp sentence describing the story of your problem and how the solution solves it
Topology diagram - Visualise what you’re going to build, show the inputs and outputs and use it to explain your idea
THINGS - What are the dumb objects?
END POINTS - What computers and sensors are need to make things smarter?
DATA MODEL - What type of data will the Things produce? What are the inputs/outputs?
MIDDLEWARE - How will devices communicate? one-one, one-many?
AUTOMATION - When this event happens then do this event?
UI - Mockups and wireframes
HUMANS - Who are the most important people using the solution?
ResourcesGet your SmartLiving IoT Starter Kit
www.smartliving.io/kits
The platform
beta.smartliving.io
Documentation
http://docs.smartliving.io/Get_Started
GitHub
https://github.com/allthingstalk
API Reference
http://allthingstalk.github.io/api-docs