Session 8th Nov 2011
Intro to Pachubeand the “Internet of Things”
Paul Tanner
Virtual Technologies@paul_tanner ~ [email protected]
Agenda
● The “Internet of Things”● What's Pachube● Why it's important● Who's using it● How to use it● Getting help● Questions
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?
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
IoT Evolution
● Discoverable devices● Devices online● Devices controllable● Devices interoperate● Smart devices
IoT Model
Physical Deployment
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
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
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
The API
● Basic API (GET/ PUT)● REpresentational State Transfer (REST)● Data Formats and Metadata● Security and Privacy● Triggers● History● Sockets & Websockets● Apps
Sensor Example
Nanode
Proximitysensor
Pachube Web Page
(Arduino + Internet)
Router
(Uses PUT and GET APIs)
Actuator Example
Phone Pachube MBED w.Radio
WirelessSocket
(Uses PUT and SUBSCRIBE APIs)
Compatible Devices e.g.
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!
Who's Using It
● Power monitoring/ management● Home automation● Environmental monitoring● Radiation monitoring● General automation
● What would you use it for?
Real Examples
Search Pachube for:● Energy Monitors● Weather Stations● Radiation Monitors
Live on homepage
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
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
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
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
Attributes
● Feeds: description, location, tags etc● Datastreams: id, tags, units● Good for searching but, as yet, no standard
vocab for tags
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
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
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
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.
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
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
IoT Model
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
Example App
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
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
Questions?
@paul_tanner ~ [email protected]
http://www.slideshare.net/paul_tanner/uni-w-pachube-111108
Top Related