SlideShare a Scribd company logo
On Raspberry Pi & Arduino
With Node.JS
June. 2014
Home Temperature & Humidity Monitor
Node.JS on Arduino + Raspberry Pi
Features (based on v. 0.1)
– mobile web app on
jQuery Mobile
– show current temperature
– show the trend of temp.
– open API for using google chart
TO-DOs
– add humidity
– add hypermedia API
Arduino Nano + Raspberry Pi + Wi-Fi
LAN
Uses DHT11 sensor
Resistance is
required
Node.JS on Raspberry Pi in 5 min.
– http://joshondesign.com/2013/10/23/noderpi
Update raspbian
Node & NPM
Set environment
sudo apt-get upgrade;
sudo apt-get update
wget http://nodejs.org/dist/v0.10.2/node-v0.10.2-linux-arm-pi.tar.gz
tar -xvzf node-v0.10.2-linux-arm-pi.tar.gz node-v0.10.2-linux-arm-
pi/bin/node --version
NODE_JS_HOME=/home/pi/node-v0.10.2-linux-arm-pi
PATH=$PATH:$NODE_JS_HOME/bin
Install MySQL server
Install node-mysql
Create table
sudo apt-get install mysql-server
npm install mysql
mysql -u root -p
Enter password:
mysql> CREATE DB temps
mysql> USE temps
Create schema
Retrieving DB on Node.JS
– http://iamapark89.wordpress.com/2013/12/1
4/node-js-2-db-%EC%97%B0%EA%B2%B0/
CREATE TABLE tempData (
tempId int(11) AUTO_INCREMENT NOT NULL,
tempDate datetime NOT NULL,
tempCelsius decimal(4,2) NOT NULL,
humidity decimal(4,2) NOT NULL,
constraint tempData_PK primary key (tempId)
);
Flushing binary with Arduino IDE
– http://playground.arduino.cc/main/DHT11Lib
Install node-serialport
– https://github.com/voodootikigod/node-serialport
wget http://nodejs.org/dist/v0.10.12/node-v0.10.12-linux-arm-
pi.tar.gz
tar xvfz node-v0.10.12-linux-arm-pi.tar.gz
sudo mv node-v0.10.12-linux-arm-pi /opt/node/
echo 'export PATH="$PATH:/opt/node/bin"' >> ~/.bashrc
source ~/.bashrc
npm install serialport
Programming server with JavaScript
– JavaScript is also famous for front-end (client)
Simple & Short Code
– No type declaration & implicit type conversion
– No multi-threading control
Various open source libraries on NPM
– Just type ‘npm install {library name}’ to use it
Awesome playgrounds
– Cloud IDE such as Cloud9 and web itself.
RequireJS
– De facto JavaScript modularization
• http://webofthink.tistory.com/12
Evented I/O asynchronous operation
var http=require(‘http’);
http.createServer(function
(request, response) {
// invoked asynchronously
});
Web Application Server
– sudo npm install express routes
var express = require('express') , routes = require('./routes') , user =
require('./routes/user') , temperatures =
require('./routes/temperature') , http = require('http') , path =
require('path');
var app = express();
// … omitted …
app.get('/', routes.index);
app.get('/users', user.list);
app.get('/temperatures', temperatures.list);
Handles GET /users
Handles GET
/temperatures
Jade Template Engine for Express
– sudo node install jade
Simplified HTML tag hierarchy
doctype 5
html
head
title
meta(name='viewport', content='width=device-width,
initial-scale=1')
body
div(data-role='page', data-theme='a')
h1
hr
a
Responsive web design
– Uses jQuery Mobile for free
• See the demo:
– http://demos.jquerymobile.com/
1.3.0-beta.1/docs/demos/
Using Google Charts
– https://developers.google.com/chart/
HTTP command, URI & representation
– HTTP command: GET, PUT, POST, DELETE, …
– URI: non-verb resources & it’s hierarchy
– Representation : XML, JSON, …
AJAX operation
var xhr = new XMLHttpRequest();
xhr.open('get', '/temperatures');
xhr.onreadystatechange = function() {
// code the event handler here
}
xhr.send(null);
JavaScript Everywhere
– Consider 1st class citizen of web for all Internet
of Things.
Develop more APIs then Apps
– App is opened to use but closed to create.
– API gives the chance to mash things up.
Data is just nothing without visualization
– Imagine how the context can be found in data.
Design hypermedia API
– Achieve the level 3 at Richardson Maturity Level
• http://webofthink.tistory.com/2
Design REST to JavaScript API for better
development
– Make the mash-up and maintenance better
– Provide user’s guide with Web IDL
Multi-screen web application
– Design the process how to develop N-Screen Apps.

More Related Content

KEY
Android and Arduio mixed with Breakout js
PDF
Macruby intro
PDF
Custom Non-RDS Multi-AZ Mysql Replication
PPTX
Rails 勉強会#3
PPTX
Controlling robots using javascript
PDF
Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
KEY
fog or: How I Learned to Stop Worrying and Love the Cloud
PDF
Shrink to grow
Android and Arduio mixed with Breakout js
Macruby intro
Custom Non-RDS Multi-AZ Mysql Replication
Rails 勉強会#3
Controlling robots using javascript
Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
fog or: How I Learned to Stop Worrying and Love the Cloud
Shrink to grow

What's hot (20)

PPTX
Kraken js at paypal
PDF
Introduction to ansible
PDF
Ansible
ODP
Fabric: A Capistrano Alternative
ODP
Ansible basics workshop
PDF
Reactive Programming by UniRx for Asynchronous & Event Processing
PDF
How to speed up your (API client) modules
PDF
OSDC.no 2015 introduction to node.js workshop
PDF
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
PPTX
Best Deep Learning Post from LinkedIn Group
PDF
The Secrets of The FullStack Ninja - Part A - Session I
PDF
Modern Infrastructure from Scratch with Puppet
PPT
Epoll - from the kernel side
PDF
Heroku pycon
PDF
Deploying Prometheus stacks with Juju
PDF
[MeetUp][2nd] 컭on턺
PDF
Continuous Integration & Continuous Delivery with GCP
PPT
AsyncIO To Speed Up Your Crawler
PDF
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
PDF
Puppet and Openshift
Kraken js at paypal
Introduction to ansible
Ansible
Fabric: A Capistrano Alternative
Ansible basics workshop
Reactive Programming by UniRx for Asynchronous & Event Processing
How to speed up your (API client) modules
OSDC.no 2015 introduction to node.js workshop
Ansible 2.0 - How to use Ansible to automate your applications in AWS.
Best Deep Learning Post from LinkedIn Group
The Secrets of The FullStack Ninja - Part A - Session I
Modern Infrastructure from Scratch with Puppet
Epoll - from the kernel side
Heroku pycon
Deploying Prometheus stacks with Juju
[MeetUp][2nd] 컭on턺
Continuous Integration & Continuous Delivery with GCP
AsyncIO To Speed Up Your Crawler
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
Puppet and Openshift
Ad

Viewers also liked (13)

PDF
IoT Web App - 수집된 정보의 가공, 처리, 융합
PDF
[1C6]오픈소스 하드웨어 플랫폼과 Node.js로 구현하는 IoT 플랫폼
PDF
Intuitive Understanding of Arduino for IoT
PDF
Do IoT Yourself 3rd : Open API - revision 3
ODP
MQTT on Raspberry Pi with node.js
PPTX
IoT with Raspberry Pi + Node JS - Chapter 2
PDF
04강 라즈베리-개발환경구축-실습
PDF
라즈베리파이로 보일러 제어하기
PPTX
라즈베리파이로 시작하는 Iot세상
PDF
자바, 미안하다! 파이썬 한국어 NLP
PDF
Device to Intelligence, IOT and Big Data in Oracle
PDF
IoT, 기술의 혁신과 미래 그리고 통찰
PPTX
Raspberry pi - Node js - Drupal
IoT Web App - 수집된 정보의 가공, 처리, 융합
[1C6]오픈소스 하드웨어 플랫폼과 Node.js로 구현하는 IoT 플랫폼
Intuitive Understanding of Arduino for IoT
Do IoT Yourself 3rd : Open API - revision 3
MQTT on Raspberry Pi with node.js
IoT with Raspberry Pi + Node JS - Chapter 2
04강 라즈베리-개발환경구축-실습
라즈베리파이로 보일러 제어하기
라즈베리파이로 시작하는 Iot세상
자바, 미안하다! 파이썬 한국어 NLP
Device to Intelligence, IOT and Big Data in Oracle
IoT, 기술의 혁신과 미래 그리고 통찰
Raspberry pi - Node js - Drupal
Ad

Similar to Home sensor prototype on Arduino & Raspberry Pi with Node.JS (20)

PPTX
ДМИТРО БУДИМ «Mobile Automation Infrastructure from scratch» Online QADay 202...
PPTX
Building Web Apps with Express
PDF
"13 ways to run web applications on the Internet" Andrii Shumada
PPTX
Reactive application using meteor
ODP
An OpenShift Primer for Developers to get your Code into the Cloud (PTJUG)
PPTX
Tutorial 1: Your First Science App - Araport Developer Workshop
PDF
Grunt & Front-end Workflow
PDF
Using the new WordPress REST API
PDF
Nodejs in Production
PDF
Mobile development in 2020
PDF
Haibu: dev deployment is fast and easy again
PDF
JDD 2017: 7 things which you should care about before release your code to pr...
PDF
Building websites with Node.ACS
PDF
Building websites with Node.ACS
PDF
Appium workship, Mobile Web+Dev Conference
PDF
Appium mobile web+dev conference
ODP
Nodejs Intro - Part2 Introduction to Web Applications
PPTX
Introduction to node.js By Ahmed Assaf
PDF
DevFest 2022 - GitHub Actions를 활용한 Flutter 배포 자동화하기
PDF
Exploring Async PHP (SF Live Berlin 2019)
ДМИТРО БУДИМ «Mobile Automation Infrastructure from scratch» Online QADay 202...
Building Web Apps with Express
"13 ways to run web applications on the Internet" Andrii Shumada
Reactive application using meteor
An OpenShift Primer for Developers to get your Code into the Cloud (PTJUG)
Tutorial 1: Your First Science App - Araport Developer Workshop
Grunt & Front-end Workflow
Using the new WordPress REST API
Nodejs in Production
Mobile development in 2020
Haibu: dev deployment is fast and easy again
JDD 2017: 7 things which you should care about before release your code to pr...
Building websites with Node.ACS
Building websites with Node.ACS
Appium workship, Mobile Web+Dev Conference
Appium mobile web+dev conference
Nodejs Intro - Part2 Introduction to Web Applications
Introduction to node.js By Ahmed Assaf
DevFest 2022 - GitHub Actions를 활용한 Flutter 배포 자동화하기
Exploring Async PHP (SF Live Berlin 2019)

More from Hyunghun Cho (6)

PDF
2018 소프트웨어에 물들다 - 기계는 어떻게 생각할까?
PDF
Somul 2017 소프트웨어, 사람과 사물의 소통을 향하여
PPTX
Tensorflow internal
PDF
Do IoT Yourself! - 사물 간의 연결을 위한 Open API
PDF
GameTube app-swing-introduction
PDF
REST to JavaScript for Better Client-side Development
2018 소프트웨어에 물들다 - 기계는 어떻게 생각할까?
Somul 2017 소프트웨어, 사람과 사물의 소통을 향하여
Tensorflow internal
Do IoT Yourself! - 사물 간의 연결을 위한 Open API
GameTube app-swing-introduction
REST to JavaScript for Better Client-side Development

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Empathic Computing: Creating Shared Understanding
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
Approach and Philosophy of On baking technology
PDF
KodekX | Application Modernization Development
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
MYSQL Presentation for SQL database connectivity
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
Machine learning based COVID-19 study performance prediction
Diabetes mellitus diagnosis method based random forest with bat algorithm
Empathic Computing: Creating Shared Understanding
Per capita expenditure prediction using model stacking based on satellite ima...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Electronic commerce courselecture one. Pdf
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
The AUB Centre for AI in Media Proposal.docx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Advanced Soft Computing BINUS July 2025.pdf
Approach and Philosophy of On baking technology
KodekX | Application Modernization Development
Reach Out and Touch Someone: Haptics and Empathic Computing
MYSQL Presentation for SQL database connectivity
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Unlocking AI with Model Context Protocol (MCP)
Mobile App Security Testing_ A Comprehensive Guide.pdf

Home sensor prototype on Arduino & Raspberry Pi with Node.JS

  • 1. On Raspberry Pi & Arduino With Node.JS June. 2014
  • 2. Home Temperature & Humidity Monitor Node.JS on Arduino + Raspberry Pi
  • 3. Features (based on v. 0.1) – mobile web app on jQuery Mobile – show current temperature – show the trend of temp. – open API for using google chart TO-DOs – add humidity – add hypermedia API
  • 4. Arduino Nano + Raspberry Pi + Wi-Fi LAN
  • 6. Node.JS on Raspberry Pi in 5 min. – http://joshondesign.com/2013/10/23/noderpi Update raspbian Node & NPM Set environment sudo apt-get upgrade; sudo apt-get update wget http://nodejs.org/dist/v0.10.2/node-v0.10.2-linux-arm-pi.tar.gz tar -xvzf node-v0.10.2-linux-arm-pi.tar.gz node-v0.10.2-linux-arm- pi/bin/node --version NODE_JS_HOME=/home/pi/node-v0.10.2-linux-arm-pi PATH=$PATH:$NODE_JS_HOME/bin
  • 7. Install MySQL server Install node-mysql Create table sudo apt-get install mysql-server npm install mysql mysql -u root -p Enter password: mysql> CREATE DB temps mysql> USE temps
  • 8. Create schema Retrieving DB on Node.JS – http://iamapark89.wordpress.com/2013/12/1 4/node-js-2-db-%EC%97%B0%EA%B2%B0/ CREATE TABLE tempData ( tempId int(11) AUTO_INCREMENT NOT NULL, tempDate datetime NOT NULL, tempCelsius decimal(4,2) NOT NULL, humidity decimal(4,2) NOT NULL, constraint tempData_PK primary key (tempId) );
  • 9. Flushing binary with Arduino IDE – http://playground.arduino.cc/main/DHT11Lib Install node-serialport – https://github.com/voodootikigod/node-serialport wget http://nodejs.org/dist/v0.10.12/node-v0.10.12-linux-arm- pi.tar.gz tar xvfz node-v0.10.12-linux-arm-pi.tar.gz sudo mv node-v0.10.12-linux-arm-pi /opt/node/ echo 'export PATH="$PATH:/opt/node/bin"' >> ~/.bashrc source ~/.bashrc npm install serialport
  • 10. Programming server with JavaScript – JavaScript is also famous for front-end (client) Simple & Short Code – No type declaration & implicit type conversion – No multi-threading control Various open source libraries on NPM – Just type ‘npm install {library name}’ to use it Awesome playgrounds – Cloud IDE such as Cloud9 and web itself.
  • 11. RequireJS – De facto JavaScript modularization • http://webofthink.tistory.com/12 Evented I/O asynchronous operation var http=require(‘http’); http.createServer(function (request, response) { // invoked asynchronously });
  • 12. Web Application Server – sudo npm install express routes var express = require('express') , routes = require('./routes') , user = require('./routes/user') , temperatures = require('./routes/temperature') , http = require('http') , path = require('path'); var app = express(); // … omitted … app.get('/', routes.index); app.get('/users', user.list); app.get('/temperatures', temperatures.list); Handles GET /users Handles GET /temperatures
  • 13. Jade Template Engine for Express – sudo node install jade Simplified HTML tag hierarchy doctype 5 html head title meta(name='viewport', content='width=device-width, initial-scale=1') body div(data-role='page', data-theme='a') h1 hr a
  • 14. Responsive web design – Uses jQuery Mobile for free • See the demo: – http://demos.jquerymobile.com/ 1.3.0-beta.1/docs/demos/
  • 15. Using Google Charts – https://developers.google.com/chart/
  • 16. HTTP command, URI & representation – HTTP command: GET, PUT, POST, DELETE, … – URI: non-verb resources & it’s hierarchy – Representation : XML, JSON, … AJAX operation var xhr = new XMLHttpRequest(); xhr.open('get', '/temperatures'); xhr.onreadystatechange = function() { // code the event handler here } xhr.send(null);
  • 17. JavaScript Everywhere – Consider 1st class citizen of web for all Internet of Things. Develop more APIs then Apps – App is opened to use but closed to create. – API gives the chance to mash things up. Data is just nothing without visualization – Imagine how the context can be found in data.
  • 18. Design hypermedia API – Achieve the level 3 at Richardson Maturity Level • http://webofthink.tistory.com/2 Design REST to JavaScript API for better development – Make the mash-up and maintenance better – Provide user’s guide with Web IDL Multi-screen web application – Design the process how to develop N-Screen Apps.