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

embedded report
embedded reportembedded report
embedded report
Gopikanth.M Tatavarthi
 
Android and Arduio mixed with Breakout js
Android and Arduio mixed with Breakout jsAndroid and Arduio mixed with Breakout js
Android and Arduio mixed with Breakout js
musart Park
 
Open Source Options for Building your WebRTC Solution, May 2015 @ WebRTC Conf...
Open Source Options for Building your WebRTC Solution, May 2015 @ WebRTC Conf...Open Source Options for Building your WebRTC Solution, May 2015 @ WebRTC Conf...
Open Source Options for Building your WebRTC Solution, May 2015 @ WebRTC Conf...
Alexandre Gouaillard
 
React Native - CirebonDev
React Native - CirebonDevReact Native - CirebonDev
React Native - CirebonDev
Ayat Maulana
 
Electron
ElectronElectron
BonAHA framework - Lab presentation
BonAHA framework - Lab presentationBonAHA framework - Lab presentation
BonAHA framework - Lab presentation
Suman Srinivasan
 
An introduction to workflow-based programming with Node-RED
An introduction to workflow-based programming with Node-REDAn introduction to workflow-based programming with Node-RED
An introduction to workflow-based programming with Node-RED
Boris Adryan
 
Sunspot
SunspotSunspot
Sunspot
pauldeng
 
Sunspot
SunspotSunspot
Sunspot
pauldeng
 
Learn Evothings Studio along with ESP8266
Learn Evothings Studio along with ESP8266Learn Evothings Studio along with ESP8266
Learn Evothings Studio along with ESP8266
Hammad Tariq
 
JavaScript and Internet Controlled Electronics
JavaScript and Internet Controlled ElectronicsJavaScript and Internet Controlled Electronics
JavaScript and Internet Controlled Electronics
Jonathan LeBlanc
 
IOT: Home Automation using Android Application
IOT: Home Automation using Android ApplicationIOT: Home Automation using Android Application
IOT: Home Automation using Android Application
Nikhil Jadav
 
amrapali builders @@ hardware hacking and robotics using the raspberry pi.pdf
amrapali builders @@ hardware hacking and robotics using the raspberry pi.pdfamrapali builders @@ hardware hacking and robotics using the raspberry pi.pdf
amrapali builders @@ hardware hacking and robotics using the raspberry pi.pdf
amrapalibuildersreviews
 
How to make your Money Machine with Internet of Things
How to make your Money Machine with Internet of ThingsHow to make your Money Machine with Internet of Things
How to make your Money Machine with Internet of Things
Jeff Prestes
 
Iot lab manual new
Iot lab manual newIot lab manual new
Iot lab manual new
Dr. Radhey Shyam
 
Raspberry Pi Based GPS Tracking System and Face Recognition System.
Raspberry Pi Based GPS Tracking System and Face Recognition System.Raspberry Pi Based GPS Tracking System and Face Recognition System.
Raspberry Pi Based GPS Tracking System and Face Recognition System.
Ruthvik Vaila
 
Raspberry pi glossary of terms dictionary extended
Raspberry pi glossary of terms dictionary extendedRaspberry pi glossary of terms dictionary extended
Raspberry pi glossary of terms dictionary extended
WiseNaeem
 
Creating books app with react native
Creating books app with react nativeCreating books app with react native
Creating books app with react native
Ali Sa'o
 
Seattle StrongLoop Node.js Workshop
Seattle StrongLoop Node.js WorkshopSeattle StrongLoop Node.js Workshop
Seattle StrongLoop Node.js Workshop
Jimmy Guerrero
 
BonAHA framework - IEEE CCNC 2009
BonAHA framework - IEEE CCNC 2009BonAHA framework - IEEE CCNC 2009
BonAHA framework - IEEE CCNC 2009
Suman Srinivasan
 

Similar to Home automation with javascript (20)

embedded report
embedded reportembedded report
embedded report
 
Android and Arduio mixed with Breakout js
Android and Arduio mixed with Breakout jsAndroid and Arduio mixed with Breakout js
Android and Arduio mixed with Breakout js
 
Open Source Options for Building your WebRTC Solution, May 2015 @ WebRTC Conf...
Open Source Options for Building your WebRTC Solution, May 2015 @ WebRTC Conf...Open Source Options for Building your WebRTC Solution, May 2015 @ WebRTC Conf...
Open Source Options for Building your WebRTC Solution, May 2015 @ WebRTC Conf...
 
React Native - CirebonDev
React Native - CirebonDevReact Native - CirebonDev
React Native - CirebonDev
 
Electron
ElectronElectron
Electron
 
BonAHA framework - Lab presentation
BonAHA framework - Lab presentationBonAHA framework - Lab presentation
BonAHA framework - Lab presentation
 
An introduction to workflow-based programming with Node-RED
An introduction to workflow-based programming with Node-REDAn introduction to workflow-based programming with Node-RED
An introduction to workflow-based programming with Node-RED
 
Sunspot
SunspotSunspot
Sunspot
 
Sunspot
SunspotSunspot
Sunspot
 
Learn Evothings Studio along with ESP8266
Learn Evothings Studio along with ESP8266Learn Evothings Studio along with ESP8266
Learn Evothings Studio along with ESP8266
 
JavaScript and Internet Controlled Electronics
JavaScript and Internet Controlled ElectronicsJavaScript and Internet Controlled Electronics
JavaScript and Internet Controlled Electronics
 
IOT: Home Automation using Android Application
IOT: Home Automation using Android ApplicationIOT: Home Automation using Android Application
IOT: Home Automation using Android Application
 
amrapali builders @@ hardware hacking and robotics using the raspberry pi.pdf
amrapali builders @@ hardware hacking and robotics using the raspberry pi.pdfamrapali builders @@ hardware hacking and robotics using the raspberry pi.pdf
amrapali builders @@ hardware hacking and robotics using the raspberry pi.pdf
 
How to make your Money Machine with Internet of Things
How to make your Money Machine with Internet of ThingsHow to make your Money Machine with Internet of Things
How to make your Money Machine with Internet of Things
 
Iot lab manual new
Iot lab manual newIot lab manual new
Iot lab manual new
 
Raspberry Pi Based GPS Tracking System and Face Recognition System.
Raspberry Pi Based GPS Tracking System and Face Recognition System.Raspberry Pi Based GPS Tracking System and Face Recognition System.
Raspberry Pi Based GPS Tracking System and Face Recognition System.
 
Raspberry pi glossary of terms dictionary extended
Raspberry pi glossary of terms dictionary extendedRaspberry pi glossary of terms dictionary extended
Raspberry pi glossary of terms dictionary extended
 
Creating books app with react native
Creating books app with react nativeCreating books app with react native
Creating books app with react native
 
Seattle StrongLoop Node.js Workshop
Seattle StrongLoop Node.js WorkshopSeattle StrongLoop Node.js Workshop
Seattle StrongLoop Node.js Workshop
 
BonAHA framework - IEEE CCNC 2009
BonAHA framework - IEEE CCNC 2009BonAHA framework - IEEE CCNC 2009
BonAHA framework - IEEE CCNC 2009
 

More from Arnav Gupta

Full stack development
Full stack developmentFull stack development
Full stack development
Arnav Gupta
 
Enhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_osEnhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_os
Arnav Gupta
 
What to do after Rooting ?
What to do after Rooting ?What to do after Rooting ?
What to do after Rooting ?
Arnav Gupta
 
Rooting an Android phone
Rooting an Android phoneRooting an Android phone
Rooting an Android phone
Arnav Gupta
 
Enhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_osEnhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_os
Arnav Gupta
 
Creating your own Android library and documenting it with Javadocs
Creating your own Android library and documenting it with JavadocsCreating your own Android library and documenting it with Javadocs
Creating your own Android library and documenting it with Javadocs
Arnav Gupta
 

More from Arnav Gupta (6)

Full stack development
Full stack developmentFull stack development
Full stack development
 
Enhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_osEnhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_os
 
What to do after Rooting ?
What to do after Rooting ?What to do after Rooting ?
What to do after Rooting ?
 
Rooting an Android phone
Rooting an Android phoneRooting an Android phone
Rooting an Android phone
 
Enhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_osEnhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_os
 
Creating your own Android library and documenting it with Javadocs
Creating your own Android library and documenting it with JavadocsCreating your own Android library and documenting it with Javadocs
Creating your own Android library and documenting it with Javadocs
 

Recently uploaded

“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 

Recently uploaded (20)

“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 

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.