37
Session 8 th Nov 2011 Intro to Pachube and the “Internet of Things” Paul Tanner Virtual Technologies @paul_tanner ~ [email protected]

Uni w pachube 111108

Embed Size (px)

DESCRIPTION

Talk at Uni Westminster 111108

Citation preview

Page 1: Uni w pachube 111108

Session 8th Nov 2011

Intro to Pachubeand the “Internet of Things”

Paul Tanner

Virtual Technologies@paul_tanner ~ [email protected]

Page 2: Uni w pachube 111108

Agenda

● The “Internet of Things”● What's Pachube● Why it's important● Who's using it● How to use it● Getting help● Questions

Page 3: Uni w pachube 111108

Me and You?

● Independent Systems Consultant, Systems Integrator, Maker

● Background in electronics and software● Part of network(s) of implementors● Active member of Pachube community

● How about y'all?

Page 4: Uni w pachube 111108

The Internet of Things

● Internet: Email → Web → IoT● Devices: Mainframe → Mini → PC → IoT● Where people and things are connected● Related issues

● Open Data● Security and Privacy● Machine intelligence

● Scope today: “Smart Object” connectivity

Page 5: Uni w pachube 111108
Page 6: Uni w pachube 111108

IoT Evolution

● Discoverable devices● Devices online● Devices controllable● Devices interoperate● Smart devices

Page 7: Uni w pachube 111108

IoT Model

Page 8: Uni w pachube 111108

Physical Deployment

Page 9: Uni w pachube 111108

What's Pachube

● A cloud-based aggregation service● An “Application Programming Interface (API)”● A website based on that API

● Search and find data feeds● Create and manage your own feeds

– Sensors (e.g. thermometer, power meter)– Actuators (e.g. control something)

● Use “Apps” for visualisation and control– Graphs, Dashboards (web and phone) etc.

● Almost everything can be done via the API

Page 10: Uni w pachube 111108

Key Characteristics

● Open API● Ability to handle volume of data● Searchable● Shareable● Built-in privacy controls● Range of data formats● Large number of connected devices● Great user community

Page 11: Uni w pachube 111108

The Website● www.pachube.com● Search and find data feeds● Create account(s)● Create feeds● Add datastreams

www.pachube.com/feeds/1539 ● Manage privacy settings, triggers etc.● Access “Apps” https://apps.pachube.com

Page 12: Uni w pachube 111108

The API

● Basic API (GET/ PUT)● REpresentational State Transfer (REST)● Data Formats and Metadata● Security and Privacy● Triggers● History● Sockets & Websockets● Apps

Page 13: Uni w pachube 111108

Sensor Example

Nanode

Proximitysensor

Pachube Web Page

(Arduino + Internet)

Router

(Uses PUT and GET APIs)

Page 14: Uni w pachube 111108

Actuator Example

Phone Pachube MBED w.Radio

WirelessSocket

(Uses PUT and SUBSCRIBE APIs)

Page 15: Uni w pachube 111108

Compatible Devices e.g.

Page 16: Uni w pachube 111108

Importance

● Anyone can put up a server, right?● “Internet of Silos” vs. API standards● IoT growth is about:

● availability of data● low cost of implementation● diversity/ cross-sector capability

● Pachube ticks all the boxes – and is now free!

Page 17: Uni w pachube 111108

Who's Using It

● Power monitoring/ management● Home automation● Environmental monitoring● Radiation monitoring● General automation

● What would you use it for?

Page 18: Uni w pachube 111108

Real Examples

Search Pachube for:● Energy Monitors● Weather Stations● Radiation Monitors

Page 19: Uni w pachube 111108

Live on homepage

Page 20: Uni w pachube 111108
Page 21: Uni w pachube 111108

Basic API

● http://api.pachube.com/v2/ ● GET/ PUT/ POST● GET needs URL only● /v2/feeds/504 or /v2/feeds/504/datastreams/0● .csv/.json/.xml – format selector● ?api_key=xxxxxxxxxxxxx (unless logged in)● POST needs headers incl. api_key and accept● Use curl for testing

Page 22: Uni w pachube 111108

GET Example

char msg[] = "{\"method\":\"get\",\"resource\":\"/feeds/504/datastreams/1\",\"headers\":{\"X-PachubeApiKey\":\"xxxxxxxxx\"}}";

Ethernet.begin(mac, ip,gateway,subnet);Serial.println("Connecting ..");if (client.connect()) { Serial.println("Connected"); client.print(msg); while (!client.available()) {} Serial.print("Receiving:"); do { c = client.read(); buffer[len++] = c; Serial.print(c); } while (client.available()); buffer[len]='\0'; Serial.println();}

{ "current_value":"100", "max_value":"10000.0", "at":"2010-07-02T10:16:19.270708Z", "min_value":"-10.0", "tags":[ "humidity" ], "id":"1"}

curl --request GET --header "X-PachubeApiKey: YOUR_API_KEY_HERE" http://api.pachube.com/v2/feeds/504/datastreams/1

Page 23: Uni w pachube 111108

PUT Example

{ "method": "put", "resource": "/feeds/38728", "headers": { "X-PachubeApiKey":"my_api_key" }, "body": { "version": "1.0.0", "datastreams": [ { "id": "pir", "current_value": "1" }, { "id":"pot", "current_value":"245" } ] }}

char pld[]="{\"method\":\"put\",\"resource\":\"/feeds/38728\",\"headers\":{\"X-PachubeApiKey\":\"my_api_key\"}, \"body\":{\"version\":\"1.0.0\",\"datastreams\":[{\"id\":\"pir\",\"current_value\":\”1\"},{\"id\":\"pot\",\"current_value\":\"245\"}]}}";

void post_callback(status,datapos) { Serial,println(status);}

es.ES_client_http_post(“/feeds/38728”,"api.pachube.com", “”, "PUT", pld, &post_callback);

curl --request PUT --data-binary @datafile.txt --header "X-PachubeApiKey: YOUR_API_KEY_HERE" http://api.pachube.com/v2/feeds/504/datastreams/1

Page 24: Uni w pachube 111108

Data Formats

● .csv most compact● .xml most flexible● .json usually the best compromise

● Not verbose● Allows access to all fields/ attributes● Tolerates adding fields etc● Simple to program

Page 25: Uni w pachube 111108

Attributes

● Feeds: description, location, tags etc● Datastreams: id, tags, units● Good for searching but, as yet, no standard

vocab for tags

Page 26: Uni w pachube 111108

Security & Privacy

● By default, all feeds are public for read● Pro a/c can restrict to private: key required● Your master key: tantamount to giving out your

password so keep it safe.● Restricted keys can be generated for a specific

feed or datastream:● Read-only, Write only, Read-write

● Groups of users can be associated with a key● COMING SOON: oauth - additional security

Page 27: Uni w pachube 111108

Triggers

● Make things happen: set a trigger on a feed or datastream

● gt, gte, lt, lte, eq, change● Calls your designated URL with the value of the

data; requires that a server be listening.● With appropriate opening in server's firewall● Sockets provide an attractive alternative

Page 28: Uni w pachube 111108

History

● All datapoints stored by default● Can be created, updated, deleted● Various granularities available to pull in bulk

● All datapoints: up to 6 hours worth (start/ end)● Daily data up to 1 year

● http://api.pachube.com/v2/ .. for details● Multiple calls needed to get more

Page 29: Uni w pachube 111108

Sockets/ Websockets

● Part of the beta API – subject to conditions● http://api.pachube.com/v2/beta/ ● TCP sockets very useful for actuators as there

is no need for polling● Websockets (in certain browsers) are perfect

for visualisations, dashboards etc.

Page 30: Uni w pachube 111108

Apps

● http://apps.pachube.com/ - mostly OK● http://beta.apps.pachube.com/ - careful!! ● Numerous “Apps” provided – mainly

visualisation components● This is gradually being opened up for

community contributions.● Not everything works yet – change of plan● Announcement expected Real Soon Now

Page 31: Uni w pachube 111108

App types

● Graphs and Visualisations● Dashboards and Controllers● Mapping Tools● Mashups and Converters● Alerts and Plugins● Feed discovery● Mobile Phone Apps● Augmented Reality● Energy Apps and Gadgets

Page 32: Uni w pachube 111108

IoT Model

Page 33: Uni w pachube 111108

IoT Apps Engine

● Make things happen in response to sensors● Make it as easy as possible for non-techies to

develop and iterate apps.● Declare a set of sensors and actuators● Describe actions based on input changes and

arbitrarily complex calculations● Include external data and cause external actions

(eg. Tweet/ call/ mail)

● Currently at prototype stage● Looking for the right partners to evaluate

Page 34: Uni w pachube 111108

Example App

Page 35: Uni w pachube 111108

Getting Help

● http://community.pachube.com/● Arduino Community http://arduino.org/ ● MBED forum http://mbed.org/forum/ ● Hackspace https://london.hackspace.org.uk/ ● [email protected] ● .. not to mention www.google.co.uk ● .. leading to numerous blogs

Page 36: Uni w pachube 111108

Suppliers

Apologies for an incomplete list ..● oomlout.co.uk● skpang.co.uk● coolcomponents.co.uk● rs-components.co.uk● nuelectronics.com● Via london.hackspace.org.uk

Page 37: Uni w pachube 111108

Questions?

@paul_tanner ~ [email protected]

http://www.slideshare.net/paul_tanner/uni-w-pachube-111108