 Hello everybody. Good afternoon. So I'm Saurabh and I have the privilege of taking the first talk after lunch. So please bear with me. I will be talking about Cylon.js and how you can integrate JavaScript with IoT. How many of you are working on IoT solutions? All right. Not much. Any of you have worked with an RDO here? Okay, cool. So before I start talking about Cylon, we've all seen what JavaScript can do, right? So it's almost everywhere. It's dominating the entire landscape of software development. You can run JavaScript everywhere. We have had great talks for the past two days telling us how to handle speed for performance for JavaScript. It's almost like, you know, the Australian teams of the early 2000s where they were almost dominating all the matches and JavaScript was almost something like that where you could run it almost everywhere now. We will be talking about IoT and how you can run your IoT solutions, control devices. I have a Pi, an Arduino and some more sensors connected and we'll see how I can control them remotely as well as locally. Cylon.js is a JavaScript framework for robotics and physical computing using Node.js. At its core, it is using Node and I'll show you how you can get started with it, how you can install Cylon and then build simple solutions. But the cool part about it is that it supports multiple and different hardware devices. So if you're looking to say build for multiple devices at once, if you're planning to get into robotics and looking to integrate JavaScript and handle all these devices together, Cylon.js may be a good framework for you. And it's almost the programming that takes place with Cylon is almost as easy as web development now. I'll show how this code actually runs. But in fact, if you have to run one code across multiple platforms, there's just a minimal changes in the code that you need to do in your programs to make it run across say an Arduino or Raspberry Pi. Of course, the setup initially will be there where you'll have to set the environment so that Cylon can run because it's using its own protocols. So for example, if there's an Arduino, it will use a Formata protocol so that JavaScript can actually interact with the microcontroller. And I'll delve deeper into what are the architecture, what is the architecture of Cylon.js? I'll try to wrap this up quickly because I want to focus more on the demos, but I'll just go through this very fast. The first one is MCP. So anything in a Cylon.js program is handled by something called a master control program, which is responsible for coordinating everything inside Cylon and including starting, stopping both robots and the API. I'll go through this quickly because this will make more sense when we see the actual code, but at least you'll get a background of where we are heading. Anything in a Cylon program is written in a Robo. So Robo is a collection of, say, an entire set of hardware devices and you want to control these devices through JavaScript. You can have multiple robots connected and you can control all these Robos within Cylon or JS. Each Robo may be a collection of devices and connections. And what are devices and connections? Basically, they are an abstraction layer, say over drivers and adapters. Now again, there are new terms coming here. What are drivers and adapters? I'll to explain it very in very simple terms. Think of it like this. If you have a Raspberry Pi, a Raspberry Pi is a board which can run a lot of stuff, right? It can run Debian. It can run Raspbian. It's a custom flavor of Debian and you can run Node.js on top of it. And obviously you can Cylon on top of it. So if you have to connect to a Raspberry Pi, you will be defining the adapter for connecting to the Raspberry Pi in your Cylon program. Again, once you declare that adapter, after that, if you want to change the code and put it somewhere in, say, an Arduino, the only changes that you need to probably do there is change the adapter pattern that is following instead of the adapter for a Raspberry Pi, you will say, okay, adapter for an Arduino and should start working. So before I go further, I'll start with this code. Is it visible at the back? All right, cool. So the first thing which you obviously need while running a Cylon program is the Cylon module. And for that, you just write bar Cylon, require Cylon. You will end up installing it. And I was talking about the Robo. So this is where your entire connection starts. If you declare this Robo and start writing the connection in the devices that it will support, you can clearly see that if you're writing for an Arduino, Cylon will use a protocol called a formata protocol. And the port, which is it is connected to my laptop right now. So com three, in case of Linux, it would be dev TTY zero. And you could specify that within the Cylon program itself. And devices right now I'm using the driver for LED. Now that's what I was talking about in the slides as well. These are the two main parameters which you need to write in your Cylon program. So in the devices part, you will write LED or if you have say a micro servo, you will write that I want to rotate a servo using this driver. All these drivers and adapters, if they are supported by Cylon, they will start working. So that's also an important part when you're building your robotic solution. You need to take care if, if that platform is supported by Cylon good enough, because then it makes it very easy for you to write code and you can directly write the drivers, write the adapters and start working with it through the methods that it gives you. The main method, think of it like a main function we all have in our programming languages, right? Here it will be the work function where it's giving you some utilities as well. Where every one second, what I want to do is I want to toggle this LED. And as soon as I define my robo, I'm starting it right here. So you can see it's getting started. And instead of, how do you know, if I'm planning to work with a Raspberry Pi, here's the code for that. If you notice it carefully, everything remains the same except the connections that I have where I'm defining a connection for the Raspberry Pi, giving it a name Raspberry Pi and the adapter for that is defined as a Raspberry Pi. And there's one thing which you need to note when you're working with Cylon, you have support for all these adapters in separate node modules. So if you're looking to work with a Raspberry Pi, for example, you will install a separate mode, no model for that. Or if you're looking to interact with say a GPIO pins of a Raspberry Pi, GPIO, general purpose input output to interact with the input and output pins of a Raspberry Pi, to say, for example, I have an LED, you will start installing that module. So everything in Cylon is broken up. Whatever you need, you start installing that module and start using it in devices. I've written the same thing, but the pin here is has changed because I'm using a GPIO pin and the pin number here refers to the physical pin number on a Raspberry Pi. So Raspberry Pi has a lot of lots of pins and there are some pins marked for GPIO, some VCC ground. I'm using the pin 11, which is a GPIO pin. And in my work function, I'm telling every second, toggle this LED. And the same thing will happen in an Arduino and a Raspberry Pi. Just to get this started, I will run this. And if you see at the screen now, this starts getting, this starts blinking LED, a simple code just to get you started of how you write function, how you write programs in Cylon, but we'll delve deeper now. And I'll just stop this. So what I'm doing is I'm just running node on my computer. Arduino is connected to this computer through my, through a wire. And since it is defined on com three, I've defined that this is the port that I want to listen on. And this is running perfectly using Cylon. I'll just stop this. I'll just go back. Now, if you may ask if you want to connect, say multiple devices, if you want to add an LED plus a button, how do you do that? Again, very simple. If you just want to add the list of devices, you will add it in the devices part, LED button. And the driver for a button will be separate again. It will be the button driver. And I've connected to a separate pen. And if you look at the functions, it's very simple to see. As soon as you push a button, the LED starts toggling. And this is possible not only with devices. So if you're building a connection with, say, a leap motion as well as an Arduino, you can directly define that in the connections parameter at the top. And in the work function again, you will just tell the Cylon robot that this is what I want to do. I want to turn on or turn off my LED. If the length is greater than zero, I want to turn it on. And if I want to turn it off, if the length is not greater than zero. So pretty easy. I'll just show a few quick demos. But before that, this is what we had. What drivers and adapters. Adapters are in charge of connecting to platforms again. And adapter classes ensure that the drivers are able to directly communicate with the platform. And the drivers, meanwhile, drivers, which you saw for, say a server or an LED, they are used to issue commands, but they are not concerned of how those things are connected. That is the part of an adapter. And this is an example. So say for example, a server driver, it will know all the commands to tell a server to turn to a certain angle, but it has no idea of how to connect to the server because the adapter will take care of that part. The adapter means the Raspberry Pi adapter, the Raspberry adapter will take care of how to connect to a server and start rotating it. In the architecture diagram again, it's very simple. You have a robot, you have connections and devices. Now a lot of things are abstracted. So connections are an abstraction over adapters and devices are abstraction over drivers. And there are events which are being handled by the robot as well. And we talked about the MCP at the beginning and the MCP is the overall program, which handles all of these things, but how the interaction with the robot takes place is right here, but it takes place with a connection and an adapter. So in fact, if you want to run the same code on an LED, we just saw that you just need to write whatever the driver and adapter is there for that specific platform. You only change the adapter and it should start working fine. Now I'll delve deeper into how you can take, take care of this remotely, remotely code samples interacting remotely right here. So I have another program here in which I want to say run server remotely. I want to, the server, if I just show you this screen share, the server is this blue part, which you see, this has a fan at the top. You could say that a very small financial start rotating, but I want to do this remotely. Now what I'm doing is a silent is a framework which can help me do that, but to interact with it remotely, I can use cloud as well. So I'm using another, I'm using the SDK for Node.js for Azure. And I'll just directly go to my commands and start running this program. I think is internet down? All right. I guess it is. All right, not a problem. Anyways, I wanted to connect to this Raspberry Pi through my, through my laptop, because I already SS SS edged into it, but thankfully I have the demo video available with me. So I will go to my backup and I will start showing you that if the internet is back within the next two minutes, I can show you the live demos, but this is how it's working right now. This is the Raspberry Pi where I'm running this program for remote server. This is the server, which you just seen connected to the Raspberry Pi. And this is my utility for interacting with cloud. So if you look at, look at this carefully, this says that this is the device ID, the server for, and I want to start the server. As soon as I do that, I click on send. You notice I just clicked on send and this thing should start auditing. All right. So, uh, where is this other video? How many do you want in time? Five minutes. All right. Cool. And it is up. Perfect. Just give me a couple of minutes. I'm just, uh, SSH into this again. 172.16. So I'm just noting down the IP of the Raspberry Pi. And if everything goes well, I should be able to connect to the Raspberry Pi. Okay. Perfect. And now if I have to say, run this program, I will do this. It starts being working. Current angle is 20. I'm just logging the current angle. But if I want to do this over remotely, say, for example, if you guys want to do this, I can give you a utility which can control this server from a separate location. And I will just come here. All right. Okay. Message is to device. My device is called server. And this is the message that I want to pass to it. Now, as soon as I do that, my server should start rotating. And if you look at this carefully, uh, this part, it starts reading at a, at 10 degrees per second. And this is all getting logged on my screen as well. So, uh, if I just come back to my screen, you see the current angle that it is running on 1790, it's reducing, then coming back again. So this is how you can do it. I'm using the, uh, Cloud SDKs and Cylon, Cylon.js to do it. Uh, before I run out of time, I'll just show a quick demo again. And that will be how you can do it the other way, where you can send data from these devices, uh, using JavaScript and, uh, monitor it real time on a website. For that example, I have this thing set up to see this node button.js. All right. So this is a button which I've connected to, uh, the Raspberry Pi. Uh, and if I just come back here, this should load if it hasn't signed me out. Okay. And I'll start monitoring this device. So this is the number of clicks, the total number of clicks that I've done on a button. And this is a website running somewhere. So I'm using Power BI, uh, for example, but I can use any other thing to just start monitoring on a, monitoring on a website. I'll just go to this, select this button and start monitoring it. And I will, so, uh, look carefully what happens here. I will, as soon as I click up, click a button, this thing, this cloud utility should tell me that I have received a command and it's working there. The cloud, the cloud utility tells me that I have received the, uh, button one click and the data at the back, the website, which is running remotely, this number should start updating again. So it was 39 before and it should start showing 40 and within a couple of seconds, uh, it should start, so start showing 41 as well. So yeah, pretty much that's it. Running everything on JavaScript, uh, nothing else. And with that, I think I'm running short on time. I will just close the session in tracking remotely. Yeah. Thank you. Questions, questions. Cool. No questions. Hello. One second. Yeah. I know there's a new thing. Um, what is a good device to start with? What is a good device to start with? So most of the folks when you're starting Hello world kind of starting when you're sitting into IOT, they use a Raspberry Pi. The latest one is the Raspberry Pi three and, uh, you could order it on Amazon. Uh, I think it costs you 3000 rupees and get started with it by a few sensors. The Hello world for any IOT device is a blinky application where you're blinking a device, uh, and use JavaScript. Is there any way to connect using Bluetooth devices? Absolutely. There's a way to connect to Bluetooth. Raspberry Pi three itself has built-in support for Bluetooth and you could interact with various devices over Bluetooth as well. Thanks. Yeah. So, um, does it has any performance hit or anything? Um, because we're using JavaScript for interacting with the hardware. Sorry. Does it has any performance hit or because we're using, um, generally I see people use low level languages for interacting with the hardware, but we are using JavaScript here. Absolutely. So how was it? So, uh, for devices which are very low cost, say about three, four years back, we were still using C, uh, because it's a low level language and you couldn't interact directly with the hardware, but with devices, the power of devices coming up, we have a Raspberry Pi. They're able to give support for JavaScript very well. The performance also good. So now even the high level languages are good to work with, even Python and yeah. Devices does the framework in itself give you anything to optimize? Like if you're running out of memory on the device or let's say you're creating too many tasks in your application, the framework, uh, by itself, uh, doesn't give you, can you hold the mic? So, uh, since the, uh, application is going to run on low memory devices, like maybe you'll have a limited amount of memory. So is it, uh, is it, uh, does the framework give you any way of identifying potential, uh, out of memory kind of scenarios? Yes. Yes, you can do that. So at the end it's running only JavaScript. You could write your own, uh, functions there, which are interacting with the system properties of Raspberry Pi or how do, how do you debug on the device? I mean, how do you debug on the device? There are two ways. One is when you're doing it locally, when you have the device to yourself, in that way, you can just directly plug the device and start seeing what's happening. And you directly access it into it. The other way is when you're trying to do it remotely. Say for example, if you have a solution, I have a solution and you're deploying it at a place far away from you. In that case again, uh, what we usually do is we utilize cloud because it's giving me device to cloud as well as cloud to device communication. So I send the command to, to my Raspberry Pi, for example, and based on the commands that I've generated, uh, it will give me a reply that this is the status of the memory. This is the status of my hard disk or stuff like that. But that is the part which, uh, you have to go ahead and develop yourself. Uh, I've built a similar solution. So if you go to my GitHub, uh, GitHub slash sort of, I built a similar solution where you could handle it remotely and start seeing, uh, the various parameters. Hi, Sarah. Who is this? Yeah. Uh, this is Abhijeet. Uh, I have been using, uh, Windows, uh, as your IoT, uh, IoT hubs. Windows as your, I mean, Windows as your IoT hub. Okay. It's not Windows. It's Microsoft. Right. So, uh, I mean, silent.js I'm hearing for the first time. Okay. I mean, uh, in which scenario would you rec, be recommending this, uh, silent.js because, uh, most of the cases if you are on, um, Windows IoT, right? So you have mostly everything is accessible to you via native CSAP language. Okay. You're talking about Windows IoT core, is it? Yes. All right. So, uh, silent.js is mostly used where you have, uh, multiple devices and you want to get started with them and interact between those devices. But you can run silent.js on a Windows IoT core machine as well because, uh, Chakra and JavaScript engine can run on a Windows IoT core machine. And that's what silent needs. It just needs a JavaScript environment to run. At the end of the day, the success of this silent.js will depend upon how many adapters are absolutely. So right now, uh, it has a great support. It has about, I think it's 41. And they're not only low level hardware devices, uh, say for example, a pie, anything, it has support for a drone as well. So if you're using an AR drone for that matter or any other device, it has support for that as well. So, uh, it's mostly used where you're trying to build multiple devices, build, build robots and make them connect to each other. That's where silent is. What we generally see is whatever comes from Microsoft that is well known for being integrated with end to end solution. So, uh, silent.js, does it offer anything good to, uh, integrate with IoT hub? Silent.js, uh, will not give you inbuilt support for IoT hub, uh, because the part of interacting with the cloud is dependent on the on whichever companies cloud you're using. So in this case, if you're using Azure, it's responsibility of Microsoft to, uh, make IO IoT hub SDKs in Node.js for the community. And all these SDKs are open source. So you could just check how they work. You could use those SDKs, install them, and that's where you connect to cloud. Silent wouldn't give you out, out of the box. Azure will give you that. One question there. The others, please meet the speaker outside. We're running short of time. Who is this? Uh, I'm, I just want to know where I can use this silent.js. Can I connect to other, other cloud platform like AWS? Absolutely. You could, you could do it to any cloud platforms. If, if you use it, if you have a SDK for IoT, uh, for that cloud, uh, that's, that's what it needs. The part of interacting with the cloud rest rests with what the SDKs for that cloud supports. Silent will give you, uh, options for building IoT solutions and get interacting with them. But once you're trying to do something remotely, uh, and interacting with AWS, uh, in that method itself, you use the AWS IoT SDKs. And since it's Node.js running on the platform, you directly, uh, install those SDKs and start pushing it to cloud. I have one more question. Like can program our adenos with this? Sorry? Can a programmer adenos devices with this? Can you program Arduino devices with this? Yes. Uh, so the first one which I showed you was an Arduino, uh, which the blinky thing, which, which was happening here. And once that happens, uh, uh, silent.js would run. So it has a built-in adapter for, for, uh, Arduino. It's using a protocol caller from our protocol. So, uh, it's able to interact with JavaScript to an Arduino. But again, if you want to push to cloud depends on the SDKs of the cloud provider. So if, if they're giving support for a particular platform, good enough. Thank, thanks for that. Thank you. Thanks.