SlideShare a Scribd company logo
Home Automation
Done completely with Javascript
The Basics
Components
1.A controller/driver (Power Electronic Switch)
2.Logic circuit for controller/driver
3.Software interface for logic circuit
4.Server-Client, or Socket based model (the API)
5.User Interface
What we will use
Controller : BeagleBone Black
A microcomputer board (like Raspberry Pi), with multiple
pinouts, running on an ARM processor. Regular Debian/Ubuntu
Linux OS.
Language (HW control): BoneScript
A Node.js plugin developed especially for boards like BBB
which provides a JS interface to turn current to the pins of a BBB
on or off (or read the current for input PINS). BoneScript is
similar to the Arduino language.
What we will use
Language (API) : Socket.io or Node.js REST
If we directly access a webpage hosted on the BBB, we can use
socket.io, or we can create a RESTful API on the BBB.
Language (UI): AngularJS
We can use any MVC or pure JS too. This is the frontend for
the given REST API on the BBB to control the states of the
switches.
How switching works
ïŹ
Power Electronics – Controlling Electrical
appliances with Electronics
ïŹ
Common switches - BJT, MOSFET, TRIAC,
DIAC
ïŹ
A 5V-1A cirtuit can control a 220V-15A circuit.
How switching works
BoneScript
Setting a PIN output to high current
var b = require('bonescript');
b.pinMode('USR0', b.OUTPUT);
b.digitalWrite('USR0', b.HIGH);
BoneScript
Read input current from a PIN
var b = require('bonescript');
b.pinMode('P8_19', b.INPUT);
b.digitalRead('P8_19', printStatus);
function printStatus(x) {
console.log('x.value = ' + x.value);
console.log('x.err = ' + x.err);
}
BoneScript
Blink a LED
var b = require('bonescript');
var led = "USR3";
var state = 0;
b.pinMode(led, 'out');
toggleLED = function() {
state = state ? 0 : 1;
b.digitalWrite(led, state);
};
timer = setInterval(toggleLED, 100);
stopTimer = function() {
clearInterval(timer);
};
setTimeout(stopTimer, 3000);
Basic home automation with Bonescript
Connect LEDs on some of the PINS of the BBB
Create a webpage on the BBB
Make buttons on the page. Each button calls a digitalWrite function
corresponding to connected LEDs.
On page load read PIN states and updates button accordingly. Red
color for off, Green for on (or something similar).
Connect the BBB to WLAN/Internet.
Access IP of BBB from Laptop/Mobile, click the buttons and watch the
LEDs go ON and OFF.
*** Make a video, or show live demo of this if WiFi available ***
Why this isn’t practically applicable ?
HAVE TO open the particular webpage on the particular
IP. Who remembers URLs and IPs ?
No App for mobile, have to do via browser.
Clients cannot be built for devices that do not have JS
support.
Solution : REST Api
We will create a simple REST API using Node.js
and Express 4.
var express = require('express');
var app = express();
app.get('/switch/fan/:state', function(req, res) {
if (req.params.state === 1)
// digitalWrite high to the required PIN
else
// digitalWrite low to the required PIN
});
app.listen(8080);
Solution : REST Api
We make REST calls from the client to turn the
fan off or on
http://bbb.ip/switch/fan/0 -- **to turn off the fan**
http://bbb.ip/switch/fan/1 -- ** to turn on the fan**
Now we can make whatever client we want (MVC client app, or
Android/iOS app, or even a command line based noGUI app).
AngularJS frontend
ïŹ
Create buttons with asynchronous calls to rest
API
ïŹ
Responsive UI + Material/Bootstrap themes.
Such design, much awesome.
ïŹ
Can also turn into Android/iOS clients using
Ionic etc.
GPIO/I2C run through
ïŹ
General Purpose I/O – Kernel interface to
control currents over sysfs.
ïŹ
Some info on why using C/C++ or shell to
actually control the currents is more efficient
than Python/Node.

More Related Content

Similar to Home automation with javascript (20)

PPTX
Bare metal Javascript & GPIO programming in Linux
Alexander Vanwynsberghe
 
KEY
Android and Arduio mixed with Breakout js
musart Park
 
PDF
Building Droids with JavaScript
Andrew Fisher
 
PPTX
Controlling robots using javascript
Sudar Muthu
 
PPTX
Hackbright Workshop
Matt Haines
 
PDF
Api workshop
Matt Haines
 
PDF
Teardown Conference: hacking appliances with netduino + xamarin
bryan costanich
 
PPTX
Controlling the world with Arduino & JavaScript
Magnus Green
 
PDF
Hardware hackers - hacking appliances with netduino + xamarin
bryan costanich
 
PDF
How To Electrocute Yourself using the Internet
Alexander Roche
 
PPTX
Final Presentation - Edan&Itzik
itzik cohen
 
PDF
Arduino: interruptor de encendido controlado por Internet
SANTIAGO PABLO ALBERTO
 
PDF
Html5 game, websocket e arduino
Giuseppe Modarelli
 
PDF
Html5 game, websocket e arduino
monksoftwareit
 
PPTX
CodeRage XI international Conference: Arduino + Delphi Mobile Apps
Vic Fernandes
 
PDF
DEVOXX Let's Get Physical: I/O Programming with Java on the Raspberry Pi usin...
savageautomate
 
PDF
Design of home automation base on internet
IRJET Journal
 
DOCX
Control of lights + fan using wi fi and bluetooth
svsembedded
 
DOCX
Report Home automation using arduino
Ikram Arshad
 
PPTX
Hacking into IoT using JavaScript
Sajan John
 
Bare metal Javascript & GPIO programming in Linux
Alexander Vanwynsberghe
 
Android and Arduio mixed with Breakout js
musart Park
 
Building Droids with JavaScript
Andrew Fisher
 
Controlling robots using javascript
Sudar Muthu
 
Hackbright Workshop
Matt Haines
 
Api workshop
Matt Haines
 
Teardown Conference: hacking appliances with netduino + xamarin
bryan costanich
 
Controlling the world with Arduino & JavaScript
Magnus Green
 
Hardware hackers - hacking appliances with netduino + xamarin
bryan costanich
 
How To Electrocute Yourself using the Internet
Alexander Roche
 
Final Presentation - Edan&Itzik
itzik cohen
 
Arduino: interruptor de encendido controlado por Internet
SANTIAGO PABLO ALBERTO
 
Html5 game, websocket e arduino
Giuseppe Modarelli
 
Html5 game, websocket e arduino
monksoftwareit
 
CodeRage XI international Conference: Arduino + Delphi Mobile Apps
Vic Fernandes
 
DEVOXX Let's Get Physical: I/O Programming with Java on the Raspberry Pi usin...
savageautomate
 
Design of home automation base on internet
IRJET Journal
 
Control of lights + fan using wi fi and bluetooth
svsembedded
 
Report Home automation using arduino
Ikram Arshad
 
Hacking into IoT using JavaScript
Sajan John
 

More from Arnav Gupta (6)

PPTX
Full stack development
Arnav Gupta
 
PPT
Enhancing and modifying_the_core_android_os
Arnav Gupta
 
ODP
What to do after Rooting ?
Arnav Gupta
 
ODP
Rooting an Android phone
Arnav Gupta
 
ODP
Enhancing and modifying_the_core_android_os
Arnav Gupta
 
PPT
Creating your own Android library and documenting it with Javadocs
Arnav Gupta
 
Full stack development
Arnav Gupta
 
Enhancing and modifying_the_core_android_os
Arnav Gupta
 
What to do after Rooting ?
Arnav Gupta
 
Rooting an Android phone
Arnav Gupta
 
Enhancing and modifying_the_core_android_os
Arnav Gupta
 
Creating your own Android library and documenting it with Javadocs
Arnav Gupta
 
Ad

Recently uploaded (20)

PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Jak MƚP w Europie ƚrodkowo-Wschodniej odnajdują się w ƛwiecie AI
dominikamizerska1
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Python basic programing language for automation
DanialHabibi2
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Jak MƚP w Europie ƚrodkowo-Wschodniej odnajdują się w ƛwiecie AI
dominikamizerska1
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
July Patch Tuesday
Ivanti
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Ad

Home automation with javascript

  • 2. The Basics Components 1.A controller/driver (Power Electronic Switch) 2.Logic circuit for controller/driver 3.Software interface for logic circuit 4.Server-Client, or Socket based model (the API) 5.User Interface
  • 3. What we will use Controller : BeagleBone Black A microcomputer board (like Raspberry Pi), with multiple pinouts, running on an ARM processor. Regular Debian/Ubuntu Linux OS. Language (HW control): BoneScript A Node.js plugin developed especially for boards like BBB which provides a JS interface to turn current to the pins of a BBB on or off (or read the current for input PINS). BoneScript is similar to the Arduino language.
  • 4. What we will use Language (API) : Socket.io or Node.js REST If we directly access a webpage hosted on the BBB, we can use socket.io, or we can create a RESTful API on the BBB. Language (UI): AngularJS We can use any MVC or pure JS too. This is the frontend for the given REST API on the BBB to control the states of the switches.
  • 5. How switching works ïŹ Power Electronics – Controlling Electrical appliances with Electronics ïŹ Common switches - BJT, MOSFET, TRIAC, DIAC ïŹ A 5V-1A cirtuit can control a 220V-15A circuit.
  • 7. BoneScript Setting a PIN output to high current var b = require('bonescript'); b.pinMode('USR0', b.OUTPUT); b.digitalWrite('USR0', b.HIGH);
  • 8. BoneScript Read input current from a PIN var b = require('bonescript'); b.pinMode('P8_19', b.INPUT); b.digitalRead('P8_19', printStatus); function printStatus(x) { console.log('x.value = ' + x.value); console.log('x.err = ' + x.err); }
  • 9. BoneScript Blink a LED var b = require('bonescript'); var led = "USR3"; var state = 0; b.pinMode(led, 'out'); toggleLED = function() { state = state ? 0 : 1; b.digitalWrite(led, state); }; timer = setInterval(toggleLED, 100); stopTimer = function() { clearInterval(timer); }; setTimeout(stopTimer, 3000);
  • 10. Basic home automation with Bonescript Connect LEDs on some of the PINS of the BBB Create a webpage on the BBB Make buttons on the page. Each button calls a digitalWrite function corresponding to connected LEDs. On page load read PIN states and updates button accordingly. Red color for off, Green for on (or something similar). Connect the BBB to WLAN/Internet. Access IP of BBB from Laptop/Mobile, click the buttons and watch the LEDs go ON and OFF. *** Make a video, or show live demo of this if WiFi available ***
  • 11. Why this isn’t practically applicable ? HAVE TO open the particular webpage on the particular IP. Who remembers URLs and IPs ? No App for mobile, have to do via browser. Clients cannot be built for devices that do not have JS support.
  • 12. Solution : REST Api We will create a simple REST API using Node.js and Express 4. var express = require('express'); var app = express(); app.get('/switch/fan/:state', function(req, res) { if (req.params.state === 1) // digitalWrite high to the required PIN else // digitalWrite low to the required PIN }); app.listen(8080);
  • 13. Solution : REST Api We make REST calls from the client to turn the fan off or on http://bbb.ip/switch/fan/0 -- **to turn off the fan** http://bbb.ip/switch/fan/1 -- ** to turn on the fan** Now we can make whatever client we want (MVC client app, or Android/iOS app, or even a command line based noGUI app).
  • 14. AngularJS frontend ïŹ Create buttons with asynchronous calls to rest API ïŹ Responsive UI + Material/Bootstrap themes. Such design, much awesome. ïŹ Can also turn into Android/iOS clients using Ionic etc.
  • 15. GPIO/I2C run through ïŹ General Purpose I/O – Kernel interface to control currents over sysfs. ïŹ Some info on why using C/C++ or shell to actually control the currents is more efficient than Python/Node.