SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Downloaden Sie, um offline zu lesen
How to build a depression
predictor
(a.k.a. a belgian weather station)
using Arduino & Node.js
@stevenbeeckman #iotbe #njugbe
In short
Arduino IDE: arduino.cc/dowload
Install StandardFirmata sketch on the Arduino
npm install johnny-five
write your script.js
Run node script.js
You need a host
computer connected to
the Arduino
Let’s build a depression
predictor
(or a belgian weather station)
Things we need
A sensor
Something to gather the sensor data
Something to store the generated timeseries
A visualisation
photoresistor Arduino MacBook Browsercloud
Heroku
+
node.js
+
hapi.js
+
Tempo
DB
add-on
photoresistor Arduino Uno
Node.js
+
Johnny Five
+
request
+
forever
TempoDB
web app
ADC http httpusb
Heroku
+
node.js
+
hapi.js
+
Tempo
DB
add-on
photoresistor Arduino Uno
Node.js
+
Johnny Five
+
request
+
forever
TempoDB
web app
ADC http httpusb
MacGyver-ism: no resistors in house and
no nearby shops to buy them from -> use
a piezo as a resistor
Heroku
+
node.js
+
hapi.js
+
Tempo
DB
add-on
photoresistor Arduino Uno
Node.js
+
Johnny Five
+
request
+
forever
TempoDB
web app
ADC http httpusb
Packages you need
npm install --save johnny-five
npm install --save request
npm install -g forever
usage:
forever start script.js
forever list (to see what’s running)
https://github.com/stevenbeeckman/arduino-j5
Heroku
+
node.js
+
hapi.js
+
Tempo
DB
add-on
photoresistor Arduino Uno
Node.js
+
Johnny Five
+
request
+
forever
TempoDB
web app
ADC http httpusb
Design
Need a REST API over HTTP
(Mandatory) POST new sensor values
(Optional) GET overview of past sensor values
Store data in a time series friendly database
Packages you need
"dependencies": {
"hapi": "^6.5.1",
"moment": "^2.8.2",
"tempodb": "^1.0.0"
}
https://github.com/stevenbeeckman/iotbe-njugbe/
Hosting
This code can run on your own server or in the
cloud.
I ran it in the cloud, on Heroku and used the
free TempoDB add-on.
Some code
var Hapi = require('hapi');
var server = new Hapi.Server(process.env.PORT || 3000);
server.route({
method: 'GET'
, path: '/'
, handler: function(request, reply){
reply('Hello, Internet of Things fans!');
}
});
server.start(function(){
console.log('Server running at:' + server.info.uri);
});
heroku create
git add index.js
git commit -m “First deploy.”
git push heroku master
http://iotbe-njugbe.herokuapp.com/
Writing to your TempoDB
var TempoDBClient = require('tempodb').TempoDBClient;
var tempodb = new TempoDBClient('heroku-5e2f03bd25cf424098426a8a21db26f3', process.env.TEMPODB_API_KEY, process.env.
TEMPODB_API_SECRET, {hostname: process.env.TEMPODB_API_HOST, port: process.env.TEMPODB_API_PORT});
var moment = require('moment');
server.route({
method: 'POST'
, path: '/sensor/{sensor_id}/measurement'
, config: {
handler: function(request, reply){
var newMeasurement = new Object();
newMeasurement.t = moment().format("YYYY-MM-DDTHH:mm:ss.SSSZZ");
newMeasurement.v = request.payload.value;
var tempodb_data = new Array();
tempodb_data.push(newMeasurement);
var series_key = 'sensor-' + request.params.sensor_id;
tempodb.write_key(series_key, tempodb_data, function(error, result){
error ? reply(error) : reply(result);
});
}
}
});
Writing to your TempoDB
var TempoDBClient = require('tempodb').TempoDBClient;
var tempodb = new TempoDBClient('heroku-5e2f03bd25cf424098426a8a21db26f3', process.env.TEMPODB_API_KEY, process.env.
TEMPODB_API_SECRET, {hostname: process.env.TEMPODB_API_HOST, port: process.env.TEMPODB_API_PORT});
var moment = require('moment');
server.route({
method: 'POST'
, path: '/sensor/{sensor_id}/measurement'
, config: {
handler: function(request, reply){
var newMeasurement = new Object();
newMeasurement.t = moment().format("YYYY-MM-DDTHH:mm:ss.SSSZZ");
newMeasurement.v = request.payload.value;
var tempodb_data = new Array();
tempodb_data.push(newMeasurement);
var series_key = 'sensor-' + request.params.sensor_id;
tempodb.write_key(series_key, tempodb_data, function(error, result){
error ? reply(error) : reply(result);
});
}
}
});
Not documented: date must be formatted.
new Date() will not work as is. Use moment.js for
easy formatting.
Writing to your TempoDB
var TempoDBClient = require('tempodb').TempoDBClient;
var tempodb = new TempoDBClient('heroku-5e2f03bd25cf424098426a8a21db26f3', process.env.TEMPODB_API_KEY, process.env.
TEMPODB_API_SECRET, {hostname: process.env.TEMPODB_API_HOST, port: process.env.TEMPODB_API_PORT});
var moment = require('moment');
server.route({
method: 'POST'
, path: '/sensor/{sensor_id}/measurement'
, config: {
handler: function(request, reply){
var newMeasurement = new Object();
newMeasurement.t = moment().format("YYYY-MM-DDTHH:mm:ss.SSSZZ");
newMeasurement.v = request.payload.value;
var tempodb_data = new Array();
tempodb_data.push(newMeasurement);
var series_key = 'sensor-' + request.params.sensor_id;
tempodb.write_key(series_key, tempodb_data, function(error, result){
error ? reply(error) : reply(result);
});
}
}
});
Single key value pairs {t,v} must be wrapped in an
Array too...
Writing to your TempoDB
var TempoDBClient = require('tempodb').TempoDBClient;
var tempodb = new TempoDBClient('heroku-5e2f03bd25cf424098426a8a21db26f3', process.env.TEMPODB_API_KEY, process.env.
TEMPODB_API_SECRET, {hostname: process.env.TEMPODB_API_HOST, port: process.env.TEMPODB_API_PORT});
var moment = require('moment');
server.route({
method: 'POST'
, path: '/sensor/{sensor_id}/measurement'
, config: {
handler: function(request, reply){
var newMeasurement = new Object();
newMeasurement.t = moment().format("YYYY-MM-DDTHH:mm:ss.SSSZZ");
newMeasurement.v = request.payload.value;
var tempodb_data = new Array();
tempodb_data.push(newMeasurement);
var series_key = 'sensor-' + request.params.sensor_id;
tempodb.write_key(series_key, tempodb_data, function(error, result){
error ? reply(error) : reply(result);
});
}
}
});
Warning:
You have to pass the TempoDB database name too,
which is not documented!
Heroku
+
node.js
+
hapi.js
+
Tempo
DB
add-on
photoresistor Arduino Uno
Node.js
+
Johnny Five
+
request
+
forever
TempoDB
web app
ADC http httpusb
MacBooks crash
too
hard drive failure
References
http://arduino.cc
https://github.com/rwaldron/johnny-five
http://blog.nodejitsu.com/keep-a-nodejs-server-up-with-
forever/
http://heroku.com
http://hapijs.com
http://momentjs.com
https://tempo-db.com
Questions?
@stevenbeeckman #iotbe #njugbe

Weitere ähnliche Inhalte

Was ist angesagt?

The Ring programming language version 1.5.4 book - Part 62 of 185
The Ring programming language version 1.5.4 book - Part 62 of 185The Ring programming language version 1.5.4 book - Part 62 of 185
The Ring programming language version 1.5.4 book - Part 62 of 185Mahmoud Samir Fayed
 
Hybrid quantum classical neural networks with pytorch and qiskit
Hybrid quantum classical neural networks with pytorch and qiskitHybrid quantum classical neural networks with pytorch and qiskit
Hybrid quantum classical neural networks with pytorch and qiskitVijayananda Mohire
 
倒计时优化点滴
倒计时优化点滴倒计时优化点滴
倒计时优化点滴j5726
 
Qsam simulator in IBM Quantum Lab cloud
Qsam simulator in IBM Quantum Lab cloudQsam simulator in IBM Quantum Lab cloud
Qsam simulator in IBM Quantum Lab cloudVijayananda Mohire
 
Service worker: discover the next web game changer
Service worker: discover the next web game changerService worker: discover the next web game changer
Service worker: discover the next web game changerSandro Paganotti
 
You will learn RxJS in 2017
You will learn RxJS in 2017You will learn RxJS in 2017
You will learn RxJS in 2017名辰 洪
 
Calculator code with scientific functions in java
Calculator code with scientific functions in java Calculator code with scientific functions in java
Calculator code with scientific functions in java Amna Nawazish
 
Star bed 2018.07.19
Star bed 2018.07.19Star bed 2018.07.19
Star bed 2018.07.19Ruo Ando
 
MongoDB World 2019: Life In Stitch-es
MongoDB World 2019: Life In Stitch-esMongoDB World 2019: Life In Stitch-es
MongoDB World 2019: Life In Stitch-esMongoDB
 
Monitoring und Metriken im Wunderland
Monitoring und Metriken im WunderlandMonitoring und Metriken im Wunderland
Monitoring und Metriken im WunderlandD
 
Async JavaScript in ES7
Async JavaScript in ES7Async JavaScript in ES7
Async JavaScript in ES7Mike North
 
Using Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your DataUsing Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your DataMongoDB
 
New feature of async fakeAsync test in angular
New feature of async fakeAsync test in angularNew feature of async fakeAsync test in angular
New feature of async fakeAsync test in angularJia Li
 
The Ring programming language version 1.2 book - Part 44 of 84
The Ring programming language version 1.2 book - Part 44 of 84The Ring programming language version 1.2 book - Part 44 of 84
The Ring programming language version 1.2 book - Part 44 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189Mahmoud Samir Fayed
 

Was ist angesagt? (20)

The Ring programming language version 1.5.4 book - Part 62 of 185
The Ring programming language version 1.5.4 book - Part 62 of 185The Ring programming language version 1.5.4 book - Part 62 of 185
The Ring programming language version 1.5.4 book - Part 62 of 185
 
Hybrid quantum classical neural networks with pytorch and qiskit
Hybrid quantum classical neural networks with pytorch and qiskitHybrid quantum classical neural networks with pytorch and qiskit
Hybrid quantum classical neural networks with pytorch and qiskit
 
倒计时优化点滴
倒计时优化点滴倒计时优化点滴
倒计时优化点滴
 
Qsam simulator in IBM Quantum Lab cloud
Qsam simulator in IBM Quantum Lab cloudQsam simulator in IBM Quantum Lab cloud
Qsam simulator in IBM Quantum Lab cloud
 
Service worker: discover the next web game changer
Service worker: discover the next web game changerService worker: discover the next web game changer
Service worker: discover the next web game changer
 
You will learn RxJS in 2017
You will learn RxJS in 2017You will learn RxJS in 2017
You will learn RxJS in 2017
 
Calculator code with scientific functions in java
Calculator code with scientific functions in java Calculator code with scientific functions in java
Calculator code with scientific functions in java
 
Star bed 2018.07.19
Star bed 2018.07.19Star bed 2018.07.19
Star bed 2018.07.19
 
Multi qubit entanglement
Multi qubit entanglementMulti qubit entanglement
Multi qubit entanglement
 
node-rpi-ws281x
node-rpi-ws281xnode-rpi-ws281x
node-rpi-ws281x
 
Caching a page
Caching a pageCaching a page
Caching a page
 
MongoDB World 2019: Life In Stitch-es
MongoDB World 2019: Life In Stitch-esMongoDB World 2019: Life In Stitch-es
MongoDB World 2019: Life In Stitch-es
 
Monitoring und Metriken im Wunderland
Monitoring und Metriken im WunderlandMonitoring und Metriken im Wunderland
Monitoring und Metriken im Wunderland
 
Async JavaScript in ES7
Async JavaScript in ES7Async JavaScript in ES7
Async JavaScript in ES7
 
Rxjs swetugg
Rxjs swetuggRxjs swetugg
Rxjs swetugg
 
Using Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your DataUsing Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your Data
 
New feature of async fakeAsync test in angular
New feature of async fakeAsync test in angularNew feature of async fakeAsync test in angular
New feature of async fakeAsync test in angular
 
Rxjs marble-testing
Rxjs marble-testingRxjs marble-testing
Rxjs marble-testing
 
The Ring programming language version 1.2 book - Part 44 of 84
The Ring programming language version 1.2 book - Part 44 of 84The Ring programming language version 1.2 book - Part 44 of 84
The Ring programming language version 1.2 book - Part 44 of 84
 
The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189
 

Ähnlich wie Arduino & node.js

How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js ModuleFred Chien
 
End to end todo list app with NestJs - Angular - Redux & Redux Saga
End to end todo list app with NestJs - Angular - Redux & Redux SagaEnd to end todo list app with NestJs - Angular - Redux & Redux Saga
End to end todo list app with NestJs - Angular - Redux & Redux SagaBabacar NIANG
 
Артем Маркушев - JavaScript
Артем Маркушев - JavaScriptАртем Маркушев - JavaScript
Артем Маркушев - JavaScriptDataArt
 
a friend in need-a js indeed / Yonatan levin
a friend in need-a js indeed / Yonatan levina friend in need-a js indeed / Yonatan levin
a friend in need-a js indeed / Yonatan levingeektimecoil
 
A friend in need - A JS indeed
A friend in need - A JS indeedA friend in need - A JS indeed
A friend in need - A JS indeedYonatan Levin
 
Yves & Zed @ Developer Conference 2013
Yves & Zed @ Developer Conference 2013Yves & Zed @ Developer Conference 2013
Yves & Zed @ Developer Conference 2013FabianWesnerBerlin
 
Background Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbBackground Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbJuan Maiz
 
node.js and the AR.Drone: building a real-time dashboard using socket.io
node.js and the AR.Drone: building a real-time dashboard using socket.ionode.js and the AR.Drone: building a real-time dashboard using socket.io
node.js and the AR.Drone: building a real-time dashboard using socket.ioSteven Beeckman
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the CloudWesley Beary
 
Ardupilot Gazebo status.pdf
Ardupilot Gazebo status.pdfArdupilot Gazebo status.pdf
Ardupilot Gazebo status.pdfssuserd7d2f2
 
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015Masahiro Nagano
 
Gearmanpresentation 110308165409-phpapp01
Gearmanpresentation 110308165409-phpapp01Gearmanpresentation 110308165409-phpapp01
Gearmanpresentation 110308165409-phpapp01longtuan
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comVan-Duyet Le
 
AWS IoT 핸즈온 워크샵 - 실습 5. DynamoDB에 센서 데이터 저장하기 (김무현 솔루션즈 아키텍트)
AWS IoT 핸즈온 워크샵 - 실습 5. DynamoDB에 센서 데이터 저장하기 (김무현 솔루션즈 아키텍트)AWS IoT 핸즈온 워크샵 - 실습 5. DynamoDB에 센서 데이터 저장하기 (김무현 솔루션즈 아키텍트)
AWS IoT 핸즈온 워크샵 - 실습 5. DynamoDB에 센서 데이터 저장하기 (김무현 솔루션즈 아키텍트)Amazon Web Services Korea
 
Live Streaming & Server Sent Events
Live Streaming & Server Sent EventsLive Streaming & Server Sent Events
Live Streaming & Server Sent Eventstkramar
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)Wesley Beary
 
Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationBen Hall
 

Ähnlich wie Arduino & node.js (20)

How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js Module
 
Server/Client Remote platform logger.
Server/Client Remote platform logger.Server/Client Remote platform logger.
Server/Client Remote platform logger.
 
End to end todo list app with NestJs - Angular - Redux & Redux Saga
End to end todo list app with NestJs - Angular - Redux & Redux SagaEnd to end todo list app with NestJs - Angular - Redux & Redux Saga
End to end todo list app with NestJs - Angular - Redux & Redux Saga
 
Артем Маркушев - JavaScript
Артем Маркушев - JavaScriptАртем Маркушев - JavaScript
Артем Маркушев - JavaScript
 
a friend in need-a js indeed / Yonatan levin
a friend in need-a js indeed / Yonatan levina friend in need-a js indeed / Yonatan levin
a friend in need-a js indeed / Yonatan levin
 
A friend in need - A JS indeed
A friend in need - A JS indeedA friend in need - A JS indeed
A friend in need - A JS indeed
 
R-House (LSRC)
R-House (LSRC)R-House (LSRC)
R-House (LSRC)
 
Yves & Zed @ Developer Conference 2013
Yves & Zed @ Developer Conference 2013Yves & Zed @ Developer Conference 2013
Yves & Zed @ Developer Conference 2013
 
Der perfekte 12c trigger
Der perfekte 12c triggerDer perfekte 12c trigger
Der perfekte 12c trigger
 
Background Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbBackground Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRb
 
node.js and the AR.Drone: building a real-time dashboard using socket.io
node.js and the AR.Drone: building a real-time dashboard using socket.ionode.js and the AR.Drone: building a real-time dashboard using socket.io
node.js and the AR.Drone: building a real-time dashboard using socket.io
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloud
 
Ardupilot Gazebo status.pdf
Ardupilot Gazebo status.pdfArdupilot Gazebo status.pdf
Ardupilot Gazebo status.pdf
 
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015
 
Gearmanpresentation 110308165409-phpapp01
Gearmanpresentation 110308165409-phpapp01Gearmanpresentation 110308165409-phpapp01
Gearmanpresentation 110308165409-phpapp01
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
 
AWS IoT 핸즈온 워크샵 - 실습 5. DynamoDB에 센서 데이터 저장하기 (김무현 솔루션즈 아키텍트)
AWS IoT 핸즈온 워크샵 - 실습 5. DynamoDB에 센서 데이터 저장하기 (김무현 솔루션즈 아키텍트)AWS IoT 핸즈온 워크샵 - 실습 5. DynamoDB에 센서 데이터 저장하기 (김무현 솔루션즈 아키텍트)
AWS IoT 핸즈온 워크샵 - 실습 5. DynamoDB에 센서 데이터 저장하기 (김무현 솔루션즈 아키텍트)
 
Live Streaming & Server Sent Events
Live Streaming & Server Sent EventsLive Streaming & Server Sent Events
Live Streaming & Server Sent Events
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
 
Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS Application
 

Mehr von Steven Beeckman

An Incomplete Introduction to Artificial Intelligence
An Incomplete Introduction to Artificial IntelligenceAn Incomplete Introduction to Artificial Intelligence
An Incomplete Introduction to Artificial IntelligenceSteven Beeckman
 
Digital transformation in other countries' governments
Digital transformation in other countries' governmentsDigital transformation in other countries' governments
Digital transformation in other countries' governmentsSteven Beeckman
 
csv,conf 2014 - Open data within organizations
csv,conf 2014 - Open data within organizationscsv,conf 2014 - Open data within organizations
csv,conf 2014 - Open data within organizationsSteven Beeckman
 
Boondoggle Bright - Hackathing - StartupBus
Boondoggle Bright - Hackathing - StartupBusBoondoggle Bright - Hackathing - StartupBus
Boondoggle Bright - Hackathing - StartupBusSteven Beeckman
 
BlackBerry 10 Core Native Camera API
BlackBerry 10 Core Native Camera APIBlackBerry 10 Core Native Camera API
BlackBerry 10 Core Native Camera APISteven Beeckman
 
Testing & Deploying node.js apps
Testing & Deploying node.js appsTesting & Deploying node.js apps
Testing & Deploying node.js appsSteven Beeckman
 
4 Simple Rules of Design
4 Simple Rules of Design4 Simple Rules of Design
4 Simple Rules of DesignSteven Beeckman
 
BlackBerry Developers Group Belgium - 1st meetup
BlackBerry Developers Group Belgium - 1st meetupBlackBerry Developers Group Belgium - 1st meetup
BlackBerry Developers Group Belgium - 1st meetupSteven Beeckman
 
Node.js User Group Belgium - 1st meetup
Node.js User Group Belgium - 1st meetupNode.js User Group Belgium - 1st meetup
Node.js User Group Belgium - 1st meetupSteven Beeckman
 
Think Before You Act or Rapid Prototyping
Think Before You Act or Rapid PrototypingThink Before You Act or Rapid Prototyping
Think Before You Act or Rapid PrototypingSteven Beeckman
 

Mehr von Steven Beeckman (12)

An Incomplete Introduction to Artificial Intelligence
An Incomplete Introduction to Artificial IntelligenceAn Incomplete Introduction to Artificial Intelligence
An Incomplete Introduction to Artificial Intelligence
 
Digital transformation in other countries' governments
Digital transformation in other countries' governmentsDigital transformation in other countries' governments
Digital transformation in other countries' governments
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
csv,conf 2014 - Open data within organizations
csv,conf 2014 - Open data within organizationscsv,conf 2014 - Open data within organizations
csv,conf 2014 - Open data within organizations
 
Boondoggle Bright - Hackathing - StartupBus
Boondoggle Bright - Hackathing - StartupBusBoondoggle Bright - Hackathing - StartupBus
Boondoggle Bright - Hackathing - StartupBus
 
Intro
IntroIntro
Intro
 
BlackBerry 10 Core Native Camera API
BlackBerry 10 Core Native Camera APIBlackBerry 10 Core Native Camera API
BlackBerry 10 Core Native Camera API
 
Testing & Deploying node.js apps
Testing & Deploying node.js appsTesting & Deploying node.js apps
Testing & Deploying node.js apps
 
4 Simple Rules of Design
4 Simple Rules of Design4 Simple Rules of Design
4 Simple Rules of Design
 
BlackBerry Developers Group Belgium - 1st meetup
BlackBerry Developers Group Belgium - 1st meetupBlackBerry Developers Group Belgium - 1st meetup
BlackBerry Developers Group Belgium - 1st meetup
 
Node.js User Group Belgium - 1st meetup
Node.js User Group Belgium - 1st meetupNode.js User Group Belgium - 1st meetup
Node.js User Group Belgium - 1st meetup
 
Think Before You Act or Rapid Prototyping
Think Before You Act or Rapid PrototypingThink Before You Act or Rapid Prototyping
Think Before You Act or Rapid Prototyping
 

Kürzlich hochgeladen

Call Girls Banashankari Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Banashankari Just Call 👗 7737669865 👗 Top Class Call Girl Service ...Call Girls Banashankari Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Banashankari Just Call 👗 7737669865 👗 Top Class Call Girl Service ...amitlee9823
 
Call Girls In RT Nagar ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In RT Nagar ☎ 7737669865 🥵 Book Your One night StandCall Girls In RT Nagar ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In RT Nagar ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Call Girls Chikhali Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Chikhali Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Chikhali Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Chikhali Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
VVIP Pune Call Girls Gahunje WhatSapp Number 8005736733 With Elite Staff And ...
VVIP Pune Call Girls Gahunje WhatSapp Number 8005736733 With Elite Staff And ...VVIP Pune Call Girls Gahunje WhatSapp Number 8005736733 With Elite Staff And ...
VVIP Pune Call Girls Gahunje WhatSapp Number 8005736733 With Elite Staff And ...SUHANI PANDEY
 
HLH PPT.ppt very important topic to discuss
HLH PPT.ppt very important topic to discussHLH PPT.ppt very important topic to discuss
HLH PPT.ppt very important topic to discussDrMSajidNoor
 
Bommasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Bommasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Bommasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Bommasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
➥🔝 7737669865 🔝▻ Muzaffarpur Call-girls in Women Seeking Men 🔝Muzaffarpur🔝 ...
➥🔝 7737669865 🔝▻ Muzaffarpur Call-girls in Women Seeking Men  🔝Muzaffarpur🔝  ...➥🔝 7737669865 🔝▻ Muzaffarpur Call-girls in Women Seeking Men  🔝Muzaffarpur🔝  ...
➥🔝 7737669865 🔝▻ Muzaffarpur Call-girls in Women Seeking Men 🔝Muzaffarpur🔝 ...amitlee9823
 
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...MOHANI PANDEY
 
Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...amitlee9823
 
Just Call Vip call girls daman Escorts ☎️9352988975 Two shot with one girl (d...
Just Call Vip call girls daman Escorts ☎️9352988975 Two shot with one girl (d...Just Call Vip call girls daman Escorts ☎️9352988975 Two shot with one girl (d...
Just Call Vip call girls daman Escorts ☎️9352988975 Two shot with one girl (d...gajnagarg
 
Top Rated Pune Call Girls Ravet ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Ravet ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Ravet ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Ravet ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Call Girls in Nagpur High Profile
 
SM-N975F esquematico completo - reparación.pdf
SM-N975F esquematico completo - reparación.pdfSM-N975F esquematico completo - reparación.pdf
SM-N975F esquematico completo - reparación.pdfStefanoBiamonte1
 
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in DammamAbortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammamahmedjiabur940
 
一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制
一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制
一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制uodye
 
➥🔝 7737669865 🔝▻ kakinada Call-girls in Women Seeking Men 🔝kakinada🔝 Escor...
➥🔝 7737669865 🔝▻ kakinada Call-girls in Women Seeking Men  🔝kakinada🔝   Escor...➥🔝 7737669865 🔝▻ kakinada Call-girls in Women Seeking Men  🔝kakinada🔝   Escor...
➥🔝 7737669865 🔝▻ kakinada Call-girls in Women Seeking Men 🔝kakinada🔝 Escor...amitlee9823
 
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证tufbav
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝
Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝
Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Kürzlich hochgeladen (20)

Call Girls Banashankari Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Banashankari Just Call 👗 7737669865 👗 Top Class Call Girl Service ...Call Girls Banashankari Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Banashankari Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
 
Call Girls In RT Nagar ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In RT Nagar ☎ 7737669865 🥵 Book Your One night StandCall Girls In RT Nagar ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In RT Nagar ☎ 7737669865 🥵 Book Your One night Stand
 
Call Girls Chikhali Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Chikhali Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Chikhali Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Chikhali Call Me 7737669865 Budget Friendly No Advance Booking
 
VVIP Pune Call Girls Gahunje WhatSapp Number 8005736733 With Elite Staff And ...
VVIP Pune Call Girls Gahunje WhatSapp Number 8005736733 With Elite Staff And ...VVIP Pune Call Girls Gahunje WhatSapp Number 8005736733 With Elite Staff And ...
VVIP Pune Call Girls Gahunje WhatSapp Number 8005736733 With Elite Staff And ...
 
HLH PPT.ppt very important topic to discuss
HLH PPT.ppt very important topic to discussHLH PPT.ppt very important topic to discuss
HLH PPT.ppt very important topic to discuss
 
Bommasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Bommasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Bommasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Bommasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
➥🔝 7737669865 🔝▻ Muzaffarpur Call-girls in Women Seeking Men 🔝Muzaffarpur🔝 ...
➥🔝 7737669865 🔝▻ Muzaffarpur Call-girls in Women Seeking Men  🔝Muzaffarpur🔝  ...➥🔝 7737669865 🔝▻ Muzaffarpur Call-girls in Women Seeking Men  🔝Muzaffarpur🔝  ...
➥🔝 7737669865 🔝▻ Muzaffarpur Call-girls in Women Seeking Men 🔝Muzaffarpur🔝 ...
 
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...
 
(INDIRA) Call Girl Napur Call Now 8617697112 Napur Escorts 24x7
(INDIRA) Call Girl Napur Call Now 8617697112 Napur Escorts 24x7(INDIRA) Call Girl Napur Call Now 8617697112 Napur Escorts 24x7
(INDIRA) Call Girl Napur Call Now 8617697112 Napur Escorts 24x7
 
Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
 
Just Call Vip call girls daman Escorts ☎️9352988975 Two shot with one girl (d...
Just Call Vip call girls daman Escorts ☎️9352988975 Two shot with one girl (d...Just Call Vip call girls daman Escorts ☎️9352988975 Two shot with one girl (d...
Just Call Vip call girls daman Escorts ☎️9352988975 Two shot with one girl (d...
 
CHEAP Call Girls in Mayapuri (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Mayapuri  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Mayapuri  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Mayapuri (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Top Rated Pune Call Girls Ravet ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Ravet ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Ravet ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Ravet ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
SM-N975F esquematico completo - reparación.pdf
SM-N975F esquematico completo - reparación.pdfSM-N975F esquematico completo - reparación.pdf
SM-N975F esquematico completo - reparación.pdf
 
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in DammamAbortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
Abortion Pill for sale in Riyadh ((+918761049707) Get Cytotec in Dammam
 
一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制
一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制
一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制
 
➥🔝 7737669865 🔝▻ kakinada Call-girls in Women Seeking Men 🔝kakinada🔝 Escor...
➥🔝 7737669865 🔝▻ kakinada Call-girls in Women Seeking Men  🔝kakinada🔝   Escor...➥🔝 7737669865 🔝▻ kakinada Call-girls in Women Seeking Men  🔝kakinada🔝   Escor...
➥🔝 7737669865 🔝▻ kakinada Call-girls in Women Seeking Men 🔝kakinada🔝 Escor...
 
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
怎样办理维多利亚大学毕业证(UVic毕业证书)成绩单留信认证
 
CHEAP Call Girls in Hauz Quazi (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Hauz Quazi  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Hauz Quazi  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Hauz Quazi (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝
Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝
Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝
 

Arduino & node.js

  • 1. How to build a depression predictor (a.k.a. a belgian weather station) using Arduino & Node.js @stevenbeeckman #iotbe #njugbe
  • 2. In short Arduino IDE: arduino.cc/dowload Install StandardFirmata sketch on the Arduino npm install johnny-five write your script.js Run node script.js
  • 3. You need a host computer connected to the Arduino
  • 4. Let’s build a depression predictor (or a belgian weather station)
  • 5. Things we need A sensor Something to gather the sensor data Something to store the generated timeseries A visualisation
  • 7. Heroku + node.js + hapi.js + Tempo DB add-on photoresistor Arduino Uno Node.js + Johnny Five + request + forever TempoDB web app ADC http httpusb
  • 8. Heroku + node.js + hapi.js + Tempo DB add-on photoresistor Arduino Uno Node.js + Johnny Five + request + forever TempoDB web app ADC http httpusb
  • 9. MacGyver-ism: no resistors in house and no nearby shops to buy them from -> use a piezo as a resistor
  • 10. Heroku + node.js + hapi.js + Tempo DB add-on photoresistor Arduino Uno Node.js + Johnny Five + request + forever TempoDB web app ADC http httpusb
  • 11.
  • 12. Packages you need npm install --save johnny-five npm install --save request npm install -g forever usage: forever start script.js forever list (to see what’s running) https://github.com/stevenbeeckman/arduino-j5
  • 13. Heroku + node.js + hapi.js + Tempo DB add-on photoresistor Arduino Uno Node.js + Johnny Five + request + forever TempoDB web app ADC http httpusb
  • 14. Design Need a REST API over HTTP (Mandatory) POST new sensor values (Optional) GET overview of past sensor values Store data in a time series friendly database
  • 15. Packages you need "dependencies": { "hapi": "^6.5.1", "moment": "^2.8.2", "tempodb": "^1.0.0" } https://github.com/stevenbeeckman/iotbe-njugbe/
  • 16. Hosting This code can run on your own server or in the cloud. I ran it in the cloud, on Heroku and used the free TempoDB add-on.
  • 17.
  • 18. Some code var Hapi = require('hapi'); var server = new Hapi.Server(process.env.PORT || 3000); server.route({ method: 'GET' , path: '/' , handler: function(request, reply){ reply('Hello, Internet of Things fans!'); } }); server.start(function(){ console.log('Server running at:' + server.info.uri); }); heroku create git add index.js git commit -m “First deploy.” git push heroku master http://iotbe-njugbe.herokuapp.com/
  • 19. Writing to your TempoDB var TempoDBClient = require('tempodb').TempoDBClient; var tempodb = new TempoDBClient('heroku-5e2f03bd25cf424098426a8a21db26f3', process.env.TEMPODB_API_KEY, process.env. TEMPODB_API_SECRET, {hostname: process.env.TEMPODB_API_HOST, port: process.env.TEMPODB_API_PORT}); var moment = require('moment'); server.route({ method: 'POST' , path: '/sensor/{sensor_id}/measurement' , config: { handler: function(request, reply){ var newMeasurement = new Object(); newMeasurement.t = moment().format("YYYY-MM-DDTHH:mm:ss.SSSZZ"); newMeasurement.v = request.payload.value; var tempodb_data = new Array(); tempodb_data.push(newMeasurement); var series_key = 'sensor-' + request.params.sensor_id; tempodb.write_key(series_key, tempodb_data, function(error, result){ error ? reply(error) : reply(result); }); } } });
  • 20. Writing to your TempoDB var TempoDBClient = require('tempodb').TempoDBClient; var tempodb = new TempoDBClient('heroku-5e2f03bd25cf424098426a8a21db26f3', process.env.TEMPODB_API_KEY, process.env. TEMPODB_API_SECRET, {hostname: process.env.TEMPODB_API_HOST, port: process.env.TEMPODB_API_PORT}); var moment = require('moment'); server.route({ method: 'POST' , path: '/sensor/{sensor_id}/measurement' , config: { handler: function(request, reply){ var newMeasurement = new Object(); newMeasurement.t = moment().format("YYYY-MM-DDTHH:mm:ss.SSSZZ"); newMeasurement.v = request.payload.value; var tempodb_data = new Array(); tempodb_data.push(newMeasurement); var series_key = 'sensor-' + request.params.sensor_id; tempodb.write_key(series_key, tempodb_data, function(error, result){ error ? reply(error) : reply(result); }); } } }); Not documented: date must be formatted. new Date() will not work as is. Use moment.js for easy formatting.
  • 21. Writing to your TempoDB var TempoDBClient = require('tempodb').TempoDBClient; var tempodb = new TempoDBClient('heroku-5e2f03bd25cf424098426a8a21db26f3', process.env.TEMPODB_API_KEY, process.env. TEMPODB_API_SECRET, {hostname: process.env.TEMPODB_API_HOST, port: process.env.TEMPODB_API_PORT}); var moment = require('moment'); server.route({ method: 'POST' , path: '/sensor/{sensor_id}/measurement' , config: { handler: function(request, reply){ var newMeasurement = new Object(); newMeasurement.t = moment().format("YYYY-MM-DDTHH:mm:ss.SSSZZ"); newMeasurement.v = request.payload.value; var tempodb_data = new Array(); tempodb_data.push(newMeasurement); var series_key = 'sensor-' + request.params.sensor_id; tempodb.write_key(series_key, tempodb_data, function(error, result){ error ? reply(error) : reply(result); }); } } }); Single key value pairs {t,v} must be wrapped in an Array too...
  • 22. Writing to your TempoDB var TempoDBClient = require('tempodb').TempoDBClient; var tempodb = new TempoDBClient('heroku-5e2f03bd25cf424098426a8a21db26f3', process.env.TEMPODB_API_KEY, process.env. TEMPODB_API_SECRET, {hostname: process.env.TEMPODB_API_HOST, port: process.env.TEMPODB_API_PORT}); var moment = require('moment'); server.route({ method: 'POST' , path: '/sensor/{sensor_id}/measurement' , config: { handler: function(request, reply){ var newMeasurement = new Object(); newMeasurement.t = moment().format("YYYY-MM-DDTHH:mm:ss.SSSZZ"); newMeasurement.v = request.payload.value; var tempodb_data = new Array(); tempodb_data.push(newMeasurement); var series_key = 'sensor-' + request.params.sensor_id; tempodb.write_key(series_key, tempodb_data, function(error, result){ error ? reply(error) : reply(result); }); } } }); Warning: You have to pass the TempoDB database name too, which is not documented!
  • 23. Heroku + node.js + hapi.js + Tempo DB add-on photoresistor Arduino Uno Node.js + Johnny Five + request + forever TempoDB web app ADC http httpusb
  • 24.
  • 25.