AV-Portal 3.23.2 (82e6d442014116effb30fa56eb6dcabdede8ee7f)

Internet of Things

Video in TIB AV-Portal: Internet of Things

Formal Metadata

Internet of Things
Connecting Rails with the Real World
Title of Series
Part Number
Number of Parts
CC Attribution - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this license.
Release Date

Content Metadata

Subject Area
According to Gartner, there will be nearly 26 billion devices on the Internet of Things (IoT) by 2020. ABI Research estimates that more than 30 billion devices will be wirelessly connected to the IoT by 2020. This discussion provides examples examples, ideas, tools and best-practices for Rails developers to start building IoT applications that connect their web applications to the real world.
Presentation of a group Computer animation Gamma function Content (media) Basis <Mathematik> Internet der Dinge
User interface Presentation of a group Demo (music) Code Cellular automaton Basis <Mathematik> Information technology consulting Number Pi Data management Computer animation Different (Kate Ryan album) Personal digital assistant Videoconferencing Right angle Internet der Dinge
Type theory Computer animation Coroutine Sound effect Right angle Bit Figurate number Graph coloring Arithmetic progression Form (programming)
Graph (mathematics) Term (mathematics) Multiplication sign Debugger Physical law Musical ensemble Cycle (graph theory) Information security
Vector space Set (mathematics)
Building Group action Digital electronics Pay television Computer file Multiplication sign 1 (number) Virtual machine Regular graph Portable communications device Power (physics) Number Web 2.0 Fluid statics Internetworking Energy level Software testing Office suite Cartesian coordinate system Word Computer animation Software Integrated development environment Order (biology) Point cloud Video game Right angle Object (grammar) Internet der Dinge
Mobile app Code Multiplication sign Source code Coroutine Ultraviolet photoelectron spectroscopy Water vapor Number Web 2.0 Mathematics Information security Traffic reporting Personal area network Fitness function Interactive television Physicalism Cartesian coordinate system Leak Computer animation Angle Video game Self-organization Right angle Object (grammar) Internet der Dinge Local ring Spacetime Row (database)
Group action Server (computing) Mobile app Service (economics) State of matter Multiplication sign Online help Client (computing) Regular graph Graph coloring Event horizon Mathematics Computer cluster Bit rate Term (mathematics) Different (Kate Ryan album) Videoconferencing Form (programming) Dependent and independent variables Debugger Cartesian coordinate system Connected space Exterior algebra Computer animation Right angle Object (grammar) Internet der Dinge Cycle (graph theory)
User interface Scripting language Slide rule Game controller Group action Mapping Link (knot theory) Cellular automaton Debugger Interactive television Electronic program guide Bit Client (computing) Mereology Event horizon Web 2.0 Computer animation Endliche Modelltheorie Object (grammar) Library (computing)
User interface Group action Game controller Mapping Code Multiplication sign Source code Data storage device Interactive television Database Cartesian coordinate system Graph coloring Event horizon Attribute grammar Connected space Computer animation Hash function Personal digital assistant String (computer science) Right angle Object (grammar) Cycle (graph theory)
Domain name User interface Group action Debugger Database Parameter (computer programming) Cartesian coordinate system Graph coloring Message passing Computer animation Endliche Modelltheorie Object (grammar) Internet der Dinge
Point (geometry) Slide rule Digital electronics Service (economics) Thread (computing) Code Multiplication sign Sheaf (mathematics) 1 (number) Electronic program guide Mereology Rule of inference Event horizon Internetworking Single-precision floating-point format Software testing Social class User interface Plastikkarte Bit Cartesian coordinate system Computer animation Vector space Personal digital assistant Telecommunication Object (grammar) Figurate number Library (computing)
Personal identification number Trail Mobile app Server (computing) Thread (computing) Graph (mathematics) Service (economics) Debugger Control flow Counting Database Cartesian coordinate system Event horizon Impulse response Programmschleife Computer animation Personal digital assistant output Right angle Freezing Sinc function
Point (geometry) Group action Mobile app Multiplication Divisor Software developer Neuroinformatik Graphical user interface Word Computer animation Software Object-oriented programming Different (Kate Ryan album) Phase transition Right angle Internet der Dinge Object (grammar) Spacetime
Mobile app Game controller Building Group action INTEGRAL Software developer Source code Bit Cartesian coordinate system Mereology Surface of revolution Computer animation Different (Kate Ryan album) Right angle Object (grammar) Internet der Dinge Computing platform
Computer animation Integrated development environment Lecture/Conference
the in and in the end of the and this remark as and 2 gamma presentation Internet of Things and it's a topic them very very fast about with and not something I do on a day-to-day basis for work but I hadn't tinkering within an Internet of Things and reading a lot about it so I want to share that with you guys the today so that then you walk through and a simple rails based on Internet of Things Active built on and then kind of talk runs in the background and content from the Internet of Things and and then also talk through and the future of the Internet of Things and kind of where see the work workers you going so this is the quickly but it into
background introduction of for around the cell I had a roller-coaster career which is that of a tried and done a lot of kind various different things started off as a political science major then went the business where tried management consulting and venture capital and before I can start teaching myself to learn a code really loved it so into the fire in school but and conceived to get a formal education there and now I'm working at a small legal text are up in all cases like so I certainly don't have the number of years experience that a lot of I know a lot of you guys have but that I love it it's it's it's been an awesome right so far very excited to be here today as well and then further on a day-to-day basis and use rails and an angular and and a kind as I mentioned as kind of a Internet of Things and narrative I've ever really gotten into it kind tinkering along with raspberry pies and windows as well so
so before I kind of get into the presentation when you wanted to write daily routine just a quick disclaimer I had about all this stuff here and the figured had demo might be a little better if you guys can see there and also videotaped that so of history as the video the that
well known which the for
scraping called this look through that what what is is it that it's actually doing them a little bit more in detail but I had the the actual wear that on the on the left and the right kind of that might things aren't set up at home on the right and are kind of go through what might what my daily routine is and so in the morning I wake up I I turn my lights on but I'm really cranky in the morning so I need to turn this day my light all that so I do that and as the day kind of progress is supposed to be good to kind of get a renter type of light for your circadian rhythms that using kind of form there I can start changing the color of my light as well then after that going to the next that and I really need some caffeine what I do is I go to the appliances had and I turn on the coffee maker but as you can see and I start getting a little coffee that starts coming down and being made that's all connected to an odd we noted that the figures guys was see the set up again show that afterwards the then the start sound effects
that the as the 2nd term a coffee maker off what about an and then I turn on and turn on my neighbor and music playlist who move in miss me were so this is this is in the middle some playing playing happy and usually never happy in the morning so far and it's trying permeable of that usually never works but it has a
leading as I'm leaving the door in my apartment and would return turn on my security my motion detector and on the right side still graph and that's and that kind of lights up every time this motion and you should see a kind of a graph over time changing with account of motions as well and that all the front end and it's kind of a law that there's just throw the it that on the on the right side as well so as you can see the little but this it's like this thing here but you can see cycle of motion detector and and so it's about a
set that up before before I leave 1 if I want I can also set and as a and the retina silent alarm it's kind of a lotta alarm so the answer so again kind of setting up the motion vector but now connecting with it with the with that listeners and and Canada having to to interact with 1 another but during the day but
when coding I like to listen to be at the end of what we do good in blue and then up at the end of the day and after maybe on Friday or Saturday so I swear online the low that's a hell of a lot this so that's kind of
a quick overview of the of that that build sigh of candy go into more
detail but it's in into how that so how it's working out right
so the high levels of background this on the Internet of Things application is a gun at angular application that's running around in the cloud but I'm kind of serving that up with our using do shot these dish of words really cool but it's kind of like a rogue group but for static applications it's really easy to push and applications up and then the angular application and consumes the API and from my Rails that and the real that is actually running locally on on a raspberry pi and that's kind of serving kind of the the the Rails application and the API with that and I'm I'm running that on the Raspberry Pi which is on the whole network and because I can't act actually push up on like a heroic room AWS or something because I need I need to to actually be running on the whole network because a lot of a lot of the object some smart smart objects so like a so those are like a life x light ball and those are already connected to your home networks in order to use the API is you need to be on the whole network as well I'm right now I'm kind of I'm certain that the Web with any rockets kind of a really easy tunneling toolkit but you're and development environment on pop up on the web and this is kind of the testing of this Internet of Things applications on and then the other 1 the rails that then connects both at smart objects on as well as dialogic so smart objects are the ones that are already and connected to the internet so these are the ones that you're probably gonna play a huge premium for a right now so like a light bulb like a regular light but it's like a dollar so it and then the connected light bulb is a 100 dollars so the new 100 times the premium for it to be connected to the Internet so right now it's uh the real that actually connects to and the light that light bulb and so no switchable smart and SunOS actually works off of with Dropbox on actually sending it files and from Dropbox on the cloud for portability so does not depend on on the files to be on my local machine and then I'll also gonna a number of dumb objects as well as well so that the sunken in out the so so uh my coffee maker is a 10 dollar coffee maker and a cutback that connected to the internet and unable to turn it on and off with my application as well but and as well as on the motion detectors all that's actually like a 5 dollar motion detectors it's really really cheap but I do that all not we know I'm kind of splicing but they're circuits to be able to kind of send send signals on when i wanna turn the power on and turn the power power off and the cool thing is because the front and kind of lives in the cloud I can actually and I guess you control the stuff anywhere in uh from from anywhere sigh can be at the offices but uh and the turn on and turn off my lights just you know make sure things are often similar appliances sorry connect a out of the slow cooker to this as well so that now I can I'm actually start turning on my slow cooker just and so that's my fool be ready by the time the home but so what is the Internet of
Things but it's literally some object-oriented programming and you're connecting to physical objects but through code and using the things really pop up everywhere right now and health and fitness monitors home security devices connected cars household appliances on a ton of other applications out there and but is also a lot of non-cancer record a consumer applications as well so but we see the Internet of Things and for example local governments starting use licenses to build a look at the infrastructure and we'll see if there's any kind of you know water gas leaks or whatever before that before the actual damage occurs so I'm really a lot of cool stuff happening in the space but so was
important and I think it's really 3 reasons the most important reason but is that it allows you to get a better more easily interact with the world around us so before the 2nd nest thermometer for example right before we when we had to go on to the wall you know and turn it up and down or turn off a remembered Chernoff only walk out the door and we can now use an app to control the temperature and then this and then over time and it starts to of learning a routines and being able to better and better meet their needs and and so so we can can more easily interact with it and the 2nd reason why I think it's all-important is an iterative really really big and we've seen a huge increase explosion over the past 5 years or so but in the in the Internet of Things space and I would think and a lot of these connected devices pop up all over the place a lot of companies are starting to get into space Biggs 1 start ups and everything but I think it's gonna get even bigger and this'll than a lot of research research reports on that say that but by 2020 there's going to be and it's all research reports into psych 20 20 is kind of the the the angle of the big more were organs see a lot of change but but 20 20 when you see 40 to 80 billion and connected objects and that's 10 connected objects for the for every human on the planet and at that time and I just read a report that came out today saying that the that the health care and in 2020 the health care of Internet of Things market will be a a uh it's good 117 billion dollar market so a lot of big numbers in this space I think that the most important reason why you things is really so important and is because it really increases the amount of data and that we have the out there so typically big data we can think of that is that all the data that's kind of on the web on 1 all users were getting this from applications but more more Big Data is going to comprise the things that that actually occur in the physical world actual and the of physical interactions we have a in the real world so everything from like a like ball onto a thermostat to wearable devices and they're really the they're going become sources of data that they were there we can use and and analyzes and hopefully a major life can even better with and this is kind of the the notion of quantified self and where these technologies really help us to better understand how analytically look at our daily routines in our lives in general but but it's not as
quantifying ourselves but so far that I read about this just recently about this does start up that started but they have been built the sensors for cowls and use the sensors on a cow and the former is able to tell a when they're will to kind of get all the data on the couch when the cows eating sleeping and when the cows pregnant when it's sick and a cow generates 200 megabytes of data per year and so if an animal that sleeps 12 and a half hours a day and each for another 10 hours a day it generates that much data imagine how much data a human can generate or and or even something like a clock but I think that it is a scary so much data out there and so as as kind of
building and as you think about what is going to talk about today and in terms of the internet of things in this application as building what exactly sure but was not talk about initially so I started building and then estimate some issues arose and that's kind of what help to drive and the topics that there was talk about but so initially with this application I start off with a regular can HTTP API and so running into some issues there so if you look at them with sickle like for example right or Rails application when when when we wanna turn on the light we have to connect to the light and then we have the turn it on when we want a change of change something about the lights who wanted the brightness or if we want change the color of the light each time we have to connect to the light on and then we have the turn down the brightness or we have to you can change the color of the brightness and a new kind of RGB values the light but then again when would turn off again were connecting to the light and then where returning the light off it now so were having to connect onto this a lot of times it's it's obviously not drive but it's not just the stylistic issue but it also comes but become the performance issues well when dealing with some of these on the Internet of Things objects so if you think about it and I showed you the video of a slider rate change the brightness of the light on this like a regular form and there's it's kind of got different values along each of the body to add that slider has 100 values of its is 0 to 100 and so the user can it takes that slider and as moves up and down and in 1 2nd to generate 200 requests onto the server and hence the light gray and so imagine that as 1 user if if use start building some kind app with a lot of different users on the something but as I see a lot of slow down the light would take 5 minutes to go through the brightness cycle or sometimes you just crashed into something you just would just wouldn't do it had and so as so that's why I can assert looking for potential alternative on the solution found that was WebSockets and and that's actually a lot more relevant now I'm especially and after DHH is talk on Tuesday around the action cable so precisely what's coming out of that but of the critical thing about WebSockets is that they allow you to hold the connection opened on between the client and the server and and so you can maintain uh this connection between between requests on and you can maintain state and then you can decide benefit I got back she ended up using indeed in quite a lot was that the service and events and that you're not tied to kind of the response of the requested response cycle and you you can actually generate a that's the kind of popular something in the front end up as well to the kind and
so the anatomy of the rail that had built up quickly go over this and kind of get a little bit more detail but basically you get requests uh to to interface with an object and again pretty much as with the with a front end and that kind of goes to the event map and which is just like a rails throughout the ashes mapping events and that then goes the WebSocket controllers and and then the controllers do 2 things and they work with your models to can save that and that interactions the database on because I want to build analyze and everything from the other motions the when lights are on and off and and potentially gets more advanced of later on but it also kind of interfaces with the off with a physical object itself that
and so not a drain the slides and go through each of the 2 steps as talked about but the justices an angular and where rails Conf right now basically what I'm doing is I'm creating a dispatcher on the front end and and I'm using this using the will of the WebSocket rails and using the Web realization on on the on the back and they have a a and as a client side libraries while enforcing the client-side library is a bundling with the gen and also it's in coffee script and I I I prefer JavaScript copy script and and I'm going to pull out the the decline part of that and into the into the angular out so what I did was I just unbundled that a guide action a link on the slide you guys are interested and there is some interest on StackOverflow or on the cell up with them using this dispatcher that created and the dispatcher created uh triggers events but that then maps
you and your event map on the rails side so this is the way the request 1st comes into the rails and application and as you can see that it maps to and you controllers an action action is just like you would have a regular HTTP in in your other but the syntax is very familiar you can use on the string or the hash syntax here and and i'd in general here tried to be and this is going to an example of the light and the coffee maker but I tried to be as you know RESTful as possible so that the create action turning it off turning the object on and destroys turning it off update is changing some attributes about that like and shows kind of returning some status that we have on the on on the in on the object and in the case of the light and it's the color it's that whether it's on and off and it's the brightness values but then just as no like some of the code that I'm gonna go through and it's uh paraphrase little for simplicity the full source code is on get github so I'm not handling of available for that
so then you have the next up from there is the idea the controllers the really true portant things to note in the controller the WebSocket controllers allow you create connection that stays open and again rather than working from onerous request-response cycle like HTTP and and the cool thing about these WebSocket controllers is that you have this controller store available and that lets us carry over and the connection to the physical the physical interface across your controller methods so rotten again having to connect to the light every single time with the but like X interface that new so we can just call it the 1st time that control is it and then hold that connection and and then use a connection over and over and over again in a dollar a method so if you look at like for example the create method right where you were referring to that like a like interface and in the controller store and and the whole thing but controlled stores well is that that works when it's and the when the controllers 1st and it's and it's initialized so that any time whether at 1 user no another using the that connects to at your so using that same connections you not having to reconnect over and over and over to the to the to the to the light bulb of and so every control action really does 2 things and it's again like I mentioned it saves that interaction to the database and it actually but it interfaces with the object of this is going to be
a little more detail magnet talk through this but just the update action that had and taking a parameters which is message on here from the front end and then up here it's the RGB values that that 1 or the other brightness value that I want and then up again during the same 2 things I'm sitting into the database and interfacing with the object of a domain model the
answer is really really simple common in this application and basically I've got a so player I've got a of a party I've got a motion detector which has many motion detection and guy coffee maker of the light and a light has many colors in a car and and the light also has many brightnesses and the only thing here is that again really really simple I just over in the destroy method because in our case and with the internet of things destroyed at least the way I've got it set up is actually turning the object off and so actually save a reference to 1 that object was turned off so then the interface
and this is kind of a this is kind the most interesting in the most fun part to build on in this application if kisses classes that build a kind of the and the glue between the rails AP and and the actual physical objects and the interface classes a really easy to build in the case of smart objects like here so player or your light bulb and because there's a lot of API is engines in official or unofficial ones available out there and where it's a little bit more I get so the trick here but also all of the more fun is where you have lot a dumb objects which are not connected to the Internet where you happen connect to all of you get used to the hard we knows library and then do a little bit of circuitry but it actually really really easy and not very big circuits guide also unaffected figure out it and I'm so this is my motion detector but up on the slide right now but the th TSA I came down from New York USA really wasn't happy about this and somehow I agree with them it looks pretty sketchy but somehow it survived all of their while being in testing but then here right now but and I think it's a it's it's it's interesting but the motion sector was kind of 1 of the more more interesting interfaces the build because unlike all the other objects which an on off right where you turning the light on turning off the coffee maker turning on turn off right the motion vector want to turn on it's actually and it actually is such as kind of a single point in time in Section on for a little while GNG starting get motion detections that coming from this the motion detector and also requires a two-way communication between the object and and the rails out so it's not just the real that sending a signal and the OIC turn on when this motion and in the section said that back to the rules that we need to be able to deal with that with that as well
and so this is enabled through arcanum multithreading and service and events and this is another code is tiny I'm going to jump into more detail and all of all of this but basically and the main method that have here that's the stop motion detector method but it does for things that start a new thread it connects to the yard we know it detects and reacts emotion and then it detects and reacts to no motion so the 1st part of
that and is where we are and where we set up a new thread so why we need to do this again the the the the motion detector is continuously and continuously running it's almost kind of like a loop as if you think about you know when you do never put like a break or something listed looping and frees up your app so the same thing happens there it continues to looking on the odd odd an input for for for motion and if we don't get off the main thread it actually ends up freezing up on the application and since that's where the applications kind of running so we 1st thing we do is we got the main thread by creating a new thread and and then we start listing from the odd we know in the input port that we specify and the
next 1 method is that is pretty cool and this is where we react emotion and a lack of motion and so when motion is sense on on the on the ordering of in that we saw specifies input and basically what happens here is when this emotion and that the motion detector detects a case and the little impulse to the to to that in the input pin and therefore it we we send them back to the rails that out so what we do is we can say that motion to the database once again keeping track of all the motions that have that have occurred around and then we can we said the server generated event and to alert the front end of that of of the alert alert the client of of the of the of the fact that there's been motion and that's kind of white how you start seeing on the graph using the graph turn red when this motion and then turn that turned blue again when there's no motion and it's because it's reacting to these service and events and that that they're they're happening and and then similarly when there's no motion were sending them just a signal to the front end to say and there's this there's no more motion and so here turned blue again and and then the right to we we also send a kind of account of the the latest count of motions to update the graph dynamically
so and the future of the Internet of Things and so in 1997 had Alan Kay the pager behind object-oriented programming in the graphical user interface and said that day after 50 years of development the computers still masquerading as better paper but in the next decade of will be the next decade will be the transition into what computing in networks of a really about and we really that kind of and come come to life and come about as a firmly
believe that's kind of what we're seeing in the Internet of Things space as well and the play of Alan Kay's words right now the Internet of Things is really a masquerading as a better light bulb or better thermostat and you get the point at the and we're kind of in this like cool factor phase where it's really cool to build turn on an object of return often object with your with your app around the world is kind of really captivated by this so far unsophisticated implementation of of this technology but if you think about it we've gone from a light bulb on earth SoraLex switch on on on a wall we flip on and off when you walk into a room and to act but then when you have to walk into a dark room you realize that you know have blood you fall and hit your password and open the at the turn it on and that's a big if you have multiple different brands of light bulbs and you have to open the app for each 1 right that's that's annoying and it's it's not actually very functional so we've gone back to having the lights which is on the wall but the lights which is now connected to the Y from the Internet of Things light switches so cool cool stuff but you know we haven't really seen that much incremental value being delivered in the space yet and I think we'll see a lot more of it in the next 5 years so so so where I
think the Internet of Things is going and I think but right now on the stage in between where we have these disconnected dumb objects all over the place up to now starting to connect a lot of these objects worst Stasi connected everything out and but I think that's the kind of still working in silos again you have different apps for different different brands and you know even if it's within the same company there might be different the different apps to to to work with these things I think the next up from there's centralizing but a lot of a lot of the object so having 1 platform wreaking being b of the control your different objects of all in 1 place we start to see a little bit of that as well but apples home care was to do a little bit of that Amazon echo and they just announced they're gonna have a integration of stuff you have another things objects in there but so that's kind of where I think the next step is but I think that the ultimate step in where we really 1 end up with you know Internet of things on his work were actually integrating all of these were 1 where all the smart objects are working with 1 another and does a matter what brand they are or of or you know what what what they should do that she working together and and in in in in the sky routines so the you know you can imagine an apple where you heard you can and that a situation where you're coming home late from work in your your your home almost no that's a source heating up the food right when you you know far you know close enough the lights turn on you walk in the doors unlocked and everything kind of works and works you know together and seamlessly and so my goal for today was really just to
show you the building Internet of Things at is really easy and you know this took me just you did take a very long at all to build a very simple but but especially the skills that we have and as Israel's developers and I think is going even easier now that you know announcement of action cable and it's going the kind of more integrated in rails and so I think that's going to be some kind of make it very easy for all of us too can start building and kind of prototyping these Internet of Things applications company also to see more of a rails developers have to be part of this you know things revolution and kind of push us towards Europe the Jetsons and as opposed to 4 and so on and so I hope that a lot of you know our body building and will build and and and in these applications has so
much further I heard I how it and
a kind of environment and and this is a time and