 Hey everyone, we're back with that net comp. So We did a little troubleshooting and it seems like Miguel just muted us He was all the way down. That's we couldn't hear us. Well, I would probably mute me myself, too You know what? I mean, yeah, I know it's true It's true, but the content was so good and I would talk it with cam so for our next speaker was right here Say hi say hi cam Hey everybody, so we were like talking behind the scenes like well, we'll let Miguel do Miguel stuff And then we'll come back and go about it. But anyway, now we got cam here.net comp talking about Have your raspberry have your pie. I need it too. Let's talk about that cam Sure. So before we start. Hey Miguel if you're watching man, I'm so sorry. I had to cut you off I was really digging your talk So one of the most exciting features of Dot net core is its cross platform compatibility So this applies not just to server and desktop environments But also to iot devices raspberry pi is arguably the ultimate iot platform because it packs a very broad range of Functionality into a credit card size device that's affordable for students hobbyists and professionals So what we're going to cover in this talk, let me Share this Where's my display? There we go What we're going to cover is We're going to talk about the basics Where's my slide? There it is Uh, so we're going to talk about developing deploying and debugging dot net core code on the raspberry pi There's a lot less that goes into it than you would think. Um, this is actually going to seem kind of 100 level stuff Then we're going to talk about gpio GPio stands for general purpose input and output it refers to This header here on the motherboard Um, it's a collection of pins that we can use for all kinds of input and output purposes What we're going to use it for today are some pretty simple demonstrations We're going to control an led and we're going to control a reversible motor We're going to turn a motor on and we're going to be able to make it go uh forward or backward And then after we play with the gpio pins a little bit We're going to take it a step further and use our iot device on the internet. We're going to uh integrate a few Components with some cloud services We've got a sensor that we're going to use to alert us when a door is open or closed And the final thing we're going to do is we're going to control an array of leds using cortana here on my desktop So with that let's start at the very beginning. Hey cam really question Quick question somebody wants to know what version of the raspberry pi you're using So i'm using a raspberry pi Three model b not the b plus although the b plus is a very incremental upgrade over the b. It just has adds it's like a rev on Bluetooth and it adds a power over ethernet header. Oh, wow So yeah, we're using yeah, so we're using the 3b Um, but the demos that I have out on github and I'll share that lincoln a little bit Should work on should work on the 2 the 3 the 3b. I don't know about the zero I haven't tried it on the zero, but I I'd be I'd be interested in hearing what what uh, what your experience is with that Awesome. Thanks, man. So sure So i'm going to jump right into a demo I'm going to show you how easy it is to get dot net code running on the raspberry pi now I'm not going to go through, you know, where to get the raspberry pi and the operating system and all that It's out there on the internet. It's easy to find We're going to start Where I've got a raspberry pi device sitting here on my desk. It's connected to my network And it's running the raspbian os with ssh enabled. So all we need to do is write some code. So let's get to it So i'm just going to pop open a new visual studio window here And we're just going to file new project ASP.net core web application And i'm going to call it Pi demo Ah, I already have a pi demo folder. How about pi demo 2? That's creative I'm just going to take all the defaults. So it's going to be an ASP.net core 2.1 razor web application. All right So that's done. There's really no need to review this boilerplate. I'm sure anybody who's done an ASP.net core applications seen it all I think I will go ahead and we'll just change some text On the index razor page just so we can say that we changed it There we go And let's run it locally real quick to make sure it works and that I didn't somehow break anything All right, so that's it's working. That's fine. Now we need to get it onto the raspberry pi Well to get it on the raspberry pi. I need to package it up as a deployment first There are two ways we can do deployments in dot net core There's a framework dependent deployment that expects the framework to be Installed on the operating system or there's a self-contained deployment that has all the dependencies along with the executable I'm going to go with the self-contained deployment. So I don't have to worry about getting the dot net framework The dot net core of runtime and framework installed on on my device Now I could Package that we are in pi demo 2. I could publish that rather dot net publish dash r for To make it a self-contained deployment targeting linux dash arm And that that will work that that will do exactly what I want it to but since I use a visual studio to Build the application. It seems to me like I should probably use visual studio to at least publish it Before I before I ftp it out to the device So let's take a look at how to do that really quick Just like publishing to azure. We're going to right click on the project and go down to publish But I'm going to publish to a folder I'm going to put this folder. I'm going to put it in the root. I'm just going to call it a pi demo 2 pub Then we're going to set a few advanced options I'm going to go with the debug configuration because I'm going to be showing you debugging here in a minute Uh target framework is that is net core app 2 1 Deployment mode is not going to be framework dependent. It's going to be self-contained And target runtime. Well, you'll notice linux dash arm isn't in the list. That's okay. I got you We're going to pick linux dash x64 Save the profile and create it I'm going to go ahead and rename it just so uh, I I know what the file name for the profile is we're going to rename it Pi profile Now before I click publish I'm going to come over here to my properties node under the project and there's a folder for publish profiles If we look in there, there's my pi profile And this is the profile and there's the linux dash x64 runtime identifier I'm going to change that to linux dash arm and save it And now I can come back over here and I can click publish And it's going to do its thing All right, so it's done. Let's see what we've got You know a border that I put I put in c pi demo 2 pub So there we go. We've got a whole bunch of files in here. We've actually got 355 files in there But uh, that's that's everything that our application needs to run on the device Uh, let's ftp that out there because it's going to take a few seconds to transfer and before we look at the files Hey cam Yeah, there's a couple questions in here and the people are wondering um, skull crusher for life Is asking if your stuff contained will it package the required dependencies there and saving space on the raspberry pi Um, you know, I don't know of all of the all of the deployments I've done It does seem to grow if I'm doing asp.net versus say a console. So I'm inclined to say yes, but to be honest I haven't looked that closely Um, I I it is a bigger transfer from asp.net So I'm inclined to say yes, and I'm I'm hoping that somebody has a more definitive answer Gotcha because there's a follow-up when someone's saying is there a performance difference between publishing a self-contained or framework independent? So I would I would assume that framework can be bigger though, wouldn't you? Well, I wouldn't assume there's any type of performance difference. It's the same It's the same binaries that are are being read in at runtime. It's just whether they're located in the same directory as the As the the assembly or whether whether they're off somewhere in like a global, you know, like in a path location somewhere Perfect. All right. No, it's all good. Go ahead continue answer Well, I see another question just popped up. Jose wants to know which of us is running on the raspberry pi And that is I'm running the latest version of raspy in linux So, um, yeah, so we're gonna grab this publish location. Where was it? Where did I call it? I probably need to refresh locally. There it is pi demo pub And I'm going to connect to my raspberry pi over sf tp in file zilla file zilla is an open source file transfer client Um I actually have a profile already set up sf tp uses the same username and credentials as ssh So when you set up your pi and you go into the configuration tool to turn on, uh, like wi-fi and things You'll also want to turn on the ssh service Let's make a little location. So you see we're in our home directory for the pi user I'm going to make a location To store that, uh, we'll just call it pi demo Actually pi demo 2 There we go And I'll come over here control a drag and drop And let it go and this will take a couple of seconds. It's uh, about 93 megs total with all the dependencies While that's doing that. I want to come over and I won't actually look in that folder And we see a lot of things that you would see in a typical, uh, asp.net core deployment, right? Like your app settings Uh dot json files and we go down and there's a whole bunch of dlls and pieces of the framework and compatibility shims for linux and all kinds of things Um, then we get down and we see like we have pi demo 2 dot dl and pi demo 2 dot views dot dl Those are also what we would expect to see in a razor app But we also have this file right here this file that has no extension Pi dash demo 2 no extension. That's actually the executable file. That's actually what we're going to run in linux There's probably a term for that. I'm really more of a windows guy anyway So I if there's a terminology there that I'm not aware of I'd love for somebody to tell me But um, all right, so our file transfer is done So we should in theory be able to ssh out to the shell on my raspberry pi and Should be able to run it right Well, not so fast Uh, here's let me go ahead and type in the command pi demo 2 permission denied If you're not familiar with linux linux has a mechanism whereby we don't just run any file willy-nilly We have to give files permission to run And the way we do that is the chmod command So i'm going to give it Uh permissions So now it should be able to run give it a few seconds to jit All right, it's running Now I can't look at the website yet though because We're running as a as a kestrel application. Whoops wrong uh wrong Zoom it. Uh, we're running as a kestrel application And kestrel by default if you don't tell it otherwise Is only listening on the loopback adapter localhost port 5000 So we can change that right you can change it in code We can go to you know the the programs.cs and come in here and when we're Creating our web host we can add a dot use urls right for example But what we can also do is just at the command line. I'm going to control c to end the program And i'm going to run it again, but this time i'm going to pass in a switch urls http http colon slash slash star so every adapter port 5000 All right, so now we're running and we're listening on all the network adapters on the device So we should be able to go to my browser And I should be able to go http colon slash slash raspberry pi port 5000 Well that wasn't what I wanted. Why are you searching edge? You should not be searching You didn't search earlier There it goes it's loading this time All right, so there's our website running on the device. So that's really all there was to it. I mean Dot net cores cross platform We really should be able to pick up an application and run it on any platform without any significant changes Now debugging the application is where it gets just a tiny bit trickier, but it's still not that difficult I'm going to leave the application running I'm going to come back over to visual studio I'm going to get rid of this little change I made there we go and We're going to go to debug and attach to process and in the connection type When you come in here, it's usually going to say default and it's going to list all your local processes But we're going to select ssh The connection target is going to be your username at the network address And it'll prompt you for a password. It's not going to prompt me because it's got my credentials cached already But I'll hit enter And there's my list of running processes on on the raspberry pi and there's pi demo 2 So we can just attach right to him It asks it's asking us what type of code we're debugging. So this is managed code I'm looking at the while it's attaching. I'm looking at the chat I do have like a foot tall deadpool character standing here on my desk, by the way um All right, so it's running. Uh, let's set a breakpoint real quick I'm going to go into the razor page I'm going to set a breakpoint where it drops out of the on-get method So in theory, we should be able to come back over here to our browser refresh the page and hit the breakpoint So it's going to take a couple seconds this first time because there's a little warm-up involved But pretty quickly we do hit the breakpoint. All right, so let's continue I'm going to hit refresh again You notice it hits the breakpoint much quicker that time So that's how we debug in visual studio. You can debug in visual studio code too But there's a little bit more involved. There's a dependency that you have to install on the pi And I've got a link to a walkthrough to that on the github page for this talk. I'll be sharing that url later all right so That's pretty much all we need to do to get an asp.net core app running Now I want to talk about some of the device specific features of of the raspberry pi specifically GPIO right Now before we start talking about GPIO, we have to talk a little bit about just a tiny bit about electrical engineering Now, let me preface this. I am not an electrical engineer There are probably plenty of you in the audience who have Way more experience in electrical engineering than I do I've been probably going to mess up terminology and for that I sincerely apologize feel free to correct me in the chat Or twitter or whatever So The hello world app when it comes to gpio is blinking and led To do that i'm using a few devices here that I want to make you familiar with The first one Is this little blue thing right here on my device? It's black on one I think it's green on another one, but it's it's called a cobbler or breakout board The idea behind this cobbler or breakout board is that I can hook On the raspberry pi itself a ribbon cable that connects the gpio header to the header on this cobbler and Then plug the cobbler into a breadboard which makes it easy to connect Wires to these various pins on the raspberry pi and and have a visual representation of what i'm connecting to Now the breadboard itself if you've never used a breadboard and breadboards were new to me until recently The breadboard itself is a device that's used for prototyping circuits without doing any soldering Which is really handy for me because i'm awful at soldering So the way it works is all these ports on the breadboard are connected to other ports on the edge We've got ports running down the length of the device And in the middle We've got ports that run on either side of the median And what this allows us to do like I said is to plug our cobbler into the breadboard And then use jumper wires and kind of play operator You remember the old cartoons where the operators would plug in the the plugs into the switchboard and it's kind of like that Again, i'm not going to go into the circuit or why the led works or why there's a resistor there or anything like that But what's important Is to know that to turn on the led i need to turn on gpio 17 that's pin 17 I just arbitrarily picked pin 17 There's no reason to pick it over any other one I just arbitrarily picked that one and it feeds power to this rail down here on the bottom Which feeds power to the resistor which feeds power to the led Which is connected the cathode the out pin on the led is connected to this row right here Which goes back to the ground pin on the header So um, that's the circuit Now before I show you the code that's going to run this circuit I need to show you a feature of the raspbian operating system that's fundamental to how the code works So let's drop out of the slide here And i'm going to go back over To my shell And what I want to show you Is a virtual file system location on the raspbian operating system So this slash class slash gpio And what this file system location allows us to do is it allows us to control our gpio pins directly through the shell Let me let me demonstrate So if I look at the contents of this directory, we have a few different locations We have locations named export and unexport and we have three Representing gpio chips. Uh, we're just concerned with export and unexport at this moment Now to open pin 17 I'm going to write the text 17 And i'm going to pipe it to that export location So now if I look at the directory contents notice That I have right here A gpio 17 location So if we change our directory to gpio 17 And look at the contents We have a few other locations and what we're concerned with here are direction and value So whenever we open a pin, we need to set a direction We need to tell the device whether to whether to generate current or expect current coming into the pin like a ground pin um The way we do that is we write again. We just write a text value And in this case out we want the pin to generate a current echo out to Direction All right, so direction is out and then we can turn on the uh led turn it off and on Uh by writing one or zero to the value location and to show you an actual breadboard with the led I've got a little camera rig here. I actually had to do a little bit of a rube goldberg contract contraption where I'm remoting into another machine driving the camera because Skype does not like this camera And um, you can see that this this circuit is exactly the same as it was on the schematic I showed you a second ago Or I mean I've got it plugged into pin 17 the blue wire right down to the wire color I really wanted to make it so you could reconstruct this at home without too much effort So um So yeah, we should be able to just write one to the value And it should be able to it should turn the led on. Let's let's try it echo one to value And there we go we turned on an led Now let's turn it off There we go And then we can close the pin by echoing 17 to unexport All right, if we if we look at the directory again 17 has been closed So How do we do this in dot net? Well, there are apis to do it um, certainly now I uh, uh Did not use any of the other apis that are out there and we're going to talk about that later near the end of the talk I actually rolled my own and um This gpa gpio dot net project in the uh demos folder on the github repository for this talk Um has a gpi open class Now in that class Um, we just have three properties number direction and value And we'll come back to the getters and setters for value here in a second when we Initialize the the object We are requiring a pin number in a direction in the constructor Right, and we're setting those right off the bat And we're writing those out to that location. So we're opening the pin then later on we're setting the direction And then we're setting a default value, right? So we have an optional parameter on the constructor That that sets a default value of pin value dot low. Wait, wait, wait low. What's that mean? We talked one and zero well in in, um in Gpio terms high is one low is zero I don't know why all right. This goes back to me saying i'm not an electrical engineer I'm sure somebody in the audience can probably tell us why um, but uh Uh, but that's that's the terminology. So that's what I went with The other thing that this class does is in the event That we set pin direction in in other words, we're expecting current So we're gonna watch to see if the circuit is broken. Um, I kick off a task asynchronous task That I call pin watcher That just actually pulls the value every 10 milliseconds and uh fires off an event if If the value changes to either high or low Why am I polling there? Why didn't I use like a file system watcher? Well, I tried using the file system watcher and it doesn't like that virtual file system thing So, uh, I had to use kind of this hacky cluchy method Um, there is an api out there that will do it kind of the right way directly in memory But it's not quite baked yet and we'll get to that So my hello world led program Where was the code for that? There it is All it does When we run the code is it's going to new up my gpio pin class with pin 17 direction out And we're going to loop five times. We're going to turn it on wait a second turn it off. Wait a second That's all we're going to do now gpio pin. It implements I disposable because I I made it. I wrote it in such a way that it it is Consider it and closes the pins that it opens So, uh, we want to use the using pattern to make sure that we dispose of it properly So with that I've already got it built. I've already got it deployed Let's just go ahead and run it. Let me Get the breadboard up where we can see it. There we go And sure enough it works All right, so on one hand. Yeah, that's pretty cool We can control an led through hardware that you know kind of like low level on the metal hardware But on another level big deal. We turned on an led, right? Well That little piece of functionality being able to open and close a pin open and close a circuit like that Gives opens up a whole world of possibilities for us Let me illustrate The next demo I'm going to show you is this circuit now I realize this circuit looks kind of nasty has lots of wires and relays and things like that But it's really not that bad. Um, I'm actually switching out my breadboards while I'm talking. Um So I've got two relay modules attached to attached to my breadboard And what we need to take away from this is that the first relay module The one on the top there it's only using one of its two relays because these are dual relay modules It's connected to pin 21 and all it does is Open and close the circuit turn this motor on and off that's all it does Now the other one the the Second relay module has two relays on it and we are actually using both of those But what I want to point out Is that they are both hooked up to the same pin in fact, let's zoom in a little bit there You can see Those are both hooked up to pin 27 Both of them Now, why would I do that? Well, the reason I did that is because I wired this circuit in such a way that when These two relays on the second relay module are turned off Power flows one way through the circuit And then when we have turned them both on at the same time we use a different set of wires And power flows the other way reversing the polarity of the motor Okay So we're going to I see somebody likes my zooming. Oh, it's scott. Hey scott. You like my zooming skills, huh? So I'm going to Switch out let me plug in this breadboard Really quick This again, this breadboard is Exactly what's on the schematic. I showed you Right down to the wire color. I I paid a lot of attention to detail I 3d printed a little bushing to hold my motor so we can make it more visible for you And I put a little spinner on the on the shaft So when the motor's spinning you have a visual representation of it So, uh, let's uh, take a look at the dot net code that goes along with that real quick before we run it This is the motor project in the demo solution. We'll start with the motor class The motor class, um, it's actually really simple when we knew it up We pass in in the constructor a Power pin number and a polarity pin number And we knew up those gpio pins Um, and notice we set a default value of pin value high Why on earth would we do that? Well, it has to do with the way the relays are expecting, uh, current from the device It turns out that my relay modules, um, expect pin value high to be on and pin value low to be off Uh, it's just how the how the relay modules were designed. So I'm just rolling with it So when we call on we set pin value to low turns the motor on when we call off We set high turns the motor off and then I just arbitrarily chose high and low for forward and reverse Um, the program code That launches that motor class. I just made a little command line interpreter, right? So, um, it news up the motor using the using iDisposable pattern again and, uh, Sits in a loop Looking for commands on off reverse forward and exit and those are all pretty self-explanatory So let's go ahead and run it Uh, need to put the breadboard where you can see it. There we go. Uh, yep. I know it's a directory executable, please There we go All right valid commands on off forward reverse and exit. So let's try on The motor's spinning All right, let's reverse it. All right. It's going the other way Let's go ahead and just turn the motor off So you'll notice it's still reversed and the the relay that controls reverse and forward is, um It works independently of the relay that controls on or off so we can set it back forward again Turn it on again and off So that's a practical application Beyond just turning a light on and off. We can actually turn like Physical things on and off motors. You could connect relays to lamps to you these relays actually support up to 15 amps On a 110 volt circuit so you could control your your uh, your your household lighting with one of these if you were so inclined All right, so We've put the things in internet of things. We've been looking at the gpio pens But this is all everything we've done so far has been Constrained locally to my raspberry pi right here on my desk What I want to do now Is I want to show you a few projects that I did To give you some ideas of things that you can do with this using some services out in the cloud And to start i'm going to dive right in With that door alert sensor. I told you about now Let me switch out my breadboards bear with me for a few seconds Hey cam. So what I've got now Hey cam Yes, everybody's loving you. This is amazing You're doing a great job man I appreciate that you never know how a talk is going to be received until you do it And this is a brand new talk I mean this is this is this is up there I appreciate that So, um, what i'm going to show you now is we're actually going to use pin direction in right We're going to mod we're going to watch a circuit to see if it gets you know See if it's opened or closed and uh, what i'm using are these little magnetic This little magnetic read switch So the the whole idea behind a read switch is when the magnet is present The switch is closed So the circuit is connected and when the magnet is not present the switch is open So the circuit is disconnected and let me zoom in a little bit here So I can show you you can't really make out the text on the breadboard But the blue wire is three volt power And that's going to the read switch and then pin 20 right there Is uh, that's going to be in that's going to be what's watching to see if the power is coming into the pin or not And firing off events in our code So let's look at that code real quick So we understand what's going on This is the door watcher program So I'm going to skip right down here to main And all I'm doing is I'm newing up that pin on port 20 direction in And I'm wiring up a couple of events uh contact switch high and contact switch low If we go look at those two events, they both do practically the same thing They pass a message off to a method called post status And what post status does is it kicks off an asynchronous task That serializes a message and if you're wondering what that What the uh what that looks like there's not much to it. It's just a single property on that class um It serializes that message to json and it posts it To an azure logic app now I chose an azure logic app for this because they are dead simple to set up Um, we can go look at it real quick This is the logic app. It has uh, it has a single trigger and a single action The trigger is just an http webhook. So you saw back in back in the code. I'm, um, I'm posting to a http location And uh, there's the the schema for the message that maps matches the class in my uh in my project And then what it does with that message there's a billion different connectors that we can choose from in in logic apps I chose slack in this case just because it would be easy to uh show here on the screen share But you could use something like twilio You could log it in an excel spreadsheet if you want to know who came and left your office all day You could set that up and I'm not who but what time people came and left and when the doors opened You could you could rig up a home security system You could do stuff like that and make it go to your phone go wherever that's kind of kind of the magic of something like logic apps So let's look You can see where I was I was actually trying this earlier. I have meant to reset this. Um, this is my this is my slack room right here and Go back to the gpio. Let's Move this over here And I exit my motor program Whoops There we go And let's run the door watcher program All right, so now it's waiting for the switch So you can see up in the breadboard. I'm going to put the uh magnet next to the switch It's going to take a few seconds to wake up the logic app the first time But after that It's basically Sub-second so there we go there's a a uh A uh home security system made with a raspberry pi and a five dollar read switch Okay Now for my final uh demonstration of cloud integrations that we can do I want to actually use cortana um to Drive like I said, I have an array of leds that I want to be able to instruct cortana to turn these leds on and off Um, there's a problem with this however And I've got a slide to illustrate that The problem is that the way this is going to work So I'm actually going to do this with the cortana integration on ift if this than that. It's a it's a service It's a lot like logic apps Um, it's it's a lot simpler though It has a single trigger and a single action if a happens then b And cortana actually has some actions out there that are pretty robust that are really easy to use I'm going to show you that here in a second So my thought was well, we could trigger cortana. We could invoke cortana Dot net bot is going to help me with that if I can ever click there we go We're going to invoke cortana and that's going to set off the trigger in ift, right And then ift could maybe fire off a webhook to hit a web api on my raspberry pi, right? I mean that seems to make sense The problem is we're here in my home office. We're behind my firewall I could open a port on my firewall, but I'm not going to do that What if I was in a location where I couldn't open a port on my firewall? Uh, so the traffic's not going to get through and that's not going to work So we have to come up with another solution So the way this is going to work Is we're going to use a couple other services We're going to use an azure logic app and an azure service bus message queue And the way it's going to go is when we first start the application It's going to make an outbound connection from behind my firewall To the message queue where it's going to watch the queue And uh, it's going to wait for new messages Then at some future time we can invoke cortana Which will fire off the trigger on if this than that Which will send a we use a webhook and post post that webhook on another azure logic app Which that logic app will in turn Create a service bus message and put it on the queue Where it's immediately picked up and acted on by our application All right, so I'm going to walk through all the code on that and then we're actually going to demo it We close that So let's start with the Service bus queue. There's actually nothing to the service bus queue I already have a service bus namespace. I created there's no I just took all the defaults And then there's two queues I put in there. I had one for another demo that I'm not that I If not going to be doing and I have this one here called cortana There's all default. I made no changes whatsoever. Just uh file new basically Now the logic app let's check out that logic app that logic app Again is pretty simple. It's pretty much the same as the other one We've got a webhook here, right with a simple schema that's expecting um a single property called color And the action that that logic app is going to take is it's going to Send a message to a service bus queue named cortana And I've already done all the wiring up and it walks you through it the first time you you set it up Okay, so that's the that's the the two azure components. It's a service bus queue and the logic app Let's go look at the dot net code really quick Don't don't do this by the way. Don't don't hard code your connection strings. I was rushed. I was rushed You put your connection strings someplace where they belong, please So what we do is we open up these three pins And uh Then we connect to the service bus queue and we watch it We register some handlers to handle the handle the messages as they're posted And then we uh, we just say, okay, we're waiting for cortana Now the handlers are actually pretty simple. They're very similar to the To the door watcher app. Actually the same kind of thing Where all we're doing is we're looking at that message Right and we're looking first thing we're doing when we get down to the process color text It has to go through several levels of of process messages and handlers and so forth But when it gets down to process color text, we're just looking if it's red We turn on the red light if it's yellow we turn on the yellow if it's green we turn on the green Again, you're going to say, okay, but why is this pin value low and not pin value high? I'm going to explain that in just a second. This one's actually pretty easy to understand for me anyway um And then if if it's not red yellow or green, we're going to blink all the leds is kind of an error state to say Hey, yeah, this isn't this isn't a color you asked for purple and we don't have purple So the final thing that we need to do to get this all wired up is we need to set up Cortana And she thinks i'm talking to her hold on there we go. Um So i've logged into my ift account we're going to make a new applet. I'm going to say if this And this is going to be Cortana And we're going to say a phrase with text What do you want to say? I'm going to say turn on the and then you see it says down here that Says down here that the dollar sign is the token for the uh for the text ingredient They call it so the the text that we want to pass on to the uh to our action So we're going to say turn on the dollar sign light Also, just add dollar sign light please is another option And what do I want cortana to say in response? How about we have her say Sure I'll send a message to turn on the dollar sign light So there's our trigger Yeah, I see out in the chat they're asking where's the device integration this this is this is poor man's cortana integration You're absolutely right. We can we could write cortana code to live on a pi device using the windows iot But this is more i'm going to use some uh some integrations from my desktop here to automate stuff Like in my house or office or whatever So the trigger was cortana and then that is going to be a In this case another webhook We're going to make a web request And I have my webhook url over here in my notes Authentication is baked into that url has a I believe an oauth token in it Going to post application json and then what we're going to post The shape of that message is Whoops wrong Copy and paste There we go. That's the shape of the message just a single property called color And I don't want notifications So there we go. We made a new applet. It's all wired up and ready to go The only other thing we need to do is uh, we need to hook up the breadboard that has the leds So let me do that very quickly There we go Now I told you that the reason that there's a very Easy to understand reason why we're using low instead of high to turn on these leds And that that reason is The uh Well, what's the hot key for a line? So the 3.3 volt Uh wire here is going to this rail which is providing power to All of these resistors which are in turn providing power to the leds And then the cathodes from the leds are connected to their respective ports Since the cathodes the outputs from the leds are connected to the ports The ports are going to be blocking the connection when they're high And when they're set to one But they're going to be allowing the connection when they're set to zero So that's why low is going to turn them on and high is going to turn them off You'll notice also The red and the yellow happen to be glowing a little and I think the green is too It's just not coming through on the camera That's because we haven't opened the pins and there's just a little bit of background voltage flowing across the pins yet When we open the pins in the rastering operating system, you'll see that those that little glow will go away So let's just go ahead and run it. It should all be wired up and ready to go now all right So let's try this Hey Cortana turn on the green light I'll send a message to turn on the green light There we go. It was that quick Let's try it again Hey Cortana Oh, that's me. Yeah, sorry. I've I've clicked when I shouldn't I've hey Cortana Or I'll just click turn on the yellow light Well now I've gone and confused her Sure I'll send a message to turn on the yellow light. All right Let's try a color that we don't have Hey Cortana Turn on the purple light I'll send a message to turn on the purple light Well, I don't know how the I don't know how good the frame rate on the frame rate on skype is But you should have seen all the lights blinking in quick succession to show that we don't have a purple light One more thing I want to try Hey Cortana Hey Cortana Oh, she heard me say hey Cortana twice My my poor little surface is I'm I can just hear the cpu burning I'm just going to click the mic You don't have to put on the red light Not Roxanne and you're not staying and that's a really lame 80s music joke For those of you youngins that was a joke about the police They were a really cool band in the 80s and you should go check them out on spotify Um, all right, so That is it for our integration demos Which leaves us one more point of discussion And that point of discussion is what now? Well, I encourage you to go check out my github Uh, it's at that address right there github.com slash camslope soper slash have your pie There you'll find my notes uh with everything you need to know I've got links to where you can get the operating systems and uh some some advice about which devices to buy and and uh Which components to buy to build these I've got all my schematics all my demos including some demos that I didn't use And all these slides. I'll also put a link to this Talk on that github so you can refer to it in the future The other thing I wanted to talk about is you should go take a look at system.devices.gpio That is a package that is currently in pre-release. It is targeted for.net core 30 It is very early in development and the api surface is very likely to change before release It's designed for all kinds of iot platforms that use gpio Raspberry pi included and it's kind of a an easy one to feature because it's so ubiquitous There's a few there's actually a reason why I didn't use system.devices.gpio it mostly works But the demo that I had where we were watching the read sensor It locked up my raspberry pi pretty consistently every time I demoed it. So, um, I ended up not using it But it is like I said early pre-release and it doesn't use that kind of hacky mechanism that I used In in the file system. It does support pulse width modulate. I'm sorry pulse width modulation So that's the ability to kind of ramp up and ramp down power on a pin So you can make a make a make leds, uh for for example You could make leds brighter or dimmer and it also supports spi and i2c Which are serial interfaces for talking to things like temperature sensors and humidity sensors Finally the team has asked me to point out to you guys that they're looking for contributors If you're uh, if this is something that you're really interested in and this is in your wheelhouse by all means Go check out their github and and send them a few pull requests So with that I'd like to see if we have any other questions Hey camp, I think everybody's afraid of asking questions. So you just literally dropped the the virtual mic here everybody's been loving it the just the demo was On point Like literally if I I'm a little bit bro crushing on you my friend just fyi Just just have that in the back of your mind while I'm saying this but like IOT demos are hard because I'm literally sweating bullets that things will not work But everything worked amazing for you, bud. Yeah, you did. This is awesome. Dang Well, thank you. I I appreciate that Yeah, everybody Go ahead I'm just gonna say so if there aren't any more questions I just want to say I hope everyone found this Informative and enjoyable and I really hope you found yourself inspired with some ideas to go implement in your own Raspberry Pi projects You can again check out my github check out my twitter You can always hit me up and I'll I'll try to help you out and and do check out the system.devices.gpio project Because that is going to be the official.net core support in the future Nice. Awesome. Thank you so much. Well, I'm camspired It's a good thing we're in the afternoon. That's right. That's right. I'm thinking that and I heard I'm too loud So I will keep it down. Thank you so much for taking the time talking to us Everybody we're going to go to a quick break Learn about functions in azure and then we'll be right back where it's jeremy our next presenter. Thank you so much