SlideShare a Scribd company logo
IOTDB.org 
• 
Control all the Things 
with Node-JS
David Janes 
@dpjanes 
davidjanes@iotdb.org 
http://iotdb.org/social/imadeit/ 
November 2014
Introduction
N.B. 
• Demo example code on github 
• dpjanes/ 
• iotdb-examples/ 
• demos/ 
• 2014-11-fsto/
What is it? 
{ 
"on" : true, 
"temperature" : 225 
}
What does each field 
mean?
Control or 
Measurement? 
• Does on mean: 
• Turn it on? or 
• Is it on? 
• Does temperature mean: 
• Set the temperature? or 
• What is the temperature?
Units 
• What does temperature refer to? 
• degrees Celsius, Fahrenheit … or Kelvin?
What does the whole 
message represent?
What are we talking 
about … or with? 
• An oven? 
• A toaster? 
• A sensor in the Large Hadron Collider?
Solve “the Basket Full 
of Remotes Apps 
Problem”
Control all the Things with Node-JS
Solve the N-standards 
• Open Interconnect 
Consortium 
• Thread Group 
• AllSeen Alliance 
• HyperCat Consortium 
• Industrial Internet 
Consortium 
• IoT-GSI) from ITU-T 
• oneM2M 
• Open Mobile Alliance 
• Internet of Things (IEE) 
• IETF 
• IPSO Alliance
XKCD
IOTDB(.org)
Semantic Vocab 
• Formal definitions 
• https://iotdb.org/pub 
• JSON-LD
Models 
• https://iotdb.org/iotdb 
• https://github.com/dpjanes/iotdb-models
Node-IOTDB
IOTDB Stack 
• Client Program 
• Node-IOTDB 
• Models 
• Drivers 
• Libraries 
•simple_on.js 
•require('iotdb') 
•WeMoSwitch 
•iot-driver:upnp 
•upnplib
Client Program 
simple_red 
iot 
.connect() 
.set(':color', 'red');
require(‘iotdb’) 
• locates Models, Drivers, Stores,… 
• loads & maintains user configuration 
• connects to iotdb.org (sometimes) 
• manages Things (huge deal … too many 
things to go into in detail)
Model (I) 
• Semantic description of Things 
• (can be) written in JavaScript 
• actually compiles to JSON-LD (with some 
restrained JavaScript) 
• Node independent!
Model (II) 
iotdb.make_model('WeMoSwitch') 
.facet(":device.switch") 
.product(“http://www.belkin.com/…”) 
.name("WeMo Switch") 
.description("Belkin WeMo Switch") 
.attribute( 
iotdb.make_boolean(":on") 
.name("on / off") 
.control() 
)
Model (III) 
.driver_out(function(paramd) { 
if (paramd.thingd.on !== undefined) { 
paramd.driverd['urn:Belkin:service:basicevent:1'] = { 
'SetBinaryState' : { 
'BinaryState' : paramd.thingd.on ? 1 : 0 
} 
} 
} 
})
Drivers 
iot-driver:upnp 
• Binds Models to the code that actually 
“does the work” 
• discovery 
• static configuration 
• dynamic / environmental
Libraries 
• What developers usually program against 
• We’ve rewritten a number of libraries to 
make them more reliable
Demos
simple_on 
things = iot.connect() 
things.set(':on', true);
simple_off 
things = iot.connect() 
things.set(‘:on’, false);
simple_model 
iot 
.connect(‘HueLight') 
.set(':on', true);
Metadata
Select Things 
• select Things by (e.g.) 
• Model 
• name 
• number 
• place 
• facet
meta_dump 
var things = iot.connect(); 
iot.on_things(function() { 
console.log(things.metas()); 
});
meta_model 
iot.connect() 
.with_model("TCPConnectedLight") 
.set(':on', false)
meta_name 
iot 
.connect() 
.with_name("Hue Lamp 2") 
.set(':color', 'purple')
meta_number 
iot 
.connect() 
.with_number(3) 
.set(':color', 'cyan')
meta_place 
iot 
.connect() 
.with_room("David Bedroom") 
.with_floor("Second Floor") 
.set(':color', 'green')
meta_facet 
iot 
.connect() 
.with_facet(":device.lighting") 
.set(':on', true);
where does Metadata 
come from? 
• Metadata comes from several places 
• can be altered in code 
• can be persisted to locally / to disk 
• can be retrieved from iotdb.org 
• “inherent” in the Model / Driver
Events
two types of events 
• thing.on(key, callback) 
• thing.on_change(callback)
event_brightness 
var lights = iot.connect() 
var input = iot.connect({ 
model: "FirmataInputUnit", 
pin: 0 
}); 
input.on(":value", function(thing, attribute, value) { 
lights.set(':brightness', value); 
})
event_fob 
var things = iot.connect(); 
iot 
.connect('TIKeyFob') 
.on('left', function() { 
things.set(':on', true); 
}) 
.on('right', function() { 
things.set(':on', false); 
})
Arduino / Firmata
firmata_cycle 
var things = iot 
.connect() 
.connect({ 
model: "FirmataNeoPixel", 
pin: 6, 
n: 16 
}) 
var colors = [ "red", "green", "blue", "white", "black" ]; 
var ci = 0; 
setInterval(function() { 
things.set(":color", colors[ci++ % colors.length]); 
}, 2500)
firmata_neopixel 
var n = 16; 
var leds = iot.connect({ 
model: "FirmataNeoPixel", 
pin: 6, 
n: n 
}) 
var c = new iotdb.libs.Color() 
var ci = 0; 
var cf = 0; 
setInterval(function() { 
c.set_hsl(cf, 1, 0.5) 
cf += 0.015; 
if (cf > 1) cf = 0; 
leds 
.with_number(ci++ % n) 
.set(":color", c.get_hex()) 
; 
}, 50)
Arduino Models 
• FirmataChainableLED 
• FirmataDHT11 
• FirmataGroveThermistor 
• FirmataInputBoolean 
• FirmataInputUnit 
• FirmataLightDimmer 
• FirmataLightSensor 
• FirmataLightSimple 
• FirmataMotionSensor 
• FirmataNeoPixel 
• FirmataOn 
• FirmataOutputBoolean
Stores
Available Stores 
• dweet 
• http 
• mqtt 
• phant 
• pubnub 
• thingspeak
store_phant 
var input = iot.connect('TIKeyFob') 
var store = iot 
.store('phant') 
.track(input) 
https://data.sparkfun.com/streams/aGNjQK9RwZHgEmx089Lg
store_mqtt 
var input = iot.connect({ 
model: "FirmataInputUnit", 
pin: 0 
}); 
var store = iot 
.store('mqtt') 
.track(input) 
mqtt.iotdb.org u/dpjanes/#
Transmogrifiers
Control all the Things with Node-JS
What if we have the 
wrong thing? 
• Have Celsius but want Fahrenheit 
• Want to set brightness but only have color 
• What if brightness is 0-100 on one device 
and 0-1 on another 
• Average data? Max data over time? &c…
trans_fahrenheit 
var t_c = iot.connect("FirmataDHT11") 
t_c.on('temperature', function(thing, attribute, value) { 
console.log("+ temperature (C)", value) 
}) 
var t_f = t_c.transmogrify( 
iot.transmogrifier(":imperial/fahrenheit")) 
t_f.on('temperature', function(thing, attribute, value) { 
console.log("+ temperature (F)", value) 
})
warning 
• transmogrifiers are very much a work in 
progress! 
• not even pushed to npm yet
Takeaways
IOTDB 
• Semantic description of how things work
Node-IOTDB 
• Powerful language for controlling things 
• Builds on IOTDB concepts 
• Strong alpha 
• Join! Help!
Modeling 
{ 
"@context": "./meta-iri.jsonld", 
"on": true, 
"temperature": 225 
} 
Note: @context is just one way of doing this!
N.B. 
• The data does not have to be JSON! 
• You don’t need to have IOTDB! 
• You don’t need to use IOTDB IRIs (but you 
should) 
• https://iotdb.org/pub/
Additional Resources 
• Many examples + House of Janes 
https://github.com/dpjanes/iotdb-examples 
• Getting started 
https://iotdb.org/docs/node/getting-started 
• Concepts 
https://medium.com/@dpjanes
One last point 
• Don’t be misled by the simplicity! 
• I worked backward from “what do I want 
to do” to get the code 
• Way more things than I demoed today 
• I want to work with you!
Get in touch! 
David Janes 
@dpjanes 
davidjanes@iotdb.org 
http://iotdb.org/social/imadeit/

More Related Content

PDF
Semantic Metastandards will Unlock IoT Interoperability
PDF
Interoperability with Standardless IoT (Global IoT Day Wien)
PDF
Semantic and the Internet of Things
PDF
What a Thing API Should Look Like (Global IoT Day Wien)
PDF
Atoms - Semantic Interoperability
PDF
IOTDB, Semantics and the Internet of Things
PDF
Riding the Edge with Ember.js
PDF
IOTDB - Semantic Metadata for the Internet of Things
Semantic Metastandards will Unlock IoT Interoperability
Interoperability with Standardless IoT (Global IoT Day Wien)
Semantic and the Internet of Things
What a Thing API Should Look Like (Global IoT Day Wien)
Atoms - Semantic Interoperability
IOTDB, Semantics and the Internet of Things
Riding the Edge with Ember.js
IOTDB - Semantic Metadata for the Internet of Things

Similar to Control all the Things with Node-JS (20)

PPTX
HEART DISEASE PROBLEM CHECKING IN THE SYSTEM USING SOME OPERATINGS
PPTX
Getting Started with the Internet of Things - Allianz Hackrisk Hackathon 29/...
PDF
Using Java Script and COMPOSE to build cool IoT applications, SenZations 2015
PPTX
Internet of Things - block buildings Unit 2.pptx
PDF
IoT-javascript-2019-fosdem
PPTX
SenchaCon 2016: An Ext JS Dashboard for IoT Data - Dan Gallo
PPTX
Introduction to FIWARE IoT
PDF
From the internet of things to the web of things course
PDF
Internet of Things exercise on IBM Bluemix
PDF
Review paper on IoT based technology
PPTX
III CSE IoT Unit - I.pptx
PDF
IoT Toolkit and the Smart Object API Tutorial Introduction
PDF
IoT Toolkit and Smart Object API Tutorial Introduction
PDF
Smart objectapi tutorial 092013
PPTX
Designing and Implementing your IOT Solutions with Open Source
PDF
Industrial Automation Monitor and Control using IoT
PPTX
Azure Internet of Things
PPTX
Bare metal Javascript & GPIO programming in Linux
PPTX
Why we need internet of things on Node.js
PPTX
Technical seminar on it design by varsha
HEART DISEASE PROBLEM CHECKING IN THE SYSTEM USING SOME OPERATINGS
Getting Started with the Internet of Things - Allianz Hackrisk Hackathon 29/...
Using Java Script and COMPOSE to build cool IoT applications, SenZations 2015
Internet of Things - block buildings Unit 2.pptx
IoT-javascript-2019-fosdem
SenchaCon 2016: An Ext JS Dashboard for IoT Data - Dan Gallo
Introduction to FIWARE IoT
From the internet of things to the web of things course
Internet of Things exercise on IBM Bluemix
Review paper on IoT based technology
III CSE IoT Unit - I.pptx
IoT Toolkit and the Smart Object API Tutorial Introduction
IoT Toolkit and Smart Object API Tutorial Introduction
Smart objectapi tutorial 092013
Designing and Implementing your IOT Solutions with Open Source
Industrial Automation Monitor and Control using IoT
Azure Internet of Things
Bare metal Javascript & GPIO programming in Linux
Why we need internet of things on Node.js
Technical seminar on it design by varsha
Ad

Recently uploaded (20)

PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
System and Network Administraation Chapter 3
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Designing Intelligence for the Shop Floor.pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPT
Introduction Database Management System for Course Database
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Introduction to Artificial Intelligence
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Transform Your Business with a Software ERP System
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PTS Company Brochure 2025 (1).pdf.......
Digital Systems & Binary Numbers (comprehensive )
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
System and Network Administraation Chapter 3
Wondershare Filmora 15 Crack With Activation Key [2025
Design an Analysis of Algorithms I-SECS-1021-03
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Upgrade and Innovation Strategies for SAP ERP Customers
Designing Intelligence for the Shop Floor.pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Introduction Database Management System for Course Database
How to Choose the Right IT Partner for Your Business in Malaysia
Introduction to Artificial Intelligence
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Transform Your Business with a Software ERP System
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Ad

Control all the Things with Node-JS

  • 1. IOTDB.org • Control all the Things with Node-JS
  • 2. David Janes @dpjanes davidjanes@iotdb.org http://iotdb.org/social/imadeit/ November 2014
  • 4. N.B. • Demo example code on github • dpjanes/ • iotdb-examples/ • demos/ • 2014-11-fsto/
  • 5. What is it? { "on" : true, "temperature" : 225 }
  • 6. What does each field mean?
  • 7. Control or Measurement? • Does on mean: • Turn it on? or • Is it on? • Does temperature mean: • Set the temperature? or • What is the temperature?
  • 8. Units • What does temperature refer to? • degrees Celsius, Fahrenheit … or Kelvin?
  • 9. What does the whole message represent?
  • 10. What are we talking about … or with? • An oven? • A toaster? • A sensor in the Large Hadron Collider?
  • 11. Solve “the Basket Full of Remotes Apps Problem”
  • 13. Solve the N-standards • Open Interconnect Consortium • Thread Group • AllSeen Alliance • HyperCat Consortium • Industrial Internet Consortium • IoT-GSI) from ITU-T • oneM2M • Open Mobile Alliance • Internet of Things (IEE) • IETF • IPSO Alliance
  • 14. XKCD
  • 16. Semantic Vocab • Formal definitions • https://iotdb.org/pub • JSON-LD
  • 17. Models • https://iotdb.org/iotdb • https://github.com/dpjanes/iotdb-models
  • 19. IOTDB Stack • Client Program • Node-IOTDB • Models • Drivers • Libraries •simple_on.js •require('iotdb') •WeMoSwitch •iot-driver:upnp •upnplib
  • 20. Client Program simple_red iot .connect() .set(':color', 'red');
  • 21. require(‘iotdb’) • locates Models, Drivers, Stores,… • loads & maintains user configuration • connects to iotdb.org (sometimes) • manages Things (huge deal … too many things to go into in detail)
  • 22. Model (I) • Semantic description of Things • (can be) written in JavaScript • actually compiles to JSON-LD (with some restrained JavaScript) • Node independent!
  • 23. Model (II) iotdb.make_model('WeMoSwitch') .facet(":device.switch") .product(“http://www.belkin.com/…”) .name("WeMo Switch") .description("Belkin WeMo Switch") .attribute( iotdb.make_boolean(":on") .name("on / off") .control() )
  • 24. Model (III) .driver_out(function(paramd) { if (paramd.thingd.on !== undefined) { paramd.driverd['urn:Belkin:service:basicevent:1'] = { 'SetBinaryState' : { 'BinaryState' : paramd.thingd.on ? 1 : 0 } } } })
  • 25. Drivers iot-driver:upnp • Binds Models to the code that actually “does the work” • discovery • static configuration • dynamic / environmental
  • 26. Libraries • What developers usually program against • We’ve rewritten a number of libraries to make them more reliable
  • 27. Demos
  • 28. simple_on things = iot.connect() things.set(':on', true);
  • 29. simple_off things = iot.connect() things.set(‘:on’, false);
  • 32. Select Things • select Things by (e.g.) • Model • name • number • place • facet
  • 33. meta_dump var things = iot.connect(); iot.on_things(function() { console.log(things.metas()); });
  • 35. meta_name iot .connect() .with_name("Hue Lamp 2") .set(':color', 'purple')
  • 36. meta_number iot .connect() .with_number(3) .set(':color', 'cyan')
  • 37. meta_place iot .connect() .with_room("David Bedroom") .with_floor("Second Floor") .set(':color', 'green')
  • 38. meta_facet iot .connect() .with_facet(":device.lighting") .set(':on', true);
  • 39. where does Metadata come from? • Metadata comes from several places • can be altered in code • can be persisted to locally / to disk • can be retrieved from iotdb.org • “inherent” in the Model / Driver
  • 41. two types of events • thing.on(key, callback) • thing.on_change(callback)
  • 42. event_brightness var lights = iot.connect() var input = iot.connect({ model: "FirmataInputUnit", pin: 0 }); input.on(":value", function(thing, attribute, value) { lights.set(':brightness', value); })
  • 43. event_fob var things = iot.connect(); iot .connect('TIKeyFob') .on('left', function() { things.set(':on', true); }) .on('right', function() { things.set(':on', false); })
  • 45. firmata_cycle var things = iot .connect() .connect({ model: "FirmataNeoPixel", pin: 6, n: 16 }) var colors = [ "red", "green", "blue", "white", "black" ]; var ci = 0; setInterval(function() { things.set(":color", colors[ci++ % colors.length]); }, 2500)
  • 46. firmata_neopixel var n = 16; var leds = iot.connect({ model: "FirmataNeoPixel", pin: 6, n: n }) var c = new iotdb.libs.Color() var ci = 0; var cf = 0; setInterval(function() { c.set_hsl(cf, 1, 0.5) cf += 0.015; if (cf > 1) cf = 0; leds .with_number(ci++ % n) .set(":color", c.get_hex()) ; }, 50)
  • 47. Arduino Models • FirmataChainableLED • FirmataDHT11 • FirmataGroveThermistor • FirmataInputBoolean • FirmataInputUnit • FirmataLightDimmer • FirmataLightSensor • FirmataLightSimple • FirmataMotionSensor • FirmataNeoPixel • FirmataOn • FirmataOutputBoolean
  • 49. Available Stores • dweet • http • mqtt • phant • pubnub • thingspeak
  • 50. store_phant var input = iot.connect('TIKeyFob') var store = iot .store('phant') .track(input) https://data.sparkfun.com/streams/aGNjQK9RwZHgEmx089Lg
  • 51. store_mqtt var input = iot.connect({ model: "FirmataInputUnit", pin: 0 }); var store = iot .store('mqtt') .track(input) mqtt.iotdb.org u/dpjanes/#
  • 54. What if we have the wrong thing? • Have Celsius but want Fahrenheit • Want to set brightness but only have color • What if brightness is 0-100 on one device and 0-1 on another • Average data? Max data over time? &c…
  • 55. trans_fahrenheit var t_c = iot.connect("FirmataDHT11") t_c.on('temperature', function(thing, attribute, value) { console.log("+ temperature (C)", value) }) var t_f = t_c.transmogrify( iot.transmogrifier(":imperial/fahrenheit")) t_f.on('temperature', function(thing, attribute, value) { console.log("+ temperature (F)", value) })
  • 56. warning • transmogrifiers are very much a work in progress! • not even pushed to npm yet
  • 58. IOTDB • Semantic description of how things work
  • 59. Node-IOTDB • Powerful language for controlling things • Builds on IOTDB concepts • Strong alpha • Join! Help!
  • 60. Modeling { "@context": "./meta-iri.jsonld", "on": true, "temperature": 225 } Note: @context is just one way of doing this!
  • 61. N.B. • The data does not have to be JSON! • You don’t need to have IOTDB! • You don’t need to use IOTDB IRIs (but you should) • https://iotdb.org/pub/
  • 62. Additional Resources • Many examples + House of Janes https://github.com/dpjanes/iotdb-examples • Getting started https://iotdb.org/docs/node/getting-started • Concepts https://medium.com/@dpjanes
  • 63. One last point • Don’t be misled by the simplicity! • I worked backward from “what do I want to do” to get the code • Way more things than I demoed today • I want to work with you!
  • 64. Get in touch! David Janes @dpjanes davidjanes@iotdb.org http://iotdb.org/social/imadeit/