 Okay, we're going to get started. This talk is the Internet of Thingies. Our speaker is Ken Eschelby. He's with OpenNMS. And the talk is about how to do the Internet of Things for do-it-yourselfers and people that want to use open hardware designs and open source software. So without further ado, I give you Ken. Thank you. Before I start, by raising a hand, how many of you have tinkered with making hardware, little things, soldering, electronics, hobby kinds of things? So about half of you. Okay, so if this is too pedantic, hurry me along or something. For the rest of you, this might be a good introduction. It's meant to be basic enough for you to understand. For the end, it's going to get a little advanced because the software of the company that I work for, OpenNMS, is kind of an advanced monitoring software. So I'm not going to go into a lot of detail with that. So we'll get started. They always say start with a joke, and the joke is my clicker doesn't work. Sorry about the microphone. It's kind of hokey. So the joke about the IoT is that all these things are going to take us all over and we'll be their servants eventually. Maybe hopefully, maybe not hopefully, I don't know. So my interest in this is basically around my home, trying to do things more efficiently and learn about the environment around me and how I'm using energy and heat in any ways that I can do to control my energy use. So to me, that means collecting data and analyzing the data and decisions based on this data and using comparative data. So typically for our home systems, what you see are diagrams that look something like this maybe. There are a lot of varieties of models out there, but this is kind of what I'm talking about, sprinkling smart hardware with software on it that does various things like control systems and access systems, and there are tons of products out there for you to check out. This is another kind of model, a little more clear, but this is typical of what you see. I really like this one, but I have no idea what it says. Does anybody speak Russian or read Russian? Someday I'll Google translate it into a normal. And then this is where things can go. This is the fear in the machine overlord kind of thing where you're being blackmailed by your devices to turn up the heat or not watch what you do. Anyways, that's the end of my joke segment. If you stay at the western, there's a nice walk you can do. If you go just down the mall where the restaurants and shops are across the street and keep going to the city hall, there's a big rotundra, walk under it and out to the courtyard. And in the corner, each corner of the courtyard are these things and they have a little motion sensor and they make animal noises and other weird things. And I don't know why they would do that other than maybe keep people from sleeping there because I've run into people in sleeping bags out there at night. I have no idea. Go check it out. If you do keep going to the western, just go straight on through, cross the street, and you're into this little man-made creek and mosaic tile thing and it just takes you right to the west. It's a really nice walk. Keeps you away from the traffic. Okay, so these are the design goals that I was working with. They're a little vague purposefully because not all things fit and you have to pick the priorities of the components you want. I might use the hand. And that didn't help. So this is my beginning point. You need kind of a set of tools. You don't need this much, but you need some of these things because you're working with measuring voltage inducing voltage to work with the pieces. There's some circuit boards and things here. There's little jewelers, screwdriver kit, electrician scissors, soldering station, a variable power supply, and then like freakin' forever components and pieces and stuff and junk that you get from things around the house sometimes. My advice for things that you get is to... It's hard because unless you have hands on, you don't know if something works for you or not, but get things that are helpful and make things efficient so you're not fighting your equipment. So try to buy quality things like the soldering irons, like a, you know, I don't know, $50, $60 one. It's not a $15 one from Harbor Freight or something. Probably shouldn't say Harbor Freight. They're a customer. But, you know, the kind of discount tool places. So there's a variable power supply. That's really important because different components use different voltages and they can tolerate different amounts of amperage, so you have to be careful about these things or you let the magic smoke out of the electronics and that's not a good thing. I've done that maybe. There's kind of a simple list. Again, better quality makes working with this stuff more fun and easier. You're not fighting screwdrivers that strip or, you know, things like that. Power supply is not required, but it's very useful and be sure to light up your workspace and give yourself enough room to work. It's like simple things that make a huge difference and makes it more enjoyable to do this kind of thing because you end up spending a lot of time at this, so comfortable. What a picture of a breadboard with an Arduino and these are the various sensors. This is kind of a higher accuracy sensor if these are all temperature sensors. This is a waterproof one. This is one with humidity on it and then this is kind of a really cheap one. And so when you're looking at components of the pieces of what you want to build, whether you're measuring voltage or amperage or temperature or humidity or pressure or whatever, light, you have to find what's out there and what fits you, so you can see that these different components have different characteristics and some may work better or worse for your application. So what I found in my case was that this BMP180 seemed to be the most robust for me and it uses an ITUC protocol which makes it really easy to hook to the thing that's going to take the data in and work with it. This one is another one that I use because it's got humidity built into and that's useful to know around the house just for... I don't know, I have a basement and it's interesting to watch humidity in the basement and in the garage and outside and inside and see how they change and if you can affect it by insulating and different things like that. So Arduino is one way to go with this. Okay, raise a hand who knows what Arduino is or is it familiar I guess with it, so most of you. So that's the basics of Arduino. They're very cheap now. They have a lot of utility. They're easy to work with. They have their own environment to develop. They're easy to connect to and there are a lot of tutorials and examples out there so honestly this is a good starting point. Let's see. My notes do once in a while. This is the IDE. It gives you a serial console so you can watch debugging of what's actually going on and it has a variety of libraries to work with a different hardware to work with to have a web server built in and it's really easy to work with. It's probably the best if you're starting out. So for this project I have to communicate over IP so that's a component of my requirements and these are the possible characteristics and possibilities that I can work with Arduino. SNMP, which is a common networking protocol is very flaky on Arduino. It's not consistent and reliable so I kind of had to throw it out and use something else. The hardware can collect from a lot of different protocols and methodologies so I went with something else but this is kind of I'm kind of showing you the approach so these are the things that you look at you match it with your hardware and your software available and the whole system and you decide whether or not it works well or not for you. So next I look at this little thing. It's an ESP8266 it's very simple. It takes digital and analog inputs. This one happens to be 3.3 volt and see it's a model, it's a generation I guess, ESP01. It's the first iteration of this board. The cool thing about it is it's got built-in Wi-Fi so you can connect it to your AP and it becomes a client. It has a built-in TCP-IP library. It has a built-in web server so it's miraculous. It's a magical little box and I'd say the price was about five bucks for that one. So here's the prototype using ESP8266. I just wanted to show this note because all these details matter. So the thing itself operates at 3.3 volts. You got to make sure you deliver 3.3 volts to it or you cook it and release the smoke and then it doesn't work anymore. So to do that, you usually have to take some other voltage and drop it down to 3.3 volts so that's what this thing is, is a voltage regulator. So typically you get like a wall wart that outputs 5 volts or 6 volts or 9 volts or 12 volts and the regulator's like a buck. But if you don't get the heat sink for it and you're feeding it 12 volts you'll burn up the regulator. So on and on and on this goes, right? Every step of the way you have to be careful about everything you do and you learn. And luckily it's cheap to learn. And so after you do all the things correctly, put your code in this is the kind of result. So I just built a simple web server that gives me a page where I can select it with network management software. So this is a very, very basic model for this approach. So then, you know, well that's not good enough. I want something better in different ways. So I try to go about it again, make a new iteration of it. One thing about this is that you can't just plug batteries in and let it sit somewhere and run. That's kind of my dream is to have it rely on house power to make it operate. That lets me put it in places that you otherwise couldn't put it. Thank you. And it lets you be more flexible in where you collect and how long you collect. So the previous design didn't fit that. So I had to try over and over and get better at this. The other problem is that that 01 model has a really weird pin setup. Maybe here, you can see there's 8 pins and they have to bridge this gap in the prototype breadboard. Well, actually there's the better one. So I bought an adapter that those pins plug into and they come out and they spread and can bridge the boardgap. But they don't fit. So the pins down here don't fit the square. They're different types of pins. So it's loose. It just comes out. So I take a battery clamp and clamp it to it. And that works for a few days until you get annoyed with it. So then you can, somebody did this you can heat up a pin and then pull it up and then solder kind of an L shaped right angle set of pins to it and now you can bridge this gap. It's a really hokey fix but it works well and it seems to be reliable. But, you know, that's kind of silly, right? You have to do this for everyone and it's just not clean efficient approach to it. So the other thing about the first way that I was doing it is you have many components. So I showed you the voltage regulator. Well, I got one off eBay that's kind of an all in one. It's got a built-in kind of heat sink and way to deliver clean power. It's not as physical mechanical. It's got some marks to it. So it's a better tool to use. However, it's not reliable. I've killed two of these things. Likewise, you have to have a switch to do the programming of the ESP 86266. It's within Arduino but that's not really involved in this. I'm just sorry, bad manufacturing. eBay, Chinese special kind of a thing. And honestly, that's really a good way to go if you don't know what you're getting into because you can buy a 5-pack for $10 or $5 or something and you've got 5 to kill in, you know, new and creative ways each time. So, right? It's honestly buying many of things at the start or a couple at least, right? Figure you're going to destroy one and you might get one to work and then determine if it's flaky or not or maybe it's your approach or something but you run into a lot of bad hardware in this so that's just kind of how things work. That's life. So I found I've been aware of this one but I found, I guess it's a generation but they don't do an incremental thing but anyways, Adafruit which is a popular Arduino retailer. They sell a board that's based on the 12 the ESP12 model of this chip and it has the voltage regulator and the programming button, reset buttons and a whole load of inputs and outputs on the side available. It's got pins for connecting USB. So that's the BMP-180 temperature and pressure sensor. It's a lot more simpler than multiple components physical components and I found that these are incredibly reliable. I haven't had one die since the summer and we had a hot summer in Oregon so it's been a good box. It survived freezing and December was the second wettest month for Oregon in Portland forever so it's had a harsh environment so far and I haven't had to go out and reset it or do anything. So it's been really good. You have a lot of options with it. It's $10. Like I say, I haven't killed one yet and I have like six of them running I think so it's been a really good board for me. So software side, how do these things work? We know IDE with the DSP8266 but you can also flash it to something else, anything you want. You can build your own firmware and your own development and your own code and language to use with it. By default it comes with Lua programming language so it's got a firmware that includes the IP smarts and the web interface and Lua is the language you use to but I'm just showing you the NodeMCU is kind of the ring leader for these. It's a popular one and this is just a flashing utility and this is the way you load different firmware and make use of different ways of programming these things. So the Lua language here's your Wikipedia for it. It's a popular language, it's widely used with different applications. There are some of the applications and not even close to maybe that's 10% or 25% of what's on Wikipedia but you can see it's pretty widespread use. I do this because there's games and that's probably 5 or 10% of the list that I saw but popular games use it to make mods or to be their front end It's an interesting language it's used in the systems management and networking world for various things. You can see previous slides. Just go A to A devices use it so Kalki if you've ever used that on a Linux desktop it's widely used. So it's kind of a nice language to use because a lot of people use it and there's a lot of knowledge out there for it. So this is for example a this is a temperature sensor, that's the temperature and humidity one. It's a library for it and that's the file and you get it and you use this little IDE environment called ESplorer for ESP8266 you load the DHT that Lua file and here's kind of the loading or the console screen for it and you upload it and I'll show it there well anyways this is removing but anyways you load it and it will show on one of these slides that the file is here and loaded and there's your library and then you load basically your program and you execute it and then when you it's just running constantly so it's kind of a loop thing and based on whatever you've told it to do it will constantly do that it can do things like you can set it to a deep sleep mode and wake it up every so many minutes and have it send something or you can leave it on like I had for this one as a web server and it's just waiting for somebody to query it and get values from it you can do whatever you want so sky's the limit so this is the uploading of that file and then I learned how to do highlighting in whatever screen capture I was using and you can see the file there so right now we're getting advanced in my presentation but it shows the file the size of it how much space you've got left and here's the code of that library and now so because these devices have limited flash memory on it there's a nice thing you can do that lets you compile that Lua file you uploaded into kind of a binary if it strips out a lot of comments and things like that so you can shrink it by what a quarter or a third of what the original size was so it's kind of nice for saving space on it and then you load what they call the init file the init file is basically your program so to go through this all I've done is set a static IP all the examples you'll find on the internet are for DHCP and that didn't fit my model with multiple devices and having to monitor because I had to go and you have to identify a device and say this is the outside sensor right and if it's changing IPs or contesting with other things you can't tell which one you're collecting so I needed to set the IP address so I've set that up this is my SSD SSID and my password for my AP I've basically defined some pins and some variables and then I kind of do a run-through of the device itself which is basically initializing it getting some values doing some calculations of those values and then clearing out memory doing garbage collection temperature and humidity and set up the web page basically and somewhere pass it temperature and humidity values and then it basically loops so it's doing this every I can't see that number I can't see it on mine either but it does it every 30 seconds or something like that so again this is a very simple model you can kind of see how you have some variability and depending on what your use case is for this you can set it however you like so that's the hardware part do you guys have any questions about hardware related and getting ahead so I gave it I think the one I ended up with needed 4.5 or 5 volts there was some number up in there where I ended up using 4 AA rechargeables those didn't quite last 24 hours set up as a web server so what you really want to do for this is do this deep sleep and do a push collection I wanted to keep the kind of presentation simple so I wanted to present this but that's going to be the next iteration is developing a push model that's collectible and then presenting that as like the low power usage because I've run into people at maker fairs and things like that and one guy is getting I think a year and a half on a pair of AA's kind of thing so this is that's the kind of place you can go it makes a lot more sense at that kind of level than changing batteries out or having a big battery for it any other questions okay so this part is the data collection side and because I work for this company and use it and I'm a consultant for companies using this I'm not going to I'm going to breeze through it suffice it to know that there's a product in the world called openNMS there's a couple of different versions of it this is kind of a long term support version this is like a rapid development version it's kind of the red hat model that we use this would be for a production environment and this would be for a test lab environment some people use this in production our software is completely free and open source and it's an enterprise scale network and systems monitoring management platform that's about as fast as you'll ever hear that description so the configuration of it I'm putting this here to just kind of document it you don't really need to know these details but we basically configure openNMS behind the scenes in XML there's various front ends and ways that you can get data in but somehow you have to get your sensors and collect values from it so that's what provisioning is it's a way to do that and it can be a very complicated process so imagine if you have run say you're going to build these little devices and deploy them throughout the world in all of your data centers and all of your we have Papa John's Pizza as a customer so they have 2,000 or 2,200 stores they need temperature sensors for all those there has to be a lot of numbers so you have to have kind of a sensible way of getting lots of devices into our tool so provisioning is the way you do that so we've got the nodes into the system now we have to configure data collection and so what I've done is created a service which could be HTTP or ICMP or SMTP any kind of protocol and I've just made one called DHT22 which is such a type of sensor and it's got its own set of parameters so I've created in the daemon config a service that's called the sensor and then I've defined a data collection based on HTTP for it so ignore this it's just the performance data store stuff but I basically made a rgx that looks for temperature, humidity takes out the numbers for them and then alias is one which is in these parentheses and the second one which is in these parentheses and match it to sensor temp and sensor humidity values now I've got values associated with these variables and I can go reference them on like displaying graphs and things like that so that's what I did so I made a graph definition and there's the graphs for one sensor for temperature humidity over approximately a week so you can I think that's kind of cool honestly because you get a real sense of what temperature and humidity in this case does outside I think this is an outside graph likewise, openNMS has other ways of displaying your data including that plug-in for Grafana now you can kind of the modern sort of graph display of it and in this one I just I took multiple sensors and on the same graph this is I think the kitchen sensor outside sensor and the basement sensor and they all had at the time temperature and humidity and you can see what your outside humidity does in relation to your inside humidity to me that's interesting likewise you can build little displays that you can set thresholds and change the color of the number based upon the values so if it gets cold turn the number blue it's cold outside or something that's kind of a silly example but what this gives you is a way to display your data in a sort of immediate and impacting way so that you can see interesting things you can see that for this as the temperature dropped I think this is over a 24 hour period as the temperature dropped the humidity came up and in Oregon this was kind of late summer so that's kind of a normal thing. It cools off in the night gets a little more humid as a result and then when the sun comes up the humidity falls off and it gets drier outside you can see all that displayed visually there's another display using Grafana which is just the BMP 180 also lets you record pressure so here's a graph of pressure and then here's each individual sensor with this one happens to have pressure but I don't know why this one doesn't have anything but it might have humidity or pressure and then this one shows temperature and pressure together on the graph for these two sensors so you just have flexibility in what you want to do so expand that out to showing when lights are on and off what amperage are going across circuits light levels in your house like doors opening and closing this is the kind of thing that I'm kind of working toward in this presentation so I'll get there at some point so again I talked about some of this but these are some of the lessons I've learned the world is a mean and spiteful place and you'll pay and honestly what's not bad about this is you'll pay in a kind of a cheap way it's not hugely possible to pay for tinkering with this and this never used to be the case like those little ESP boards something like that used to cost $60 like a year ago and now they're $5 and $10 so this is the direction the hobbyist kind of electronics are going and it makes this fun and accessible for a lot of people so I kind of encourage you guys to go out and check it out if you've got interest in it again buy extra things one order is a lot less stressful than two orders or four orders or something so maybe double whatever you think you'll need or do something reasonable to cover losses due to various reasons and then finally some of my to-do's this push collection is a big one and actually this presentation I gave this in Germany and it got one of our developers to think about push collections and say hey we need a streaming engine to receive push data to our software so I think it's a good model for saving a lot of energy and working making these a lot more attractive ways to roll your own kind of internet of things device so you need all these pieces in place that I just took you through to make all this happen so now look at your piece and make it better and better so that's kind of how we do it so that's it there's my contact info are there any questions or comments on this yeah so the question was have I looked at Google's effort and I've only looked at openhab in terms of a central hub I'm assuming it's like a hub based and you connect various things like an S thermostat or other things to it yeah so it's kind of a matter of what you want to do are you controlling things are you just giving information are you like that kind of a thing so I haven't dived too deep into that yet I'm going to start with openhab because it's an open source project that's built very similarly architecturally to open NMS so I'm comfortable with the Java architecture and the way that it structures things so that's probably where I'll start but I'm going to look at as much as I can because I will tinker endlessly with this the Ness thermostat okay I'll slowly do this throughout the year when I get time to it'll get there I've got a developer key for it so I've got it hooked to openhab right now I haven't done much with it so now that I have some accessibility to the thermostat I can now use that key with other frameworks and work with those so yeah it does take a while build an openhab on a Raspberry Pi it gets all that set up and then start talking to it and figuring things out all of a sudden three weeks have gone by kind of a thing as time allows yeah totally I'm going to check out as much as I can any other questions there are tons as I've found out there's an ESP8266 form that is heavily used these are very popular little Wi-Fi things so for that thing as the entry to a center data or things like I've been installing a lot of LED strip lighting in my house in the basement I went from four foot fluorescent tube fixtures to all strips and I think my power dropped from the drop in power usage of those went from like 300 almost 400 watts to like 140 watts but with the switch and that's the difference in power now add to that things like a motion sensor it detects you walking into the basement and then turning it off and then a sensor doesn't detect movement the savings in energy there things like on the front porch I have LED strips that are well they're red green blue so I can make red and green ones for Christmas and yellow and purple for Easter that but also dust to dawn a light sensor to detect dust and to dawn turn them off and on based upon the light and then when somebody walks up a motion sensor that makes them brighter when they sensor you there all these iterations help with that this is a very long-term process each component that you work with I don't think I answered your question so the resources are online there's a lot of Arduino forums, what's the best one you kind of define which one do you like by the quality of the questions and the quality of the answers and how much activity it's just like GitHub or Sourceboards was where should I use this open source software well it hasn't been developed for a year and a half so any others it's on the we're an open source community and project so they could work with our developers to do that our models are kind of community-contributed for in-house we usually work with large companies that may have in-house development staff so the need has to drive the people's time as valuable so our developers really only write things that are funded we don't write a lot of code for free we tend to write features that our customers want and have paid for yeah like the model I was going to do is stuff the values separately like an XML file as the first iteration not have a new daemon or anything but just come up with a way to separate out which value belongs to which device and at what time and then pop it into a metric database based upon the time so that you can get normal looking graphs out of it so yeah I haven't gotten to putting that all in place but I've started on that but the bigger thing is a true streaming daemon that's one of this in line with all the rest of our type of daemons and makes the real thing and that we can speak MPPT protocol and all the other kind of bio key kinds of things this right now this one that I'm showing you was just on a I just have a no server and it's just in rd files we have measurement api that lets you just select any kind of data store we have two, we can use rd with our natively out of the box we can use rd natively or we can use what a segue we can use nudes which is it's basically a data model for Cassandra node collection so highly highly available a large of it Cassandra ring is possible and you collect millions of things per second kind of with big big big Cassandra node is a separate server so whatever you give it it's very hungry thank you I think we're good anything else anybody else thanks for coming I hope you have a good show come by our booth 304