 So, we will be starting with home automation and doing all of that from the lowest level of the hardware to the interface all of that completely done with JavaScript. So, basically let us start with what are the components that we are going to use like what is needed for home automation. So, the first thing like this is a list in the order of from the electrical side to the user. So, the first thing you need is your controller or driver which is like the wall switch that you have which you turn on and off to control your lights. So, in case, yeah, so when we want to do a home automation system we will need an automated solution for the switch and for that we use power electronic switch. Then we need a logic circuit which can be a microcontroller board or a microprocessor board which is going to drive that power electronic device. Then we need a software interface for controlling the logic circuit which could be something like Linux running on a microprocessor or it could be something like an embedded operating system. Then we because your central server which is going to control all your lights and fans and everything in your house is going to be somewhere and your controlling device which could be remote or it could be an app inside your phone is going to be somewhere else so we will need a server client interface and then finally the user interface through which you are going to control it could be via buttons, it could be voice controlled. So, in the following example what we are going to use is as a controller we are using BeagleBone Black. How many of you know about BeagleBone Black? How many know about Raspberry? Okay, so it's something similar to a Raspberry because everybody knows about a Raspberry. It's a micro computer board with input-output pins and it runs a version of Debian. To control the hardware like the pins, the input-output pins on the BeagleBone we are going to use something called BoneScript. I think Andrew was telling about Johnny 5 so it's also something like that. It is a node-based library. It gives you a JavaScript interface to control your hardware. One really nice thing about BoneScript is when you are writing a program with BoneScript it looks very much like how you write a program on the Arduino IDE. It has got digital read, digital write, all those commands. So, BoneScript was actually made specifically for the BeagleBone. It can work on a lot of other boards as well. For creating the API, if it's like a web page hosted on the BeagleBone, you can use socket.io or you can use a Express-based REST API. And for the final user interface, if you want to do it with JavaScript, one of the good MVC controllers are AngularJS. So before we go to actually performing this, let's check out something important. Like you have this thing, a BeagleBone which runs on 3.3 volt, a few amperes of current, and you're actually going to control devices which run on 220 volt and lots of amperes of current. So the basic device that we use are called relay switches, if you have heard of them. As a general term, we have power electronic devices. So you are controlling something, examples are like BJT, which is a transistor, MOSFET, triac, dyac. So let's show a quick animation on how this thing actually works. So if you can see in this video, this circuit basically here is your electronic circuit. And that circuit is your electrical circuit. So when your electronic circuit gets charged, this is actually electromagnet, which pulls that latch and finishes your electrical circuit. So this is the circuit in which you have a nominal amount of current and nominal amount of voltage going on. So this circuit is going to control that. And they are electrically isolated. And you hope that they remain that way, or else you might blow up your controller. So this is basically how any kind of an automation of a heavy electrical circuit goes on. In fact, if you are controlling something of the order of a few kilovolt, then you might cascade a lot of them like this. Like if you can understand, you use one smaller circuit to control a larger circuit, which itself controls another larger circuit. So coming to how bone script works, so this is a very basic example of turning on the current on one of the pins on your Beagle bone. So like a node library, you just require bone script. And then first of all, you select the pin mode. So you do pin mode. USR0 is basically the name of the pin. So there are a lot of pins. There are channels of pins, which are called P8 and P9 channels. Similarly, there are four LEDs already on the board, which are USR0, 1, 2, 3. So for example, this code, what it will do is it is going to set the user 0 pin in output mode. You have to set it into output or input mode, depending on what you need, whether you want to send current out to it, or you want to sense the current that's available on that. And then you do a digital write, which basically writes a digital signal high, something like sending a one signal, which sets the current value to high on that pin. And similarly, what you can do is, this is how you do an input. You want to read the current that is available on the pin. So here we are not using USR0, because USR is basically a LED. So here, in this pin mode, I set input. And after reading, the callback function actually prints the whatever value of current that's available on that particular pin. So this is a longer script, which actually blinks a LED. And this reads the state, which if it is 0 sets to 1, and if it is 1 sets back to 0. And at an interval of every 100 milliseconds, so basically this script is going to toggle an LED. So let's check out a quick demo about this. This visible on my camera is the board that's on my table. And for example, here is the code that I would like to run. So what's it going to do is set all these pins to a high value for a few seconds, two seconds. And it restores them back to, so basically these four pins are used to show the status of the data being transferred. So this is basically a bone script implementation using sockets. Coming back to this is just a kind of a prototype of what we did. So why this is not practically feasible is you cannot, for example, you want to do a home automation. So a user cannot log into the IP address of the Beagle bone and click on a script to run it. So you will obviously need to have a proper API to be able to control this. So that obviously you can do with Express. Express, how many of you are familiar with? So OK. That's the easiest way to create a rest server. And something like you can do switch fan 1. So you will turn on the fan, switch fan 0. You will turn off the fan, and you run the server. And then you can use this rest API from any client that you want. You can make an Android app. You can make a website. And then you can just simply let the app hit on these rest APIs. So let's see how that works. So I don't know if the URL is visible till there. But for example, I have posted this app on the 4,000 port on my Beagle. And if I, for example, let's consider, I'm representing the fan of a room with one of the LEDs. And you can see it got turned on. Then for example, I want to turn the AC on. So I switch AC. So the AC comes on. Similarly, you can turn things off. So till now, it's pretty much basic. So I'd like to hear from somebody here out here. What ideally would you like a home automation system to be like? I mean, you have got your system in place. It can turn on things, turn off things. You can make an app with a couple of buttons. Is that an ideal solution? Or would you like something better than that? Any ideas? Yeah? Jarvis. Awesome. Let's try and do that. So turn on the light. So I'm having a Satyan Reddler moment here. Turn on the AC. Oh, the AC was already on. Turn off the AC. So this voice automation part I've done using wid.ai. Wid.ai, how many of you are familiar with? It's a nice little platform. You can set up your intents out there. Basically, you can record a lot of sentences. Turn on the light, turn off the light, turn on the fan, turn off the fan. Like that, you maybe record 10 or 15 set of sentences. And then it automatically makes sense out of whatever you say. So next time you say turn on the heater, it will create a similar intent. It will use device name as heater. So basically, this is the return data that I get out of wid.ai. Intent device on off, say it is off, and a device type is AC. So basically, that's pretty much it. I wanted to be able to show you turning on and off some real lights. But that would have needed me to set up a 2.0 volt set up here with a PE switch. So that was not possible. So I just throw it open to any questions. Hey, hi, here. So you chose REST as an API for interacting with your device. That makes sense because on your device, you can run that web server, which kind of lessons on that board. Do you have any alternatives to that? Because I have seen those sort of examples a lot. But is there any even lower level protocols which are available for some embedded systems even you cannot plug a web server? That's true. The thing is, when you're talking of something like home automation and you want to productify it, so you will need to have something like a smartphone app or you will need to have something like Jarvis. So in that case, you will have to rely on having a REST API. And you will have to have a proper central server somewhere in your house, which will expose that REST API. And then that will do the lower level operations. So at some point, you will need to have an abstraction of a proper client server kind of thing because today we are talking about smartphone apps and we are talking about something like web apps. But tomorrow there could be something better. I mean, you could have watches or glasses which will find out if you are sleeping or if you are awake and they will control the lights and fans of your rooms accordingly. So you will always have to have a proper segregation of the, and I think the best way to do it is using sockets or using REST APIs. Yeah. Yeah. So have you tried integrating other chips to it? Like say, for example, NFC or like, say I come close to my door and it automatically unlocks, like uses maybe the Wi-Fi or Bluetooth or any other such devices. Exactly. So that is basically we are talking about the application layer. And there is a lot of possibilities out there. I mean, you can pair with your devices to have something like geolocation or Bluetooth proximity. You can have a beacon installed somewhere. And I think Andrew was showing right now about Johnny 5. And in fact, I have a Johnny 5 script also, almost not visible. So basically what I, the example that I showed you turning off light and fan and all that. So that, the exact thing is possible using a Johnny 5 server also. And if you're using Johnny 5, then the possibilities increase because you can read a lot of sensor data also which is connected with your whatever controller board that you're using like on a production environment, you probably not use a BeagleBone. So then there could be a lot of sensors. You can have a sensor with sensors when you're coming into a door, coming out of the door and have thermal sensors whether there is a person inside or not. So the input devices obviously were not there. Like I have only shown voice and like clicks. Yeah, that's the possibilities. As a whole extending the BeagleBone is pretty easy with the chips is what you do. As a whole it's very easy to extend the BeagleBone with whatever peripheral devices. The BeagleBone obviously because it's like a, if you take a 2012 Android phone, a BeagleBone has that much power. It's almost similar processor and RAM and all that stuff. So you can do a lot of stuff with the BeagleBone. So did you evaluate other boards as well like probably Raspberry Pi versus BeagleBone or? It depends on the kind of processing that you need to do. Like if you want to have a complete speech recognition server running on your board or something like that, there is the Odoid and then there is PCuduino which are more powerful because you would not rely on an internet connection for voice recognition if you want to have a completely localized environment. So you will probably have to have a more powerful board or maybe you might have something like Arduino connected with a Pentium based, a proper PC setup, something like that. People have home servers. So you can connect that with a lower powered board. Make sense, yeah, thank you. So do you think is there any security issues for using this thing? Because I still feel without security, it's really difficult to resist. So security is something, I mean, it's a very relative term. So one thing that I do say is that I am somebody from the electronic serial and JavaScript is something I'm doing very recently. I am not a web person and I feel that the number of layers of, you put a virtualization layer, you put an interpreter layer. So every layer comes with its own set of insecurities. If you are using a setup like this, so if there is a vulnerability in an express server, that's automatically part of your system. So at my college, we are doing a lot of projects where we are prototyping home automation systems. We are prototyping systems where lab apparatus can be automated. So we usually prefer to stick to native languages. We do not prefer to do it with JavaScript. So that would reduce your security, but it's like a trade-off between ease of development versus security. Is it a challenge? It is a challenge. If you have a connected home, I mean, you never know your neighbor could hack into it and set fire to your home. So that's possible. Definitely it's possible you can turn your thermostat up and poop your home goes on fire. So that kind of stuff can happen. So it is something that needs to be tackled when there is mass usage of home automation systems. There are a lot of apartments coming up these days in the metros where all of the houses have automation systems. So it is definitely important to keep that in mind that the security and because something like a home automation system has risk to human life. Any other questions? Thank you, Arnav.