 Hello, everyone. Can you hear me okay? This is beyond the blink add Drupal to your IOT Playground if you're here for something like super serious and you want to have your brain melted You're in the wrong place. We're gonna have some fun today. Do something a little different I know you're all doing very serious things and you're you know very serious things But we're not gonna do very serious things in here today So we're gonna have some fun with LEDs and blinking lights and we're gonna add the internet in there, too And we'll throw on some Drupal at the end. Okay, so my name is Amber Matz and You can find me on Drupal.org at Amber Himes Mat You can find me on Twitter, especially if you're nice at Amber Himes Matz And I am a production manager and trainer for DrupalizeMe and So I make a lot of training videos. I do a lot of Drupal and sometimes You just don't want to do some Drupal and you want to play with something new so I just last Last fall I started playing with Arduino. I went to a seminar at my library getting started with Arduino I had a little starter kit and I was taking a I'm sorry, but there's tapping happening the audio and I got the Arduino ID loaded on my computer And I started making a light blink and I was hooked so When you can start to make lights blink, I don't know It's just something There's some kind of chemical in your brain that's released and you're like this is amazing I have this power now over lights and it just you know balloons from there So today's takeaways you're gonna learn of a little bit about microcontrollers And if you don't know what that is just hold on a minute. What is the internet of things internet of things? Internet of things everyone's talking about it. What is it? So buzzwordy? What's going on there and We're gonna talk about how can a thing connect to the internet and why would you want to do that and how can machines and Devices talk to each other over the internet what Drupal has now for IOT applications and what I'm hoping Can be developed in the future What I think Drupal needs to better serve IOT applications and I want to Preface all of this by saying that when I'm saying IOT and this my perspective here is very personal This is my personal journey of learning this and and this is a very like Makers maker hacker kind of thing. This is not like these are prototypes people This is not like ready-for-market. This is not and I you know, I'm building an iPhone here or anything like that So this is very DIY oriented and I'm also not talking about getting your content into like You know Amazon or Alexa or you know any of the fancy stuff like that So I'm not talking about that. I'm talking about things hardware things and how we can add internet to it and how you can Trigger actions over the internet make lights blink over the internet and you can get that data into Drupal So what is IOT IOT is the internet of things you take a thing you add? Computational intelligence to it you connect it to the internet Profit maybe you probably lose a few backs along the way, but maybe eventually I suppose And it all begins with a blink. So how do you get started with internet of things? Well first you need to know a little something about microcontrollers and a great place to start is with the Arduino Uno Which is a very easy to use board I have here a No offense intended Chinese knockoff of an Arduino Uno that I got for cheap at my local surplus store And so I'm going to show you what this looks like So if I this is an Arduino Uno, and if I add power to this through the USB I have a little LED that's wired up here and I've got a resistor Going through So that the light doesn't explode or anything like that and this is called this thing right here. It's called a breadboard It's got metal strips along each row So each of the rows are connected and then along the side here on both sides They're connected along the column so you can use these little wires here These are called jumper wires and you can connect to power and ground So I have an LED LED plugged in here And it's got two pins along and a short one and the long one It's called an anode and the short one is called a cathode the long ones Plugged in here. We've got a jumper in that same row, and it's going to digital pin 13 So the Arduino here has got a row of digital pins along here and And then it's got some analog inputs here We're gonna talk about analog inputs in a second and then with my little jumpers I've got it connected to ground on the Arduino and then five volts of power So an Arduino has five volts of power and the resistor Compresses that down so that because that's just way too much for for a little LED and this is also a power outlet I could have plugged this into like a nine-volt battery with a little cap on the end and I could be powering this with battery But it also will use the USB power. So it all started with this circuit and and then next So through that exercise I learned about the Arduino uno what like a very Basic introduction to what a microcontroller is what a breadboard is. I'd never used that before What an LED a resistor some of these electronic terms that I had never heard before I have no electronics background I had this like vague awareness of these terms, but these were all new to me and You know these different kinds of tools that I can use for prototyping like these jumper wires and I learned how to load a sketch Connect the Arduino to the USB and load a program onto it and this just runs continuously So it's not like a web page where you're changing something and saving and hitting refresh It's you're changing something. You're loading it onto the Arduino and then it runs in a loop So it's great for automated processes, right? Automated systems that are keeping an eye on something and then when a certain value hits, you know a sensor is detecting something then Then something you can make something happen So and this USB cable is you probably recognize from like a printer type cable So that's all it is you want to make sure one of the first mistakes I made was in this library seminar that I went to I had just a regular charging cable and And we're like we just couldn't figure out why the Arduino ID wouldn't detect it It was because we had the wrong cable. So you need a nice good solid printer cable if you want to do this, right? So the second thing I learned was about the analog inputs and a thing called a potentiometer What's that? Well, so a digital input is on or off right one or zero an analog input can have basically An infinite number of inputs and you can set a range and so you can Like think of a dial for example is a good example. So I Learned about potentiometers and I got one of those wired up So let's take a look at that Just move this over here I'm breaking all the demo rules today. I'm gonna do live demos with electronics using the internet so so there Okay, so what we have here is Another little circuit. It's very basic circuit. This is circuit number two. Am I getting started booklet, right? So And we've got same thing LED is blinking, right? But oh, what's this over here? This is called a potentiometer and it's a little dial and I'm going to turn the dial and I turn a little more there we go now the lights blinking faster So I can control and now it's blinking so fast it's dim It's hard to see on the video But so I can turn the dial and it changes the rate of the blinking. So hey, that's pretty cool So now I know about a little bit about microcontrollers and I know about this thing called a potentiometer And now I can understand this tutorial that says, oh, did you know that you can sew microcontrollers on to? fabric and you can use conductive thread and And there's these these other kinds of microcontrollers that you can use that Are Arduino compatible so I can use this Arduino IDE that I I really like And I can add a board to it and I learned about these things called digital inputs and oh I I can read these Little neopixel pads and I can kind of understand what's going on and I understand about power and ground and ins and outs And so I can sew this hoodie and I can I can put this hoodie on and I can have this this is a soft potential. It's a textile potentiometer and It's not a dial, but it's doing the same thing. It's measuring the length here And so I'm starting in my range is like RGB values, right? so we're gonna start with blue and it's a little glitchy because I sewed it and And Then we can just go and then here we go. Here's red. So who went from red the whole spectrum So I'll put that under the video too so that folks at home can see it But just by learning these concepts. I'm just building on my knowledge and able to do other things So I'll just show this for the sake of the folks at home. Here's the Gemma microcontroller and This is just a very it's it's the little sister of this this one this is a flora and This is a much more This is more akin to the Arduino Uno in terms of power and things like that and what it can do But this is the little the little one and this is a Gemma And so I've just sewn the circuits and then we've got the Neopixels here that are chained together These are actually individually addressable, but in my code. I'm just addressing them all at once So I still haven't got to the internet yet, but I'm learning lots of really cool things, right? So, um, sorry about the do we need to move this maybe? Try that Can you still hear me? Okay? Okay? Okay, and so So now I've learned about the You know some different analog inputs, and I've even made a wearable electronics project, which I think is pretty cool And so now I'm like, okay I'm getting the the hang of this thing what microcontrollers are let me tell you I've only scratched the surface because there are Hundreds of microcontrollers and they all do different things and they're different sizes and they they have different kinds of inputs And they're great for different kinds of projects So if you're making a robot, you might want to have one kind of microcontroller If you want to do a wearable project then you probably want to have something like you know like the There's no camera here but anyone has something like the flora here where you can You can sew and these pads have holes in them And it's you can get a needle and thread through there and use conductive thread and you can have a you know an electronics project, so it just depends on what you want to do and So Arduino what is Arduino like I've been hearing this about about this a lot And there's several different things that it is so it's this IDE this is this program that you can load code onto Boards it's these Arduino boards and like the Arduino compatible and Arduino compatible means you can use the Arduino IDE to load code onto your board. It's also a Bunch of libraries of code, so there's tons of Contributed code and also libraries that are part of the IDE that are embedded in there that you can make use of It's a community of people. There are tons of tutorials out there and Instructables and code and libraries that's been contributed back. It's open hardware and open source so this idea of open hardware these these makers of boards they are You know you go to add that to your cart You can look at the documentation for it and they'll have a schematic that you can download you can download that open that And CAD you can tweak it make your own board print out your own board. You know, this is open hardware So it's not free as in beer open hardware because there's a real cost to producing these boards But it is open and you can find the schematics for any of these boards online more or less and and you could you could make your own Great for automated systems Arduino because you've got two basic functions just to get started You've got a setup function that runs once and you would set like for the LED I would set the pin 13 which is what I've got it connected to you as an output So I would put that in my setup and then in my loop. I that's when I would say Okay digital pin 13 go high delay for a second then go low and that's what makes it blink And so the loop just keeps running and so that's what makes it great for automated systems The Arduino is also great for attaching sensors to it's very resilient. It's hard to fry an Arduino board So if you're new to electronics, it's very beginner friendly. That's why I ended up Connecting and I'll get to this in a minute But this 12-volt tower light to the Arduino instead of directly to the Raspberry Pi because the Raspberry Pi is a little more delicate It's 3.3 volts and if you mess it up somehow, then you've like toasted your little computer, you know and the Arduino is a lot cheaper and And it's harder to you can but it's harder to and It's also Very scalable. So this whole System it's very component oriented and and All of these things are very scalable You can start with any number of things and then you can add these things called shields. So here's an example of a shield a Glary shield So this one it it'll go on top of the Arduino Uno and it's an SD card shield So I can add let's say I'm doing a logging part like I've got my Arduino doing some logging And I need space to like keep my logs, you know, and so this is this is an example of that Here's another example. This is an XB. This is a radio So let's say I've got a cornfield and I want to monitor the soil moisture levels But I need to like transmit that data over radio to something else that's connected to the internet That's sending that data to the cloud or to my computer or something like that So if you need to like get data wirelessly Over a distance you still have line of sight Then radio is a good way to go or maybe you've got something in the attic and you just like it's monitoring I don't know smoke in the attic or something like that And you just like don't want to go up there all the time to like download the data So maybe just use a radio shield so that you don't have to so it's scalable in terms of shields and Attaching sensors and actuators so an actuator, you know, is like this potentiometer the dial All right So, oh, here's an example of the here's a screen of the Arduino IDE very simple interface, right? We're not talking PHP storm here people. So there's like two buttons that I push all the time Verify and upload and I don't even have to time press the verify button I just hit the upload and wait for the errors to come up and So you plug that that thing in you pick your board you pick your port and which is like your USB port and You know, you read the error messages or it's successful and that's it. That's all there's to it Now other kinds of microcontrollers that you might be hearing about a lot is the Raspberry Pi so The Raspberry Pi I've got one here, and I've got one here. Here we go and This is a single board Linux computer. It's got it's got lots of USB And it's got four USBs and Ethernet. It's got HDMI So I've got it connected right here to this is just a TV through an HDMI input and It's got a little audio thing. It's got other other things in here, too But it's also got this row of GPIO pens. So you can which is GPIO is like general purpose in out It's the same idea as the Arduino, you know, you can connect You know, you can make lights blink and you can run robots with the Raspberry Pi as well The nice thing about the Raspberry Pi in regards to the Internet of Things is that it's got onboard Wi-Fi, right? So it's a way Well, this this is a Raspberry Pi 2. It's really it's it's fairly trivial to get Wi-Fi going you get a US Wi-Fi USB dongle and you can get that running pretty quickly if you've got the right drivers you download drivers and Okay, maybe it's not trivial, but it's totally doable and then but the Raspberry Pi 3 which I have over here It has built-in Wi-Fi. So the very latest version does have that and it's makes it a lot easier to get connected It's just less less wires So I'll show a little Here's the close-up of that complete with glare. Oh boy Okay, sort of see that so, you know when you get one of these you instantly feel like a bonafide nerd And you're just like I'm legit now because I'm like looking at this You know microcontroller board and I know what the word microcontroller means now and you know this thing is running Linux You just feel pretty cool, you know it's it's pretty cool and actually the the interface for the operating system if there's a there's this is The operating system is loaded on a little micro SD card so you get the operating system on there and there's a version called noobs and it just gets you up and running with a graphical user interface and It's great. So The hardest thing about these things is like what to do with them like a lot of people have these things lying around They're like, okay, what do we do with this? So that's the hardest thing to get started. Maybe you'll get some ideas today Okay, let's continue So with the Raspberry Pi being so easily able to connect to the internet like okay Let's have some fun here and the first thing I needed to consider was okay. I want to make this tower light blink How how do I want to do that? Does my Raspberry Pi need to know like how does it need to get connected? Does do the they really need to know about each other like in what terms and so and I have a Jenkins build So what I have here is I Have a Drupal site Which is kind of constant just in consequential It's just that's just there and the Jenkins build is running cron on the Drupal site so that's the only Drupal is just there for fun and and then the Jenkins build is sending a curl command with a post an HTTP post with a JSON and it's saying I've started the job or the job is successful or it's failed and it's sending those values to an API a cloud-based API called Adafruit IO and this is great for you set up a feed and you can send your sensor data there or any kind of data You want like one value at a time? And so that's I've got this feed set up on Adafruit IO called build status So the started success or failed values are going to that API Now meanwhile, I have the Raspberry Pi and it is running a Python script that is using a Protocol called MQTT and it's keeping the connection open to Adafruit IO and it's listening for a started success or failed and When it sees one of those then when it started it'll the yellow light will turn on It would have been so great because it's running like every 30 minutes if I had touch this and it would have gone on right now That would have been pretty sweet But it didn't happen So the yellow light goes on when it starts and then the green light goes on when it's successful And if it fails the red light goes on so let's see if we can Get but the Jenkins what I'm the point I'm trying to make is the Jenkins build doesn't know anything about this thing It's it doesn't know its IP address. It's not directly connected. It's it doesn't it doesn't care about it These are decoupled systems. It's all connected through this feed of this API Okay, so Let's See if we can get it working So I've got a Jenkins build here, and I'm just gonna start it And you're all off the internet, right? You're not using the internet right now so did you know I Know you're on the internet because it's not working so So We'll see if it decides to work, but it's really it works great at home. I just wanted to tell you that and Yeah, so anyway, this is running every 30 minutes or so maybe in the middle of the presentation will start working again So we'll just see what happens there But this is gonna run and oh it failed everything failed. Okay. Let me try something really quick here Okay, let's try again. I'm gonna make sure that my script is running over here. I'm just gonna. Oh, yeah, it's going It's going Okay, and then I'm gonna run the build again Look if there's a yellow light. Yes, okay Okay, oh and it's successful You know this is I just want to thank my month. No, okay, so Great, so let's let's do the the failed. So let's make it fail. I'm gonna configure this and If I can use drop downs, okay And so I'm just gonna add a build step here and I'm just gonna put some gibberish in there and save This build is now officially Not gonna work and I'm gonna wait This this will go off in like 30 seconds. I'm just gonna give it a minute here Let's just see if it works. I think the wires the streams are gonna cross here a little bit because This isn't done yet This might take a second. So I'm gonna come back to oh, oh, there we go. It failed. Okay. It failed. Yay, okay The the point that I'm not making very well, but when you're on a reliable network These sending things to these feeds and using MQTT is actually pretty instant and when you're on a reliable network Even though these things aren't directly connected to one another you can use this API and it's near instant And that's what's cool about it and I'm not using HTTP polling or anything like that I'm using this protocol that I'm an explain later called MQTT and It's it's you can effectively use a third-party broker and send messages between devices without them knowing about each other and this is great because it there's also this like security thing that is There right like if you know if if you have a thing that's insecure But it's directly connected to something. That's like a critical system like your build then You know, you don't want to expose your critical system through an internet thing you know so don't have them talk to each other have them talk to a broker and Send past messages that way So now I'm just gonna Get this working again. I'm gonna go back into that build step that I added and delete that save it and Let's just Hey, it works again. Okay. Whoo. So um, so that's my first example of an internet thing using the Raspberry Pi and using Adafruit IO and it that was just I Can think that was The things that I learned there were I learned a little bit of Python I learned how to tin the ends of these wires because it was stranded wire man. I tell you Things I had to learn so I learned a solder for you all. I just want you to know that So oh I should show you this so I'll show you this this circuit here Okay, I'm gonna move this all over. I know this is a little dog and pony show-ish. I hope that's okay. Okay, so this This thing Okay, I know that's can you see that okay? That's okay, right? so This thing is connected via USB to the Raspberry Pi and There's in the Python script. It's actually calling like okay GPIO pin 3 5 and stuff, you know, it's actually calling the the Arduino pins So I've got some libraries installed that enables that to happen so that the Raspberry Pi can talk to the Arduino that's really great because This is a 12 volt device this this tower light and this Arduino is 5 volts and they needed a way to wire these up without fire and so There's there's a couple things these things right here. These are called MOSFETs and they They absorb the extra energy and then I've got some resistors in there, too So there's There is a way what I'm saying is like 12 volt to 5 volt, you know, there's a way to like Reconcile those differences so you don't have a fire or ruin your stuff So that's how that's all this work and the reason why I did it this way Was because when I tested the tower light I was more comfortable testing it on our on our Arduino Then I was on the Raspberry Pi the Raspberry Pi was like brand new to me And I was a lot more comfortable with the Arduino and then I didn't want to touch it I was like it's working. I don't want to like touch it And so I researched how to get the Raspberry Pi To control things on the Arduino. So thank you Raspberry Pi cookbook For that, okay, so let's move on So you want an internet thing Why why do you want this? You know like there's a lot of pain I just want you to know that there's some sadness involved with adding the internet to your things as you all know as web developers You know, there's a certain amount of frustration involved and it's like pure joy when it's like you're working in an embedded system And you're making things working and then all of a sudden you add the internet to that I just want to let you know that give me painful my friends But there are some good reasons to connect your thing to the internet Your device has data on it and you want it and you want it now and you don't want to plug it into something And or your device is far away and you want that data you want access to it Or your device needs data from elsewhere to do its thing Or you have two or more devices and they need to talk to each other or you want to trigger something on that device Remotely so there's all sorts of things like maybe you want to say okay when I'm When I'm like a block away from my my house I want my house to detect the fact that I am like on my way home because of GPS things and and to automatically open the garage door nothing bad can go wrong in the situation right and And it will just you know happen by magic and so those are the kinds of things like you can do with sensors and And data and you can trigger things And in that case the the internet would be connecting through cellular right in the car And but at home the the thing that is actually opening the door is connected to the home wi-fi So you use different modes depending on your context So let's talk about oh reasons not to connect your thing to the internet You think it'll be so easy everyone's doing it internet of things internet of things so easy Okay, if you want easy go buy a phone a smartphone and just be done You know and just don't go there, but if if you are up for a little challenge, you know And you like to read tutorials that are probably a little bit wrong Then you know you should go for it Also, if you loathe code like if you just don't like it at all Don't do this at all Also, if you hate learning new things you just don't like learning at all like yes I'm gonna like celebrate every time this light goes on Thank you build notify or tower light if you hate learning new things You should not go down this road at all just like get go to the best buy or the store and just get the thing That's already working. Okay, so There are some specific data needs in the iot space. So there's storage. Okay, like what? Storage for your data storage for your program You start like putting things together Hooking things up to a microcontroller. This is I'm telling you the story of the death of thing too So in thing two I had this this flora microcontroller turns out the flora microcontroller only has a A limited number of space. I added to it a bmp280 Barometric pressure and temperature sensor. I added to it an led matrix. This is the little guy was so cute Who's great? I love led matrix matrices And I also added to it a gps module and a blue fruit module which connects it to bluetooth Turns out for each of those components you have to add a library of code And that code takes up space and when I added I tested each of these things one at a time I kept adding to them and I'm like this is going really great I'm going to rock this and then I added the bluetooth of the blue fruit module in the library and all of a sudden I'm at 114 of my storage space And um, I spent all day one sunday trying to optimize that code. I got it down to 101 I could get it down to 99 with just the library loaded when I added the one line to make the one call To the blue it it went over to 101 percent. So um, so Thing three was born. So Thing three Well, let me just go through this first. So you need storage Sensor data is great for visualization So you're sending all these values great for maps and charts and graphs And so if you're into data visualization You should like check out things that are happening in the iot Sensor data world. It's fascinating. There's monitors and triggers. So, you know, it's like, yeah, it's fine and good that we have all this data but what are we going to do with it and Uh, and then we've got calculations that need to run and update ability And there's different ways that you can connect you can you can use wi-fi you can use cellular You can use ethernet you can you can um Kind of do like a leapfrog method and Like connect to something that's connected to the internet, right? So you could use bluetooth or you could use radio for that And uh, you need to consider like how accessible does your data need to be? How often do you need access to this data? Do you need access to it every every second? Like is this a smoke alarm trigger? Like do you need access, you know, like do you need the notification that your house is filled with smoke? Like when your website decides to run cron three hours later, or do you need it now? Like do you need to know instantly? So how instantly do you need this access? What other things? Need your devices data to trigger their action. So like what's the chain of events here? What's the timeliness if you're just getting today's forecast is once a day enough? Yeah, it probably is Um, and how will other machines access your data? How will other humans access your data? Are you going to really like? Expect, uh, you know, you're someone else that needs this data to like Load it up To Arduino IDE and open up the serial monitor and just like get the raw data and then convert it no big deal Right, you know, no like how are they going to get that data? How are the humans going to access that data? That's important consideration. So iot cloud apis are there for this reason You can store sensor data for free. There's um, hosted rest api endpoints so that you can get that data You can do cred operations on it. You can create new data You can update or delete that data and you can use um message brokers that are just there's so many options And you can use protocols like mqtt to distribute the data as you require Um, things speak is one example of a great api. It's an open source api You can actually like download things speak from github, but it's hosted on the internet things speak com You can store data and channels. It's got a rest api for each of your channels and data important expert export you can You can set up matlab analysis So you can do calculations on your data You've got a lot of like out of the box matlab Like boilerplate code that you can just modify a little bit and then you get some Great, you know calculations and visualizations out of that They've got different plugins for gauges and charts and you can add your own custom thing as well They've got actions and triggers adafruit.io i'm a real fan of adafruit and I like to support their business um And they have a lot of great support not only in their products But in their code libraries and they have the service called adafruit.io Which is in beta in it right now, but it's working great for me You can start you store the data and feed so One feed you know one feed per one, you know channel you're not gonna Not like in Drupal where you have like multiple fields like in a content type or something like that But this is like one feed of data, you know one channel. They've got visual data visualization widgets Feed data manipulation tools device control so you can trigger You can set up a little widget on there to like an on off switch And you can you know turn a light on on and off from the website So you don't even have to code your own thing you can use Their api and their um their tools their widgets to to can get a start in all of this It integrates with if If this then that i ft tt and um And there's lots of code libraries with helper functions to help you connect if you're a developer So The first context i want to talk about is uh on the go is is thing one You know away from a controlled access point. So let's say i'm on the go, but i've got my phone with me So can i use my phone's internet connection? Which is connected over cellular to get data from my thing up to the internet the answer is yes I can i will show you now. Okay, so let's Look at thing. I don't know what number we're on now This might be thing five Okay, here's my thing Okay, so this thing is uh, this is a Feather blue fruit m zero microcontroller. It's real nerdy stuff here folks so The stuff that is like easy to use and um has really lots of great support Is usually out of stock The stuff that you can get on short notice when you have a dripple con presentation is really Easy to get and it's also a little harder to use Um, so not all of the arduino library's work is good. Which is why it's just doing this thing here So this is what i could figure out. So i've got a bmp 280 Uh barometric pressure and temperature temperature sensor. It's connected to the blue fruit now observe on my phone I'm gonna move this all the way I have an app on my phone Uh provided by adafruit in the app store called blue fruit le so i'm gonna open that up And here's my device i'm gonna connect to it Over uart, which is a hardware serial thing and uh Here's you can tell i'm just learning all this stuff right and it's okay because you can be a beginner and you can Get some stuff working that you didn't think you could ever get working So here it goes like it's reading the temperature in the room and it's um sending that data up and i've got The mqt t Stuff it's configured to go to this temp temp c thing three temp c feed So if i go to adafruit i o And i go to my feeds Here's the the temp c Thing three temp c i guess this is thing three so half a minute ago. So it's I'm sending so now I could do something with this data. I don't know what I would do, but You know I could do something with it. So it's it's in there. It's accessible to me It's accessible to another machine over this api and accessible to me as a human through this lovely web page Okay, so tada. Okay next um You can also connect over wifi. So we've got wifi here and um, I've got this little thing This is um, okay See that okay So this is another feather board. This is a wicked feather See I learned has solder for you people. I just want you to know that Appreciate that So this is a a wicked feather microcontroller that you can't really see because on top of it is this feather wing it's an olad it's got this olad display here and Do you see that Today's high 85 degrees So how did that get there? I'll tell you so um, if this then that Uh, in fact, I'll show you right here If this then that every day at 7 a.m. Is getting the weather forecast and it's sending the data to this aida fruit IO feed called high temp the script on the feather is Uh calling to that aida fruit IO and getting getting the high temperature. It's connecting to the wi-fi I have it configured to connect to my personal hotspot on my phone because I don't trust this internet here And but it could connect to any you you configure the ss id and the the password in in the code And and it connects to the the wi-fi So that's another way you can do it So I'm pretty sure I need to talk a little bit faster now Oh, yeah I'm going to skip to What about Drupal you all came here for that, right? So, um, okay, so what Drupal has now is uh guzzle Which is a way to make http requests and handle responses a vendor directory Which means and by that I mean like anything on packages and these crazy php stuff that people are doing it could be conceivably ported into Drupal 8 and There's also the ability to integrate javascript and embed, you know, no j s and I would also add there's a lot of smart people in this Drupal community So that's what Drupal has now. So what I did with that was um I made a Drupal site That um, it is getting this Thingspeak has a channel that tracks the location of the largest container ship in the world called the mary marisk And on the mary marisk is a location sensor and it sends the latitude and longitude to thingspeak And I'm getting that data using guzzle in a custom module in Drupal 8 to get the latitude and longitude And um, I've created this leaflet map and this leaflet map is getting data Because I created a view of um geofield actually works in Drupal 8. Thank you geofield people and um, I Have nodes that have a geofield on them and these nodes contain the latitude and longitude I have a view of a rest endpoint using a geojson formatter And so that that that creates an endpoint that outputs geojson data and then A leaflet can use that and and create these map of these map points And then I've got this little form here update thingspeak data So now it's gone out to thingspeak And I'm going to zoom this map out a little bit and you can see The mary marisk is on the move folks and we've got the latest data. So that's one way It's admittedly a contrived example of what you can do. There's many ways to improve the situation like Making this more dynamic having that data updated on a more automated basis like I could put this into cron or something like that I could have the nodes be you know updated. So it's it's only creating data with new It's not creating duplicate nodes. There's many areas of improvement here, but What we've done is we've got sensor data stored in api And we've used Drupal to to pull that data down and what i'm currently using is is guzzle for that in a nutshell So in my opinion Drupal has good ways of Exposing your Drupal site as an api, but it needs better ways to consume data from from endpoints and Drupal needs both code tools and UI tools to Let people play with their sensor data and and with these apis and connect to these apis So I think that a good start would be like an integration module with thingspeak or an integration module with adafruit IO and there's other iot cloud cloud-based apis out there And I think it would be I would love to see some development in these areas and maybe I'll I'll venture into that but but I'm probably not the best person for that, you know, so And also Drupal needs modules that can handle frequent updates. So if you've got data, that's that's getting Pumped up into an api every second or every five seconds or whatever it is and it's critical data Then you need something that goes beyond polling, right? So you you don't want a program that's just going to say hey, is anything new is anything new Is anything new you need something that's going to be able to keep a channel open And I'm not even talking about like making a light blink over Over a website which you can do like using html 5 web sockets and and mqtt and there's other ways of doing that But what I'm just talking about is making use of like real-time data That's in an api and so I'd really like to see something that goes beyond rest for that so In Drupal 7 we had feeds and there were some promising plugins there like with pub sub hubbub integration but that module seems to not Be on any kind of path to be upgraded to Drupal 8 and so I think there's going to be a real gap There's a real need here in Drupal 8 in my opinion To to have some of this development that lets people make use of this iot data In brief I'm going to make this really quick. I want to tell you about mqtt So let's say you've got a thing that wants to connect to the internet And so let's say we have a toaster and we want to connect to it Well, I suppose we could plug in an ethernet, you know with ethernet to your network and Somehow and and then it would you know connect to the internet But maybe you need to do it wirelessly, you know wireless is so cool and everything So maybe you like attached a wi-fi module to it. It's so that it it detects it and you know You know, we've got some you figure out the power situation And like if you use rest for this toaster thing like The the hgtb rest thing is going to be like is there anything new for me? No. Well, what about now? No What about now? Oh, yes, you know and this could go on for days weeks hours, you know like who knows like that's so resource intensive That it's just not a very, you know good way of doing things. So if you have mqtt The the bro the cloud api says hey toaster start toasting. Okay, my temper and it's like sending out its temperature. Okay, my temperature is 50 degrees Celsius and it's 100 degrees. Okay, and it's just like sending it along and it's not And it's sending it to the mqqtt server And then when it gets to a certain point the server knows which point that is and it says okay stop And then it stops and it sends the message back and there's this open connection and there's this published subscribe Dance that's going on and when you set the values and then it you know, there's communication that happens there And it's low bandwidth and low energy Um So this is this is a really nice thing. This is what I use in python. There's libraries for it in python There's libraries for it in many languages. There's even libraries for it in php There's just not a class for it in druple a at the moment And which it could be brought in right? So iot data is special iot data uses sensor data a lot and you know if you're going to monitor sensor data you need to You're you're probably going to trigger some action and so why trigger an action if it's going to be too late? so you need reliable connections and You know you can't be relying on running cron unless all you're doing is getting today's forecast, right? If you're using critical sensor data, then you need something that's more reliable um And so i've got some resources here for learning more about mqtt This was a new to me and it's new to a lot of people that i've talked to And so like with an mqtt broker, you know you could be juggling multiple things So there's a location sensor in the car that's like okay i'm five miles from home start toast in toaster And you know the the toaster starts toasting and then It's the broker sends a message to your phone saying your toast is toasting and you're excited about that and And then the toaster talks to the broker and says hey start a toasting and you know it's gonna Message back and forth about that and the broker is just handling that all and each individual script It's just going to like take the data that it needs Not everything right it's just like i just care about this bit of it And and then that that's the way you can juggle these multiple Channels and these multiple triggers is through using an mqtt broker Um all these slides i asked permission from eta fruit and There's a great article on eta fruit com On why you would use mqtt and i use those graphics and it's all there. There's also a great five or six part series on mqtt essentials that i highly recommend on the hive mq.com site, so i would recommend those as well Um I think i'm out of time here And i think i i touched on some of the gotchas that i encountered with regard to storage limits and You know these different microcontrollers there's so many different options And a lot of times you just don't know what you're going to run into until you plug it in and start working on it And so just you know when i first got into this i thought this is going to be a really cheap way to do fun things and It's not cheap folks, so um You know Especially if you And if you can find someone that can help you along that's really great Like i kind of like forged ahead and was you know, i had some online resources But i didn't really you know i had the local um electronic shop that Help you know gave me some tips for when i ruined my thing too and had to desolder it I had to learn to desolder for you people too. I just want you to know that And i just want to take a moment to say rip for thing too Sorry, or thing too. I couldn't get you connected to the internet, but you were pretty rad And i just want to take a moment of silence for thing too Um, so before you add internet to a thing consider the following. How will you connect? What kind of microcontroller do you need like how are you going to embed it? Um, what you know, what sizes does it need to be? How are you gonna Are you gonna have to like learn 3d printing too and 3d prints? I'm like crazy case probably Can you actually uh get it? Is it in stock? Who knows right and what will you do with the data? You know, what api you're going to use what's going to work best for you? For dribble dribble has some great ways of exposing an api But needs better ways of consuming apis in order for sensor data to be really like usable in a dribble context And I think please someone add an mqtt class to dribble eight that would make me a very happy person Um, if you would like to evaluate this crazy dog and pony show of a session I would really appreciate it and you can go to the session on the dribble con website And you can find the evaluation form there as well as the slides. Thank you very much I think we have a few minutes for some questions And there's a mic up here if anyone or you can shout it out and I can repeat the questions Are there any questions? like Do I need a therapist or you know? I'm just kidding a little bit The mqtt is that like open open source or is it like it's it's a protocol So it's a protocol like http is a protocol and so you can implement it There's you know standards and I didn't go into the details of that at all But you can read all about the protocol and you can implement it in code in whatever language you want node javascript python php, whatever so Basically, you're setting up like a quality of service like okay How open does this connection need to be like can I close it ever or not? You know and you can you can set parameters on you know How to keep that open or not and then you can implement it So and there are some great examples in github and you know just elsewhere For how to implement that I discovered it because a lot of the libraries that I use from eta fruit use it And so that I just was using it because these are the examples that I got and like oh, this is pretty cool. So Any other questions? Great. Oh, yes in the back Okay, so I'm going to warn you about some things. Yes, there are and you should be wary of a couple things here So, um, some of the examples that I saw were like, okay, how do I turn on a light like how do I make a light blink with droopal? and it involved and Maybe I do mean a little bit of offense to the person that wrote this but It involved putting a php exec statement into the body field and using the php filter and I do not approve So, um, I I think that that's a terrible idea And I think what you should do is send data to a cloud api and then get that data from the api And it's near real time There's absolutely no reason to directly like interact with the hardware over the server in the body field of your dribble site Please don't do that. So, um So I couldn't find very many examples, which is why I ended up coding my own module using guzzle so And thank you. Thank you to my co-workers for helping me with that. Thanks guys Well, Joe like Drupalize me so Yeah, like, um, it would be nice to have a class in Drupal 8 that I could extend or you know an interface that I could implement that That would give me some help there so that I wouldn't have to do it You know someone who who understood a little bit more about the protocol So that's what I'm looking for and you know and that's just from a developer's perspective That would be a great start and then we could add a you you know UI stuff on top of that but to start with like it would just be nice To have a class. Um, I did notice in the vendor directory in the zend framework Directory there's um in the feeds directory There's a pub sub hubbub Implementation and that's another published subscribe that has more to do with rss feeds if I understand But that's like instant updates too Like that's a published subscribe model in the same way that mqtt is so I would like to explore that a little further That was like the most promising thing that I found but it was um, not something that I I learned too many things so I had to stop Take a breath Any other questions? Great. Well, thank you all for your attention. Thanks for coming. I really appreciate it