AWS IoT: The Hobbyists Guide to Home Automation | Nathan Glover | Skillshare

AWS IoT: The Hobbyists Guide to Home Automation

Nathan Glover, I love technology, I'm a maker at heart!

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
26 Lessons (2h 5m)
    • 1. Course Introduction - AWS IoT for Home Automation

    • 2. AWS IoT - Introduction

    • 3. Windows / MacOS - Setup and Usage

    • 4. Raspberry Pi - Installation & Setup

    • 5. Raspberry Pi - Configuration & Updates

    • 6. Raspberry Pi - GPIO

    • 7. Raspberry Pi - MQTT Client

    • 8. AWS IoT - Creating "Things"

    • 9. AWS IoT - Creating Policies

    • 10. AWS IoT - Python SDK

    • 11. ESP32 - Register Espressif "Thing"

    • 12. ESP32 - Create Espressif Policy

    • 13. PlatformIO - Introduction & Setup

    • 14. ESP32 - WiFi Connection Setup

    • 15. ESP32 - AWS IoT MQTT Client

    • 16. ESP32 - Construct JSON Payload

    • 17. ESP32 - Certificate Authentication

    • 18. Node-RED - Install & Setup

    • 19. Node-RED - Introduction to Nodes & Flows

    • 20. Node-RED - Raspberry Pi GPIO

    • 21. Node-RED - AWS MQTT Certificate Setup

    • 22. Node-RED - Dashboards [Optional]

    • 23. AWS Lambda - SlackBot JavaScript Code

    • 24. Slack Bot - Setup & Configuration

    • 25. AWS Lambda - KMS Encryption

    • 26. AWS IoT - Actions


About This Class

AWS IoT Core is rapidly looking to become the industry leader in Management & Orchestration of Internet of Things (IoT) devices for both the home, small business and enterprise marketplaces.

When you think about the tight integration it has with all other offerings through AWS Its hard not to see the immense benefits of managing an Infinite number of devices in the cloud.


1. Course Introduction - AWS IoT for Home Automation: Welcome to the AWS Ire. T Hobbyists Guide to Home Automation. My name is Nathan Glover. I'm a computer systems engineer who's been specializing in embedded system development. I've worked with the STM 32 SP 30 to 8 to 66 and a VR boards. I've always had a strong interest in orchestration and automation and have always been wondering, Why can't I apply that to microcontrollers? I used on a day to day basis. That's why I find eight of us. I t so interesting. By the end of this course, you can expect to have an elegant and scalable platform design. You can use all your ire teen aids being at home or in an enterprise environment. We're gonna look a having a push button that talks over the GP Io pins on your raspberry pi and then have knowed red direct that traffic up to AWS. I o. T. From there, Lambda will pick up that data and forwarded onto a slack, but that we could design that's like boat will then present a notification to you in a slack group. One thing you can look forward to in this course is very detailed instructional guides and videos on how to set up your circuits. This loss includes circuit diagrams where possible. The most important piece of equipment you're going to need is either a raspberry pi two or three and AWS free tier account in some way to interact with your raspberry pi. We're gonna use a button in this course. However, if you have a different sensor, feel free to use that. You also need some wires and leads depending on what, Since you're using optionally, we also cover the use of the E S P 32 microcontroller. So if you have one of those, it'll be great for you to follow along in those sections as well. And set that one up when developing courses I like to make them is inclusive two different title learning styles as possible. That's why I also build very detailed slides for every single piece of material that we go over. So if you feel like reading those instead of listening to the videos, feel free to do that. And most importantly, guys have fun learned stuff and build amazing things 2. AWS IoT - Introduction: it'll be a society provides a single central point. We can manage all of your Internet connected devices, be it senses, lights, an industrial control system or even your car. It promises and delivers on secure and scalable solutions for any of your ire t platform needs. On top of all of this, it also provides that same interconnectivity that you've known and grown to love about AWS and Cloud Services. Let's go into a simple example of where you could make use of AWS higher t. So you have a sensor that's reading temperature data. It could funnel that data up into eight overs I ot over common protocol like Mpudi, T H GPS or Web sockets. That information could then be routed out to a temperature control system. Onside no se. You had a smart thermostat that was able to turn itself down. If temperatures exceeded a certain value, you could set up a sensor to raid in your temperature value in out case 41 degrees. And then if he exceeded 40 degrees, you could send off a command Vyron action that would turn the temperature down on your thermostat. Not only this, but you can also trigger and process rules and actions within AWS services so you could trigger a rule when your temperature exceeded 41 degrees to not only turn the thermostat down, but also send a slack notification indicating that your temperatures exceeded the 40 degree threshold. And this is a really simple implementation. This is just to sensor devices into connected nothing about a solution like this scaled up to millions of devices aws i ity is capable of providing that functionality. 3. Windows / MacOS - Setup and Usage: this course is fairly agnostic to the operating system. You're running it on, However, there's a few things you need to know when you're running on a Windows operating system versus a Mac, and Linux is one. To get the best experience, I would highly recommend downloading and installing Get for windows from the link here. On top of that, you can also go ahead and install visual studio code and set up a free tier AWS account. In terms of the requirements for a Mac and Linux box, you'll just need visual studio code or basically any I D. However, if you do plan to use the SP 32 you should get the S code because it allows you to use clap for my own. To develop the AWS free tier has to specific limits you need to be aware off. For starters, the free tier account is only valid for new accounts and is only valid for 1st 12 months. That account is being activated. You'll be able to send 200,000 messages with AWS I A T, and with AWS Lander, you'll be up to perform one million free request per month and up to 3.2 million seconds. With the compute time per month. After your 1st 12 months, you'll have to start paying for each individual request. However, those requests are extremely cheap and won't add up to much, especially in a home environment. 4. Raspberry Pi - Installation & Setup: everybody. And welcome back in this video, we're gonna look at how we can install a copy of Roz. Be in one trial. Raspberry pi. Now, to start with, what we're going to do is open up a Web browser and navigate to raspberry pi dog forward slash downloads. Ford slash bras be in from this page, we're gonna select which version of Rose be, and we want to install or download. In this case, I'm gonna download the full version of for lesbian and not live version. The reason for this is that later on, we're gonna be using node read as a form off flow and data control service and also use of the dash boarding and that comes preloaded on raspberry and full somebody down like that's it. Now, now, I've already prevented a version of this downloaded. So what I'm gonna do is in my dad's shoulder, As you can see here, he's gonna remove that open. We have our lesbian sketch towards it. Now, what we're gonna do is we're gonna load this on 12. My Christie. God, I don't want to do that. We're gonna grab on my Christie co put it into a computer. Now, In this case, I've already got a copy on my micro SD card. You probably wind. What you gonna do is download a copy of a program called ETA. You can get that from ETA, don't I? It's cross platform. So is available in every single system you're probably gonna be using. Download the one that's applicable for you and open it up. Now, what we're gonna do is we're gonna select a image. In this case, it's that copy aroused and we just downloaded. And it's gonna make because select al flash storage that we want to flashed onto. I selected that micro stick up that Iverson said into my kapita. Then what is it? Flesh, depending on what operating system your own. You might need to talk in your password and we'll give it a little time and flesh. Fantastic. Now, once that's finished, we're gonna do is win a close off extra. We're gonna open up a terminal. You from the back. What we're gonna have to do is enable ssh by default on boot, because we're not gonna plug a monitor and in order to manage raspberry pi. So what we'll do is we'll type touch volumes boot. Ssh! On what this will do is it'll create a empty file with the name Ssh in the root directory off this SD card that we first flash rose. Being onto now, one thing you might need to do is unplugged the SD card and then re plug it back in before this will work A Z, you can see it's mounted the boot partition. So now when I run this command, I have not boot. We could actually see that that blank ssh! Fall is indeed created in the root directory off boot. Next, we're gonna computer al WiFi settings. In order to do that, we'll do something very similar touch volumes, boot. And then we create a file called W P. A. Under school suddenly can't don't come. And then we'll edit that as well. Obviously, is not going to do that. And within this we need to define a few settings. We need you to find out country and in my case, I'm a you. It's the two letter country code. Then we have to define our control interface, which is just equal to D I. Aw, the run w p a supplicant grape Net Div Update config! You got one. And now we define our actual network our exercise A which in my case, is breath craft. Why? And then l p s k which is just the password for ah network. In my case, it's cats are cool. We close self, we just save that file Now What we just need to do is eject the SD Cup because I'm on a Mac . I'll just click this button here and now. I should be good to boot my respirator by. So what I'll do is I'll unplug the SD card and I just insert it into the back slot here. Then we will do is I'll grab my USB cable now. One thing you didn't even know it is in order to power different versions of the rest reply . They require different voltage and amperage requirements. So for the version of the raspberry pi musing, which is the raspberry pi three B plus, it requires five volts at about 2.2 amps. My computer can supply that, but a lot of computers going See, you might need a war What? That you plug in in order to power. So what we'll do. Is we'll, uh, that in, You know, put it off the side and we give it a little bit to boot. It can take up to about 90 seconds. Now, in order to connect it from back. What we'll do is we'll open up terminal again and we'll type Ssh key. Jen are rests. Very hoops. Rest very pi local on what it will do is remove any entries for raspberry pi. It'll local from alum known known hosts file with ssh directory And then we will just ssh pie at Russ Berrie I don't local and we should be prompted with Would we like to say this fingerprint and I'm gonna go? Yes and then the default possible. It is just raspberry and we should now be connected to our raspberry pi. Right now in the next video, we're gonna go through installing updates and getting rpai secure by adding a our own password and also giving it information about local and time zones. Self's either 5. Raspberry Pi - Configuration & Updates: Welcome back in this video, we're gonna cover a few things. Like changing our pies, password its host name the location that it thinks it lives in. AII the time zone. We're going to expand the SD card partition. I'm gonna update the pie to the latest version if available. So let's jump right into it to start with. What we're gonna do is change Calpis. Possible it First we're gonna look into a raspberry pi by going s hpai at Rose, replied a local we're gonna typing that default password, which is just raspberry. Once we've signed in, we're gonna go suitor rest pie dash config. And this will bring up the configuration menu for a raspberry pi. We're gonna select the first option, which is change password for the current user. It will want us that we're gonna be us to enter a new password and we're gonna simply type in a new password that we'd like to set to. I've successfully changed my possible. It was gonna hit. Okay, Great. Now what we're gonna do is change the host name of our raspberry pi again. I'm gonna exit out and you basically just run raspberry pi convict again. He said, this time you're gonna select network options from within this mini. You're gonna select host name. It will warn you that you can only use asking characters a through Z or digits 0 to 9. What we're gonna do is we're gonna name our pie. What about? Because it's gonna be the order, but that measures is our house. We hit. Okay, and now that's done. Next, we're gonna set the location option or the localization options again. You will have to talk to suit over Asprey convict to get back to this menu and simply select localization options change. Look, how and what you can do is find the country that's applicable to you. Now for me. I'm just gonna leave it. It's a default that it came with because I'm happy with English. Us. But if you'd like to insult a locale for your country, feel free to do that. Finally, what I'm gonna do is expand the file system. Nor do that, I'm gonna go to advanced options. I'm going to go expand fall system, and it's respectively warning me that the far system will be enlarged on next rebuild. What respectfully does is If you have a 32 gig SD card, it'll expand that entire size out so you can use all 32 gig within the root partition off the SD card on your raspberry pi. Finally, what we're gonna do is reviewed the rest reap. I always do that when you go finish and hit. Yes, I'm just gonna clear the council. How we gonna video? We're gonna give it about 90 seconds. Also refer to come back up and we're gonna reconnect to it. Let's go ahead and reconnect or raspberry pi We're gonna run ssh pie at And they were gonna Instead of using rosary pied or local, we're gonna type the host name that we signed, which is just ordered by dot local will be prompted or whether or not we want to accept this key, we'll go. Yes, they will type in that new password that we said Fantastic and lost Step is we're gonna in Seoul the latest updates for a rosary by no, to do that, we're gonna go suit I up to get update Why? This will go through to the official repositories and check to see if there are any packages on the system that need to be upgraded. Once that's done, we can go through an upgrade. Those packages, if they exist, we could do suitor have to get upgrade. And why just stands for except all prompts. That might prompt for yes or no. Okay, so the Western packages that need to be updated once that's done, we're also gonna remove any packages that might be left in the system that we know. Look, a need. In order to do that, we'll do. Sudo have to get order removed and will show us the packages it's going to remove. We're just gonna get yes. While this stuff is not necessary, it's sometimes recommended as it will clear up things that we basically just don't need anymore. Once that's done well, clear our council. We're gonna move on to the next step. I'll see you next. Video 6. Raspberry Pi - GPIO: Welcome back, upper body. In this video, we're gonna look at the simple GP Io method that we can use to interact with real life senses or, in our case, buttons without raspberry pi. Now, what is a GP? I pin she pair stands for general important output and we can use it to send in most cases analog or digital data to and from the raspberry pi from the repair pins on the board. But what are these pins? We can actually get a list of these pins, but within hours per pot talking pin out and what this will do you bring up in us diagram. See, here are cheap Europeans and the list of which pins we actually have available in order for us to use now for this section, we're gonna be using a push button in order to interact with underpins our board. In this case, we're gonna actually interact with GPR up in 23 now GPO You might also see the term BCM pin , which stands for Broadcom pin number. The reason once called Broadcom pin number, is because the chip set that's almost a raspberry pi balls is calm. Broadcom gp I mean the same thing if you see them. So we're gonna be using the Broadcom or GP every pin 23. So what we'll do is we'll hook up a connector on to pin the eighth pin down on GPO between 23 we're gonna hit up. Can act a ground connector to the ground pin on the raspberry pi. That's gonna be the third pin on this topper here. They will take the other end of those connectors. I'm gonna place one on the input and one of the other input off I'll switch button. That's fantastic. So we've set up a simple switch circuit. We haven't got anything to interact with the data coming down that GPR line. Let's write a simple python program. In order for us to do that, I'm gonna clear the screen, and we're gonna do is going to create a new file called Buttoned Up. I will do that by going touch. We'll change directory into a documents directory and always touch button dot pie, which will create a python script. Court button then will open that file by going Nana Button took pie. I'm gonna begin to edit all cut. Let's stop by importing the raspberry pi GPL your library, which is this import GP rpai dot g p i o as g. P. I, uh that's just importing this library reference here has a simple GP I instead of having to type this out each time, we're also gonna import time because we wanna have a timer or time out on when we push that button to not rain anymore Inputs And that's called a D bounce. When you push a button, you really wanna registered one push rather than all the micro pushes that Monica While that button is still pressed and bouncing back up Well, it's to find out pin mode would do GPO dot set mode and then in the brackets Will said the mode off GPO don't bcm That's basically saying that the were using the BCM standard for our GP opens That will do GPO dot set up. And in this we're gonna define out pin, which is 23. We're going to define it as an input by going GPO dot in and we're gonna send it to be a pool up down, which is gonna be equal to GPO dot Oh, you deal basically saying that is a pull up. Um, pull up. Typically pullup resistor would be put on the button in order to hold the voltage high. That will do a try. And this is basically just safely handling everything. Was blocks going to do a truck at or try? Except so do a tried true wall. True. Once we thought this out, we'll go through it. We're basically setting that. The button state is gonna be set to the value of GPR input on pin 23. So we're gonna store whatever state that button is in, and it's going to be either a zero or one. No, because it's Piketon Zeros and ones can also be interpreted as true false. Or in our case, if the button is pushed down, then it's going to come up as false. So this is going to be triggered. Basically, when we had this pull up here, we were saying that the value was always gonna be high, except for when we push the button. Then the voltage is gonna be low. And now button state's gonna be false. So we're gonna print button pressed and then we'll have a time sleep. This is basically sleeping in between pushes. So we don't have that d bounce problem. They're gonna have an except statement, and the except statement is just gonna be GPO dot cleanup. That's basically saying that if anything in this function fails, the last thing that's gonna happen is we're gonna clean up GPS states and then we're gonna do is there's gonna go control X, which is going to prompt us whether or not we want to save these changes. We get why and then enter to save the changes to file. Fantastic. Now let's run the program. You want to do that, you're gonna go python. And in the name of the script, we just read, write or buttoned up, I I'm going into No, we go across 12 circuit. I'm gonna push the button to see what happens. And as you can see, button press comes up, we can press the button as many times as we want. We should see that message come through. You might also knows that if you spend the button or if you hold the button down, you get numerator messages as well. Basically, if you hold the button down, you should see it printing to the terminal at about 0.2 about once every 0.2 seconds. As that's the value that we set within the code. In the next video, we're gonna start looking at how we can make a simple impunity client MQ TT for client that we can use to talk to aws ira t So see in that video 7. Raspberry Pi - MQTT Client: Welcome back, everybody In this video, we're going to set up a simple MQ TD client that we're gonna eventually use to deliver messages to a name cute et broker. So let's get started. So gonna log back into our raspberry pi and start with we're gonna install the Pa Ho MQ TD client or library. We can do that through Python Pip by typing Pip Install Pablo. Thank you, Titi. Now Pip is a packaging service. That's that we can use to download python packages so apart a package here Maho mgt. Could be installed to Pathan but using pip install part m u T t Fantastic! Once it's installed, let's go ahead and we're gonna open up our button press file again by going No, no button dot pie we're gonna do is we're going to slightly alter this code in order for us to implement this partner library. So what I'll do is just below this Raspberry pi GPO import. We're gonna add a import for Pablo. Don't m q t t dot client as mq tt basically just want a reference the client as a simple MQ TT statement with your python code, we'll do here is we're gonna add a comment basically saying that this is the button GPO settle. This is a little bit code. It will make things easier later on. When we're trying to read what we've done, we'll have another comment here to say that this is our MQ TT details and we're gonna start the findings and details. We're going to find out broker address, which is gonna be equal to a test server that we can use in order to make sure that our client is working. It's gonna be on test dot mosquito dot org's there will define our client i d. And in our case, we're just gonna set to be ordered about now. You can only have a client with the same name once connecting to a broker. So it means that we can only have one client code about connecting to this test burka. What were tested shouldn't be an issue. I drinking anywhere else in the world, will be connected at the same time, but something to be aware off they will find out sub topic now substantial subscribe. And when I use the word pub, it stands for publisher the way that works is you subscribe to a topic when you subscribe to a topic. Any messages that air published to that topic will be distributed to you. So we're going to find out Subscribed topic. That's just home switches. And we call this button one. Then we need a published topic. What you gonna make the same home switches button one. Next. What we'll do is we'll find a callback function, which we're gonna use a little bit later. This is basically going to take whatever information is sent to us. It's a client and do something with it. So we're gonna define this self callback function on a message receive now death stands for define or to find function. We're gonna create a function called on message, and this is gonna have a private of plant use a daughter message. And how do we wanna handle this data? Well, let's just print it to the terminal. So what do we print? Message received. They will have a string message dot payload dot decode and we're gonna use dead. It's gonna be coming in is utf eight. They will print another message. Topic messaged a topic costs which sends for quality of service. We just want to print whether or not it is enabled. So we'll do message, dot course and message shot retained flag, which you don't need to worry about too much as we want Harrell it too much in this course . Excellent. Now we have that function to find what we're gonna do. These begin to add some more code that handles the initialization off our Mpudi T client Instance. So I have print statement just below this function that's going to say initializing m peut t client instance. And we're gonna have it print out client I d. So that we know which clients. Initializing we got to find a very vocal client. We're gonna have an equal to m q t t dot clients. I'm gonna posit our client. I d scroll down a little bit and give ourselves a bit of space. I'm gonna create another function. Oh, another comment that basically says bind function to Colback. Now, what we're basically going to do here is we're gonna take the client dot on message. So this is saying when the client received a message, we're gonna bind it toe a function. We're gonna bind this function right here. So this function will be cold whenever the client receives a message. So we just have to talk to function naming here, which is gonna be on message as well. Then we're gonna connect to broker. And within this field, we're gonna have a print statement again connecting to Erica Brooker. Address printed as well. We'll have our client dot connect Bricker address. And finally we moved on into a truck catch where we're gonna edit it slightly to battle. Had better handle the subscribing to a topic. So just above the while True, we're gonna add out client dot loot start. We're going to print the council saying that were subscribing to topic. We're gonna print the topic name. Then we'll have client subscribe. So the topic. So we're referencing the variable off the subscription topic within client. Don't subscribe. Then we'll keep l. Now, while true, we'll keep out button. But just in here we're going to add another print statement below the button press that basically says print publishing to topic pup topic and then we'll have our client don't publish. We have to reference the topic we want to publish to, and we're just gonna print Oh, published a simple string in our case. Just gonna depressed They were going to increase this time. Don't sleep, Teoh about four seconds. So we don't completely spam the instance. And then we'll have a client dot loop Stop added on to the GP. I clean up, you know, except statement. One thing I just noticed here is that we're using a single court. Ah, a single quote around out string we use double quotes is that supplies? And three Standard, however, doesn't matter too much. In this case, it will handle both. Then we'll do. Is we'll control X and hit? Yes to save again announced tester imputed client by going person button don't pie And it looks like we've been Erin. So we'll do. Is we'll open up, I'll fall again and it looks like it was down here in the client Don't publish Sorry in the publishing the topic We should have had a plus sign here to contaminate the topic name with the rest of stream. We'll say that again. I will run out function again. Now it's saying it's connecting to a broker. It subscribed hot topic and should now be ready for a button press press the button it publishes, and we get a message back, which it then prints the terminal, saying, pressed, we compress it again to test it, and it looks like everything's going great. One last thing we can do is at a level of logging to this. Except that going control, See, edit out button. Now, what we're gonna do is we need to find another callback function up here, scroll down a little bit. We're gonna go callback function on, look diff on, look, passing a client passing user data, passing the level logging and passed in the buffet. And we basically just got a print love, and we're gonna print the buffer they went to cold. This within our function. Bind. So we go client dot on look similar on message, and we just pass it the on log message function saved by going controlled ex again and present. Yes, we're on a function again. Now we should get a lot more logging. So if you were having problems before, you should now be able to see where you might be having problems. Wait the button. And as you can see, we get a lot more data back. Fantastic. Thanks for joining us in this part of the course. We've taken a raspberry pi. We've set it up. We've gotten used GP I pins and we've connected to a test NTD tea broker and ordered test. Make sure our Mpudi code is ableto work. And next videos were basically gonna have a look at setting up Amazon AWS higher T and then connecting l raspberry pi to that service. So see you in those videos. 8. AWS IoT - Creating "Things": Hey, everybody, Welcome to the first section in the course where we cover eight of us, piratey how to get started. You're gonna want to create a free tier Amazon Web services account. Everything that we're covering this course is gonna be covered under the free too. Later on, if you just do decide to use green grass, however you will need to be have a paid subscription or you only to have a credit card hooked up to the account. But everything we cover for now you can use a free tier now, I already signed in my account. So what I'm gonna do is just click the sun into council here and it will syndicate May and you presented with a list of services on this page, we're gonna scroll down. We're gonna find Hyoty. Cool. Now, once you get there, Akiko Page, you'll be presented with the get started button. Before we do that, just make sure that your region is set to one that supports both ire tea and Landau. Every single region will support Lander. So as long as your region that you select up here allows it accesses page, you should be good to go, If not feel free to use another region. The only difference is you. The data centers that serve your devices would be as close by as potentially the one that you've selected to start with. I'm gonna slick Sydney because it's closest data center to my location and we collect, click get started, not going to stop by registering a device or a thing in our case. And in order to do that, we're going to go down on the left here, click, manage, and we're gonna click thing. We want a register and new device, and this new device is gonna be the raspberry pi that we set up in the previous videos. I'm gonna click register thing and will present us with a couple options. We can either bulk registered many things or register a single thing. Just what we're learning where he's register a single thing. We're going to give something a name. Now, we're just gonna call it order. But to keep things simple as it'll, it'll match up with the client I d. That we used to know em que t t scripts from the previous tutorials. We're not gonna create a type at this point in time, but title that you do sort of group similar types of in the types of devices together into one logical group. And then you apply policies to groups were getting policies in a little bit. What keeps going down. And that's pretty much all you need for this page for now. So hit next. Now you get to your creative certificate screen from here. What we're gonna do is just gonna create a certificate and will basically do everything we need for us percent us with the certificate for health thing, the public key and the private key and also a route See a certificate. Now all you need to do is download the certificate frosting the private key and the root c A. Now, when you click it, little present will show the skip certificate. Just go. Command ISS will control us if your windows and we're going to save it to this location was close that have off and then you'll be asked to pretty much just click activate, which will activate all those certificates we've just created. And then we had done. And now your certificate should be on your local system. Anything to be created. Last thing we need to do is actually copy those certificates over to our raspberry pi. Let's do that. Now. I'm on a Mac, so I'm gonna open up, Tim, and I'm gonna go CD into the directory for downloads. And as you can see, I've got my three certificates here. And the first thing I'm gonna do is I'm gonna rename the certificate something a little bit more logical. I'm gonna call it I'm gonna move it to and I'm just gonna call it root desh, See a dot Pim, if you feel more comfortable doing this to the file browser and just opening up and renaming for you feel free to do that as long as you've named it roots. See a adult, Pim, that we were all on the same page, just interjecting quickly. We actually need to fix a problem we just introduced right now where we've accidentally saved him header information from the browser when we saved as from the browser web page. So what we'll do is we'll open up that certificate that route, see a certificate that we got. It is going to remove the excess that we've got here So we need to make sure we remove everything in this block here leaving just those five dash ins and the same at the top here . So you should just be left with that. Well, it's safe. We'll close that certificate off and quit. Now let's jump back into it. We'll close it off, and now it's copy these files across the raspberry pi. We're gonna use SCP to do this. Let's get a list of this falls again and we're gonna SCP and the name of the file. We want a copy Civil type D three and pressed. Have to order complete, and we're gonna call pl certificate through fist. Once we've talked out the full name of the thing we want toe copy, weaken Type I at and then the host name off hours by which is this order. But then we're going to do the call, the dots, and then the tilde. The total just indicates that we want to work in the home directory forward slash the doc Hugh mints. So we want to put into the documents folder and then hit. Enter. Ah, my mistake. Have to run the ssh key gin one time. Just get rid of the local off the ed. Then we're just gonna run this one more time and we shouldn't get the problem. Issue was that we had an entry for order, but But we didn't have an injury. For what? About a local? Yes. Continue connecting. We have to talk in the past, Would and we copy that across. Now, let's do the same thing for the private key. Do SCP The name of certificate, which is D three private? No, the pie at what about documents? And finally will do the route. See a So let's get this. And with their route, see a dot pen. What's clear? Terminal? We now compete all three of the certificates into the bars. Reply, So we're gonna change. We got just gonna change into the rosary. Fine. Else we're gonna go. Ssh pie At what about local? In a type of hospital in. We're gonna change directory into that documents folder, and we should see how certificates here now that we got all certificates all lined up, we continue into the next video. We're gonna look at policies now. We can use them to lock down all certificates and make sure that they're securely being used for the device were specifically set them up for So I'll see you in the next video. 9. AWS IoT - Creating Policies: Welcome back, everybody in this video, we're gonna cover eight of US priority policies and how we can attach them to our things to securely lock down What certificates of being used by which things. Let's get started. What we're gonna do is going to jump into our AWS i d panel we're gonna go to secure. We're gonna find that there's already a certificate here. Now, that was from a previous thing. I'll scroll down to policies and we're going to create a new policy. Let's give this policy and name now. In our case, we want this policy to handle the order about buttons, for example, so have already bought button policy. Now, a policy can have a particular state mental action attached to it that we allow this policy to execute. In our case, we wanted to be able to connect to start with, So I'm gonna have I t connect as one of our statements. Then he's going on here and just make sure that after here we have a client E and in our case, we wanted to be order, but they're gonna hit, allow. We're gonna hit another statement. So I know the statement and we need, you know, the action. And in our case, we wanted to be able to publish. So whenever we push the button, we wanted to be able to publish to the MQ DD topic. So hit already published and the end here. We need to replace it with a topic. Now, let's use that topic that we used in the original button to Dorel, which was home switches button one and we'll hit. Allow, then finally will hit. Create. Now that we got a policy set up, we need to basically attach a We need to take this certificate. We need to attach a policy to it. So we're gonna go back up to certificates in here where we've got out certificate way to go attached policy. We need to select a policy that we want to attach to the certificate. So we're gonna go order about button policy. Hogan hit Attach. Now, the second thing we need to do is we need to attach a thing to certificate. So in a triple dot gonna get click attach thing. And now we're gonna attach the or about thing to this policy along with the certificate. I should explain it to the certificate will attach the policy and the thing that links up the rules that are in the policy with the device. All the thing about well hit attach. Cool. Now let's click on the certificate here and then under things just confirmed that water, but is in fact attached there. Fantastic. Now we're all ready to go to start using those certificates with AWS higher t from next video. We're gonna look at some of the SD case that are available specifically the part from one to start with and how we can use it to publish data to AWS charity. So I'll see you in the next video. 10. AWS IoT - Python SDK: Welcome back, everybody In this video, we're gonna have a look at how we can make use of one of the 18 years I o t as decays in order to publish data to a diverse, higher T m Q T t. That's quite a mouthful. So let's get started. We can see here that we're gonna be making use of the Amazon Web services. I ot device sdk for the python programming language. So we're gonna scroll down and have a look what's available. Going to start with. You need to its stole package through Pip. So I'm gonna take this command here and then back onto our raspberry pi. We're gonna install this package. Fantastic. Now that that package is done, we're gonna clear the screen. We're gonna go back into the get help page. Now we're going to make use of a sample script that I actually have available to us. It's under the samples folder. We're gonna go into basic pub sub basic pub sub Don't pie. We're basically going to use this script as a an easy sort of command line tool for us to test to make sure that we are able to publish data. So we want to actually download a role copy of this. We're gonna click. Rule another top here. We're gonna take a copy of this, Ural, and we gonna jump back over to our raspberry pi and within the downloads folder here, we're gonna type w get looks, and they were gonna need to paste in that. You're ill. Oops. Okay, well, clear. And just to make sure that file is, in fact, complete your Nana basic pub sub and just confirmed that we're able to beauty and contents likes it out by pressing control. X. Earlier on, we made a little mistake with the roots. See a certificate where we saved it through the web browser and it included some header information from the browser page. So what, it's gonna remove that right now? What we'll do is we'll through a nano rooty, ate up him and then everything before this first space here we're gonna get rid of. We'll do the same here, being very careful not to accidentally delete any of the set. Then we'll save that. What we're gonna do is going to make use of this script, you know, without certificates in order to publish just a message to eight of society. So we're gonna type Python. I'm gonna expand the term a lot. Just a little bit here, so it's a little bit easier to fully What? I'm talking. We talked Python basic pub sub DuPuy. They were gonna do a backslash and hit Enter this little hours to write outcome al full length command onto multiple lines, but have the have bash running all in one line. It makes a lot easier for you to read while I'm talking it. We're gonna define an endpoint. We go, e we need to define our endpoint Now. Now, if you remember back, we could go back to a diverse societies dashboard and the understandings down here we can actually we can obtain our endpoint. So I'm gonna take a copy of this. I'm gonna paste it in here. And then what we to do is put a space backslash enter. No. Next primitive is gonna be our roots. See a paths when a type R and we're gonna talk route, see a dot pen again. Backslash enter. Do we need to find a house? Certain path? So we do see, Then we do assert which was D three d c and then certificate dot upenn dot c a t me dio backs left again Enter. Okay, this is our product key backslash again i d we define our client i d which in our case is gonna be what a but backslash t we define our topic, which is home switches button one and for message and the message is gonna be pressed and mode he's gonna be published and we should see that we're now able to publish a pressed method to that end point. So what will now do is we jump back over into the consul here and we'll go to test and then under the test field, let's go to the top. And under this subscription topic, we're gonna type the home switches button one and hit subscribed topic. And what should start seeing is the press messages coming through under the Amazon Web services? I ot platform Now, in the next video, we're gonna start to cover a different type of sensor. The E s p 32. If you have one of these available, you'll be able to make use of them and hook them up in a similar way. What we did with the press pre pie. So I'll see you in those videos 11. ESP32 - Register Espressif "Thing": Welcome back, everybody in this video, we're going to set up on E S P 32 microcontroller and hook it up to the AWS platform before we can start with that, What we're gonna do is create a new thing in the AWS. I o t, um, dashboard, that we're gonna be able to use with a new certificate with that device. Now, if you'd like to undertake this toss by itself, feel free to skip this video and see if you're up for the challenge. You're gonna be creating a new device called Micro Baht. You need to create a certificate as per the same way that we did order bought and attach it to a policy that's also very similar to the order about policy. Feel free to do that now and pulls a video. Let's give if you need to come back. If you have any problems, let's get sort of those who are still with me. Let's create a new device. Anything I should say. I'm going to call this thing micro, but now we're not going to give it any more information. There will go create certificate, noble download. I'll certificate. We'll download out product key and we'll download out route, see a We're going to save this as root c a dot pim and we have a slicked page sore CIA would not gonna tow a pen de text field. And just to confirm that you got that right, let's nano the re ta and confirmed there's no junk on the end of the file that looks good. Also confirmed that we have those certificates here, in which case we do. It's the next step For us to do it is to copy them somewhere for us to use. You can go make directory, he says. And let's copy in those files to the sets directory. We can go move the name and sit, you know, case we'll do certificate first, since we'll move the second certificate and the removed will move the root certificate just to confirm that. A what? We're gonna open up. I'll find her. Okay, so it's directory just confirmed those three of the one quick thing I should mention is that we need to activate the certificate so back on the AWS Society platform, just hit. Activate on that certificate and done to confirm that that's all complete fantastic. Now that we're done, we're gonna start to apply a new policy for that. And we'll do that in the next video. 12. ESP32 - Create Espressif Policy: Now we've created all thing. We need to assign a policy to this thing. So we have homework rowboat. So what we're gonna do is we're gonna go under secure and open up policies. We're gonna go ahead and we're gonna create a new policy. We're gonna call this policy. My crew bought policy. We're gonna scroll down and under the actions menu, we're gonna similarly put it in the i o t. Connect azo action. And under the client, I d. We're gonna put microbe odd. We're gonna hit, allow, and we're gonna add a new statement. Under this action, we're gonna happen. I o t publish again. Very similar to what we did with the raspberry pi. Except this time at a topic we're gonna have home senses. Sensor one, we're gonna select, Allow gonna scroll down. We're gonna hit create. Once you've created that policy, we're getting it back. 12 certificate. Find that certificate we just created. Click these three dots and attach your policy. We're going to select them, mockery about policy and attach it, and they were gonna go click it again. We're gonna touch a thing. We're going to attach the marker about thing and once that's all attached, it's difficult. Should be completed. We're gonna open it up. Looking up. Things confirmed that micro bots is there. And if we never get back, we should see it's no active. Next, we're gonna have a look at platform Io, which is a tool train and an extension for V s code that allows us to program for embedded devices in a very sort of agnostic way. So see you in that video. 13. PlatformIO - Introduction & Setup: Hey, baby. And welcome back to the course in this fear, we're gonna start to look at Platform Io, which is a cross platform I d eight with the Unified. The bugger that basically allows you to write code for embedded systems. Using one simple idea. We're gonna use this by leveraging an existing idea called visual studio Code Small. Do is we're gonna download that to start with basically this head to code that visual studio dot com and install the version official studio code that is applicable for your operating system. Then just open up visual studio code and you should be either presented with a welcome page or a blank page like this. Once you've got that done, click the extension tab on the left here, and what we're gonna do is we're gonna install the extension that we need, which is just a platform i o. I've settled into bark top, and it is confirming that I do indeed already have it installed. If you don't, you'll be prompted to just enable it or install it. Once it's installed, you'll just need to restart visual studio code in order for it to be activated. Once you've restarted visual studio code. If you click the little house icon in the bottom left hand corner here, it will bring up the home page for platform. Either it'll give you an overview of the version of Visual Street version of Platform, a core that's installed and the home version. What we're gonna do is we're gonna create a new project that we're gonna be using Despoil code toe R E s p 32. I want to do that. Which is gonna click New Project left on the right here. How many were gonna going to give it a new name? Now we're gonna call it expressive M key. TT publish Expressive Visit the company behind the SP 32 the ESPN 8266 and number of all the market controls we're gonna select aboard, we're just gonna top SP 32 I'll give it a list of different variations and flavors of the SP 32 microcontroller. Now, my specific one is the fire beetle at the fire Beetle sp 30 to Deal Road. And I found this out because it is just on the basically written on this trip here. Your variation will probably be written on the outside of the packaging that it came in. If you can't find your version here, uh, pretty much you'll most likely be safe by just using a standard one. I'd probably go with maybe the spark phony s p 32. You could probably even try the expressive SP 32 dead multiple as well. If you got a charity brand does a pretty good chance it will work with the vision you've got. So I'm gonna select that and next to have to select the framework that I wouldn't use develop Now I'm gonna use the Audrina framework because it's what I'm sort of used to. There are other frameworks available microcontrollers like embed yes, P I D f. Which is available for the ears p range. But for us, we're just going to choose between a and save location. I'm just going to use the default location. I'll hit finish and now this install process can take a little bit of time. Basically, what it does is it sets up the file structure and it downloads or the platform tools specific to that variation off the SP 32 the S P 30 to build tools that you need in order. Teoh generate binaries that will be pushed out to your microcontroller once it's completed . Let's go over some of the files that exist within a standard part for my project. Now the most important one is our platform. Ioo dot i and I File, which basically defines some settings related to the platform, were deploying to know it's generated the settings for us based on the device that we selected when we created the project. As you can see, a five year old 32 expressive 32 with the environment defined for these, we've also defined the framework. There's a few other things we can define we can define. For example, monitor board. We can define the Border eight that we would like to have Thekla. It'll open up. As for this microcontroller when we plug it in. So basically the border, it is the rate of speed of communication to the serial port on this device. We also wanted to find a external library that we're gonna be using a little bit later, and we can do that by talking lib tips equals and then just to keep things for the neat on the new line will type in the name of a library we'd like to use. We can do Audrina Jason at and then the version of the 5.13 point one. Now that we got these libraries to find, what we're gonna do is just test to make sure that we can indeed build this package. We're gonna do this by clicking the take symbol here in the bottom left hand corner makes the house the first time you run this it might take a little bit longer. Is we'll need to pull down everything that's required from the for the framework from the Internet. You should say success. Basically, that means that it's a prickly build the boundary that is going to eventually deploy tortillas p 32. So just hit any K to close this terminal. Now, we're just gonna write a simple blink program in order to test to make sure that we can actually communicate quickly without microcontroller. So just open up. The source may not c++ and what we're gonna do is just gonna replace all the code in set up the loop without own code. You might be accustomed to, uh, the blink program. It's It's sort of like the Halle world of embedded systems, which is gonna blink one led on the E s p 32. We did that. We could do that quite simply. But first defining a pin mode, we need to find which pin we want to talk to. We're gonna talk to, led, built in, and we gonna set it as output. Basically saying that led built in is gonna be an output pin led. Built in is the little led all natural board itself. So there's a little status led, and when we do led built in, we can actually reference that pin specifically next, we need to write a status to that pin. So we're going to do that with a digital, right? We're gonna define the pain we want to talk to, led, built in. We're gonna set it high, high meaning on. Then what we'll do is we'll have a delay delay over one second. So 1000 most seconds and they will have a digital right led, built in look, which is gonna turn the led off and then finally will have another 1000 millisecond delay we'll save the program. And then what we're gonna do is we're gonna attach on microcontroller to the computer once it's connected down the bottom right here. Oh, left. Here, we're gonna click the little era to say we want to deploy to the target. Once that's done, we should be able to see a light blink on and off on the years p 32. That's everything we need to get started with developing for the years p 32 with platform IO In the next video, we're going to implement the AWS library within this code in order to send data to the MQ TT broker saucy on a video. 14. ESP32 - WiFi Connection Setup: Welcome back, everybody In this video, we're going to implement the AWS i O t s t k within our SP 32 project and begin to send data to AWS Society. To start with, what we have to do is download the sdk for use within our project. Now, in order to do that, we're gonna take a look at where you can get access to the code for the final version. This project I've written upon my get hub at get up dot com for its large teaser for glove in four slash expressive and PTT published within this repo I've got all the code that you need In order to get this this version of the project up and running, we're gonna reference it a little bit if we dreamed access any piece of the code specifically, we need access to this folder here AWS 80 within the Libs directory. Now, alternatively, I've also create created a bit Lee link that you can use to download the sdk if you need to . That's just bit dot l y forward slash to lower case J replicate sea up against I uppercase de propagates f another case. So let's go ahead and download that now. And once we have a copy of that, we're going to extract the folder. Let's bring official studio code, and we're just gonna drop it straight into this Libs directory. Here. You need to know way you can access this folder. It should just be under your users. Dr. Documents Platform Io and then projects, then on the lips directory. We're just gonna pace that folder. AWS I o t close this off and we go back into V s code, and we should see this library is now available for use within a project. So we're gonna do is going to start to write some code that implements this. We're gonna delete everything that seemed out loop and I'll set up function to start with what's gonna delete our reference? 200 Arduino Thought h we're going to We're gonna include a diverse society head of file, which is gonna allow us to access that sdk. We're gonna include the WiFi header which allows us to access the onboard WiFi driver that will allow us to connect our SBT two to the Internet or a local wireless. And finally, we're gonna include the Arduino, Jason, that were you just brought in recently in the Libs directory or the Libs Dependencies within our platform. I don't and I file next, we're gonna define a variable that will hold the state of our later years fire. T. Instance, we're gonna take the status of the while the wireless interface. This basically stores. So this is a global very what we can access at any point going to sort of status within this interview here that's gonna give us a statement whether or not the wireless is ready to connect. We're gonna store value of tick, which we're gonna use to increment and then post out Thean PDT client when we're ready. And we're also gonna stole a number of message counts. Then we've been set up. We're gonna open up a serial connection over the board rate 115 200. I'm gonna have a two second delay. We're gonna check to see if the wireless is connected by referencing the status, uh, in relation to while is connected. And if it is not connected, we're going to print the message saying where attempting to get the s society and reference of arable s society, which will define in just one second. And then we'll take the status of wife. I don't begin passing at a reference to the S I. D. And the password again will define the positive. Just a sec. Then we'll have a delay for five seconds while we wait for everything to connect. And then finally will have a serial print line that basically says it's connected to a WiFi . Now, let's set up some of these special variables that we need to reference within our code for except, for instance, the S I. D. And the password. I want to do that. We're going to create a new file within this source directory called main dot Age Now within, man, don't age. We need a few different things. What we're actually gonna do is take a copy off this block from the get help repository on the main page. We're basically in a copy of this block right here into a file. Take a moment of pause. If you need to talk this out yourself Once is defined in the code, we can actually define our WiFi. So what we're gonna do is I'm gonna put in on my WiFi access points, which is pictograph WiFi. My estate S s I d password is cats are cool. The thing I d for my particular device is in this case, it's gonna be my crew, but then we need the client I d. That's also micro, but and we make use of thing i d later on, when we're printing out to the NPT message, we won't actually print the name of advice is talking. And then we need the n Q t for silver, which again you can get from the AWS console under the Settings menu and basically is take this endpoint here, then finally, we just need to define our topic. And our topic is going to just be home. Senses sensible. Why? And that's pretty much everything we need to do defined within this main page file. Now, in your references file back within Alexi Pappas code. So I want to do that at the very, very top up here. We're going to have another include, and we don't use the square brackets. We only use the quotes because it's a local reference within our Lives directory. It's a local reference to a library to find ourselves in, so it's inside sources. Now let's move down into just below. It is connected to WiFi, and we're going to include some code that basically connects us to the amputee tea server. We'll take that into the next video. 15. ESP32 - AWS IoT MQTT Client: have you guys welcome back in the last video, we set up everything we needed to in order to connect our a s p 32 to the WiFi. And in this video, we're going to go through connecting it to the AWS. Piety in Q t t broker up in set up here. We're going to continue writing all code. Basically, we're having in a statement that says eight oversight, he don't connect, and we're going to connect our, um, using al eight overs and cute et server definition. I know amputee client I d definition, which we defined within this main don't hate file here. And then if we are successful, we're basically going to go serial dot print 1000 cops know serial print line, I should say, connected to AWS, and then we'll have delay of 1000 milliseconds 01 2nd Now if we aren't able to connect, what is gonna print something up to comment? Console Basically saying AWS connection has failed. And just check the host address and we'll simply have a while, one which basically loop over this until we're connected. Then we'll have a delay for two seconds. Let's move down into Main Loop. Now we're going to define some logic that basically every five seconds away, going to set everything up that we're gonna be posting a message out to eight of society. Now, in order to do that, what is gonna happen if take So we're referencing this tick variable. The very top is greater or equal to 55 being seconds Tick. Then we're going to reset tick back to zero because we hit five. And just for now, we're going to define a character, right? 0 500 folds butts on the make A comment saying that will replace this shortly. We're gonna replace this with some Jason payload in sec. But for now, we're just gonna do this so we can move on to next step. And we were going to say if the aid of a society client don't publish eyes able to publish Thio Thio Amputee topic for published with the payload that we defined up here, they were basically just gonna print the terminal published message and then the payload that we've published now, if we weren't able to publish what is gonna print the message published, failed and finally at the bottom of this loop here. We're going to start a V task delay. And we can use this to basically make sure that al function ah, runs at a constant one second tick. So this logic here is what implements out take oh, increments. I'll take every one second and that's everything we need. In order to publish a payload to eight of us, I t In the next video, we're gonna look at how we can publish a Jason Payload that eight of society is able to read it correctly, So see in the video 16. ESP32 - Construct JSON Payload: Welcome back, everybody. In this final part of this video, Siri's we're going to look at how we can construct a simple Jason payload that serves hours out eight output data that we can then publish to eight over society. Let's get started. We're gonna pick off where we left off here. With this payload definition, we're gonna replace it with some new code that basically creates a new Jason object and in puts in two fields were put in the payload. And we're gonna put in the Jason. All the things I d. Now, this lines quite important because we don't know how big our Jason that object is going to be. We need a way off being able to scale it up and down. So we're not just sending a block sized of data payload to eight of society every single time. We can do this by using a buffer size where we basically take the number of Jason objects that we think we're gonna get so we can use a global function here called Jason Object size . We passed in how many Jason objects we want to use or, in our case, just payload and thing I D and it will return us a estimate of how many butts it's going to require. Then we're gonna plus 20 bucks just to be safe. And we gonna set this as al, um, out buffa size that we use later on when we are publishing out payload object. Then we're going to construct a Jason Buffer using that buffer size. And this is a dynamic Jason Buffer. So it means that we can pass data into it, and it will continue to increase in size as we prostate or in, rather than having to set the total size when we actually defined the object. Next we go instead, initiate the Jason Buffers object, and we're gonna set it to equal to the address off this route for the Jessop. So we're gonna create a new Jason object. I'm going to take the address of it. We're gonna set the root key within a Jackson object for payload equal to the message count , and then we're gonna increment message count as we go as well. So it means that all message count will be 1234 in our message and they were going to set the thing I d simply equal to the thing I d that we defined within our main dot h Then what we're gonna do is defined a new string, um, called Jason Output. Then we're just gonna simply send a string version off this Jason object to this string variable. Then we're gonna do is we're going to find a character ohr array for payload. What? We're gonna reference try rate payload, and we're going Teoh, give it the buff a size That's the same buffa size that we used up here. And what we'll do is also get rid of this payload from the top here, as we just defined it down here. And then what we're gonna do is we're gonna write that Jason output data to a child car, all right? And we're gonna give it the charlie that we want to write to in the buffer size. And then we're going to use a C function cold, Uh, a sprint. If hopes we pass it in the payload object, and we positive the, uh the output data that we'd like to put within the broad array or the character, right? Technically, so a character and by the rare actually exactly the same. Technically. Okay, cool. So now we should end up with e string payload NL. Also, he output of this trace on object within our payload but array. And then what we're gonna do is gonna pass it out. Thes payload field here. So, technically, that should be all the code we need in order. Teoh, get this. Sending data to a society was one last thing we need to do, and it involves health certificates. What we're gonna do in the next video is we're gonna have a look at how we can take the certificate that we also generated and then implemented within this code base cell. See in the video. 17. ESP32 - Certificate Authentication: Welcome back, everybody. In this final video, we're going to look at how we can integrate the certificates that we downloaded from a diverse society into our DSP 32 project in platform I o Let's have a look at exactly what we're gonna be doing now. If you open up the Libs directory, open up eight of society and open up source. We should see this AWS I ot certificates thought see file. And this you can see It's just got a bunch of X is where our certificates need to be. Now what gonna do to start with? It was organic. We're going to copy in al certificates to somewhere That's a little bit easier for us to work with. So if you recall we made a folder cold sits. Ah, that had those three certificates into it and we're just gonna place it into this source directory here. So again, if you don't quite remember, if you go to your profile documents platform, Iot projects open up, up project open source, and then we'll just paste in that folder for sets and that has all three certificates within it. Then what we need to go through and do is to start with. We're gonna do the AWS root, see a drop him. So I'm gonna open up our roots, see a certificate. I'm gonna take a copy of that entire certificate there and then we gonna open up the certificates, etc. And being very, very carefully careful, which is gonna replace everything within these reports here without certificate. One thing you will notice is we've also removed these new like actors. Unfortunately, we do need to go through and place one of these on every single line and make sure you put one on the last line as well. Next, What we're gonna do is we're going to go through and perform the same action to second certificate down here. So we're going to open up our certificates directory again, and this time we're going to be doing the pub, the public thes certificate for the device. So we're gonna open up the i D certificate but him take the content and then pasted in here . One thing I will also note is this last line here. You do not need the final trailing character there. So you just need the end. Then again, within this take your main character and save. And finally, your private key. Take a copy and then go through and add the ends. Then we'll just save that file off. And that should be everything we need, what we're gonna do. We're gonna close down all these sections on the left here, and we're gonna try compiling our code. You know what to do that. Just click the little plus we'll check button again. It should be successful. You might have noticed three errors. That's just to do with the way that was storing the strings of these variables. You don't need to worry about them, had entered to close it off. And then what we can do is we can upload the court to AL S P 32. So plug it into your system and then hit. Deploy. This person gets 10. Take some time once it's completed. Close that off and they connect. Connect to this little power cable symbol, which is basically going to kick the serial monitor on our device. It allows us to follow along exactly what's going on on the device so we can see it's connecting to WiFi connected to AWS and then in just a second. We should start to see that it is publishing payloads. There we go. Now let's view this within the AWS Iady console. We're going to bring it up. We're going to go test and then under test, very talk. Under subscription topic, we're gonna type in home senses sense of one and we going to subscribe to the topic. We should start to see that our payload is coming through within the console. Fantastic. That's everything to do with this section on the A s, p 32 how we can get a very simple piece of code uploading data over the impunity burger to AWS in the next section, we're gonna look at how we can utilize a really smart flow and dash boarding tool called Glowed Red in order to visualize some of this data and interacted with it in more interesting ways on the raspberry pi. So I'll see you in that section 18. Node-RED - Install & Setup: hasn't going. Everybody in this section we're gonna have a look at node red and setting it up on our raspberry pi in order to use it as a dash boarding and flow control tool for our i o t sensor networks. So stop with we're gonna navigate to node red dot or avoid slash dogs for slash hardware for slash raspberry pi. We're basically coming here for this one command here, which is a simple script that basically allows us to upgrade the existing version of node read that comes on the raspberry pi. When we deploy it, that's what we're gonna do. You're gonna open up our raspberry pi and ssh to it. As you can see, I'm logged into our raspberry pi and we gonna run this command right here. We're gonna be asked to make sure that we're OK with this. Is going to basically remove the existing version of No Js Version six. Replace it with version eight. It's gonna run a rebuild. So if you have any other no jesper or node more JavaScript projects on your system, just be aware that this might might cause issues, but probably not fantastic. Once that person's has completed. You should see some information. You'll see that if we point to the this location in our browser will be able to access the united Red Weapon to face. But before we need to do that, we need to run node red start. So we need to do that now. And it will let us know that we can indeed actually run at this as a service that will run at startup. Um, I'm gonna go ahead and do that. So what we'll do is we'll scroll back up here. We're gonna take this command here, so pseudo system CTL enable node red dot service. Now, in order for us to do this, we're gonna have to close out of this. So we're gonna go control be we're gonna run that command, it'll enable service, and I'm going to go CEO system CTL. We don't need to start the service. I'm pretty sure it's already running, so we can indeed we're gonna be looking for that port there. So open about Web browser here. I'm gonna go to http. Uh, what about local? And then port 18 80 and then we go, we should be presented with node bread. Uh, this is the basic panel on in the next video. We're gonna go through how we can sort of set up al first floor, so I'll see you there. 19. Node-RED - Introduction to Nodes & Flows: Hey, everybody. And welcome back in this video, we're gonna go through how to get started with Node Red. Now that we're connected to the Web interface, we're gonna go through. What flow is what notes are on some of the other, more intricate details that you might need to know about when developing flows and no dread to start with will go through what each of these parts the panel actually do. Up here, we've got import. This is a node palette. So it's a Siri's off similarly liked nodes that a group together in this case, those air inputs. These air the nodes now a node can have. Typically, if it's import node, it will be importing data into outflows. Now, flows are basically if we dragon note in, so we'll take. This will take this. These are two nodes and they can interact with each other. We can take the line here and we can drag it to the output. Then, if we hit deploy, for example, we could see that it's printing the time stamp. As you can see any changes we make, we have to re click deploy. This is basically like it's committing the changes that we'd like to roll out into production. You can see on the right here we have all deep hug panel. Any time we connect anything up to a debug output note weaken view that output here on the right, you'll be using D debug notes quite often on the right here. We've also got the information panel. So, for example, if we had a if we had that inject again, we can get information about what this new it actually does what the output should be expected from its if we double click it. We can also get some information about some more properties that this note has. So, for example, its input can be Could be Jason. If we wanted to be, uh, we could define all that within the click menu. For that note, Let's go ahead and let's create our first flow. What we want to actually be doing is we want to be taking some data from the Internet and just printing it out. In our case, we're gonna be using data from the metal weather meta whether dot com a p i on specifically location A PR, so we're gonna be passing it in a location in the world and getting back weather data off that location. In order to do this, we're gonna go back to know dread. I'm gonna drag in a http request. So this is going to be not an import. It's actually going to be a function. So what we're gonna do? So I to you basically have a look at what we need to supply. Tow it. We're gonna be making a hate. Should be request eso We probably want to supply an endpoint. We're gonna be making a get request. And euro is going to be three ap I m point that we need to be using, which is https, www dot meta weather dot com ford slash ap I for its last location and then a identify for location We want to get data from Maybe we want to get it from London, for example. That's just triple full 18 and that should be all we need to do. So then what we'll do is we are going to change this return. Time to be a pause, Jason object because we want to get the Jason data from the a p i n point and pass it off. We're gonna name it. We're gonna call it get whether Jason and that is pretty much everything we need for this node. It's all do you have done there? And we can see that we've updated the name of a node. Now, in order to trigger this to actually occur, we need input. So we'll go over to the left here. I'm going to create a new inject. Are we to connect this inject up to? I'll get whether Jason Node double click on this. We're gonna change the payload type to instead be just flow dot trigger. There's no significance this would trigger. It's just a Munich way. We can reference it later on. All of this should be pretty fine. So we'll hit. Done. And finally, we need to add a debug because we want to see what the outcome off this get request actually is so draggin a debug node and we connect the output of I'll get whether Jason into it. And then we have deploy. Go ahead and open up the debug pad on the right and then click the button. It should make the request and then return an array or a Jason Array. Jason, data off all the information gotten from that a p i n point. Fantastic. Now, in the next section, we're gonna have a look at how we can replace that functionality from the button presses that we did earlier with a node within note read. So I'll see you in the next video. 20. Node-RED - Raspberry Pi GPIO: Hey, everybody. And welcome back in this video, we're gonna go through the process of creating a flow that replaces that button script that we were in. Pathan within note. Read. Now, why don't you do this? We're gonna create a new flow. So in the top right hand corner, we're gonna go to flows. We're gonna go to add We can see that we're now going to tabs along here that we can toggle between no wonder float to We're going to go on the left hand side here, scroll down until we get to the raspberry pi palette. Now, the raspberry pi pallet comes on all instances of the raspberry pi, and it will allow us to go through and select some different inputs that we'd like to use. For example, we want to get data from a GP. I open because that's what we're doing without Parton script. So we'll drag in this note here with the output on the right and then double click it. What we need to do is we need to select which pin we wanna handle will deal with. Before we were using the GPR 23. So we're gonna select that here. We have to check the type of resistant to be a pullup resistor. And the D bounce there is perfectly fine for the scenario using we're gonna change the name to be GP Io button and then we'll hit done. Mobile studio is well hit. Deploy on What we should see is this little number down the bottom here. Now, if I go through and press the button, we should see it click to zero, which is good. It means that it's working. So now we wanna handle the button, press in a more effective way and then print the output to a, uh to a message, basically. So to do that, we're going to make you self and you know the function. So get here to the functions palette, and we're going to you get a switch. Now we're gonna open up the switch. We're gonna change the name to be button Pausa. The property is just gonna be the message, your payload, because that's gonna be the one of zero. And we going to say that if we get a value equal to zero, then we're gonna output 2.1? What this means is that this is an output. So we could actually technically have to output so we could have an output for if the value is high. But we don't really care if the button hasn't been pressed. Um, so we don't need that, but I'm actually show you what I mean, if we went one then hit done there, we'd have to outputs here that we could we could work with. However, we only want to deal with that one output here. Cool. Then we'll do. Is we'll have done here. We'll move that down here and we'll connect LG pr one, which I just realized I spelled slightly wrong. And next we need another type off function. We're gonna be using the change function. Basically want to change that zero. That's within the payload to be a message instead. Say, I'll show you what I mean. We're gonna connect up the button. Positive. Now, the data that's coming out of this button pause it right now is just going to be a zero or one. I'll show you what I mean, dragging a debug, connect out the d book, deploy and then if we, for example, press the button, we get that zero. Now, we don't want to send the number zero of the NPT. We have to do something more interesting with it. So we're gonna double click on this new started this new change. Good. And we're going to make sounds like a Justin's. We're gonna call it payload pressed We're gonna take, or we're gonna sit the value of message shot payload to just equal pressed, for example, they will have done. And then what we'll do this will fleet that line there, and we'll take the output from this hit deploy, and then we press the button and we should see the string pressed, which is exactly what we need. Fantastic. Now we're at the position where we can connect it up to eight oversight T and published this data out. So in the next video, we're gonna do just that. I'll see you there 21. Node-RED - AWS MQTT Certificate Setup: everybody. And welcome back in this video, we're gonna hook up node red toe on AWS broker using the certificates that we generated in the first set of videos. That's what we'll do is we'll drag in a new output. Which is this gonna be this M Q t T object? We're gonna double click it and we'll get this menu here first. We need to configure a new MQ TT broker. We're looking it up and they're gonna give it a name. We're gonna call it AWS Hyoty. What I bought the host needs to be that server address. So if we go back up to AWS, I t go down to settings and then we take this endpoint here and then we need to change the port number. This very important to be a three will set enable secure ssl tireless. We'll set the client I d to be order but and then we'll need to configure a new tail s config. So we're going to hit the button there and then now we need to define the location where all certificates actually stored now rather than you can upload if you'd like, But we're gonna just reference them on the raspberry pi. Specifically, Let's actually open up terminal, clear it. And we're gonna go into our documents folder and just confirmed that all certificates role that they are. Would you in l s ale so we can view them all. So we need to be referencing these three certificates here within these fields. Let's get started. We're gonna get home pine documents because that's folder there in and then in this field, we need to reference the certificate. So that's this one here. Obviously, your one will be named slightly different, but the end should be certificate dot pen dot CRT Whoops. This should go up here and then the 2nd 1 we need to do is the private key. So it's going to stop the same as with the last one. But this time for the product key, we're gonna take the private key and then the sea. A certificate is just the roots here, so it should end up looking like that. Make sure you take verify service certificate and then we'll name this eight of us what I bought so we know what we're using. Next time we try to use this, we'll hit that next we'll hit ad from here as well, making sure that we've put that TLS configuration set and then back under the top level. We've gotta set the topic that we want to publish to. That's just gonna be home switches. Button one. We're also just gonna name it. The exact same name was the topic. So we don't forget was that cross toe zero and we'll hit. Done. Now it's deploy. And if everything went okay, you should see that it's connected. That means it is connected successfully to AWS, Sire, Tea using our city figures. So let's publish a message out. We're gonna drag this to the top here. Then we're going to drag a new connected to that node. We're gonna hit Deploy Now. What going to do is we're gonna open up eight of society we're gonna go to test, and then under this topic here, we're gonna get home switches. Button one. I'm gonna subscribe to this topic. Now if we press this button, what we should see is that message pressed. Come through the constable. As you can see, it's wealthy working perfectly fine. However, it's warning us that we should be using Jason on not utf eight strings. Let's go ahead and actually convert that payload that we have with a note read to be to be a Jason Paler instead, you know, do that change this button press change to instead be a Jason object. Click these three dots here and we'll bring up an editor for us to use within here. We're going to construct Jason Payload. Well hit. Done. Well, hit Done again. Well hit. Deploy. Then we'll open up eight of s I t. And at the very top here, we're gonna clear, and they will press sell button. And there we go. We should see Jason formula data coming through every time we push this button Now. Awesome. Congratulations on making it this far. The next video is gonna be an optional look at setting up a basic dashboard within node Red Cell. See there 22. Node-RED - Dashboards [Optional]: Hi, everybody. And welcome back in this video, we're gonna look at how we can set up a basic node red dashboard. Using a custom palette city get started, we're actually gonna install an external palette. So go to your node red Web interface. Then this three lines in the top, right click it and click manage palette, go to install. And then what we can do is actually search for public pound public pallets were able to use in our case, we want to be using no red dashboard. Then you simply hit in stole. It'll warn us. Well, it is. Still, once it's complete, it'll pop up with all the various pellets when notes in that pallet business is installed. So we're gonna hit close that if we scroll down on the left here, we should see a new palette called dashboard, which has a variety of different tools that we can use in order to build a simple dashboard webpage. Let's get started with that. Now, all day is on top right here. We can now see that we've got a new tab called dashboard and if you and if you click on the top button here we had deployed first. If you click it, you'll bring up a new Web page with basically nothing in it at the moment. Basically telling us this is the node red dashboard. We need to add some you, you my notes to flow before it will actually display. So how about we go ahead and we do that? We'll go across the side here and we can see you. We can name it, whatever we'd like it to be, so we could have It's a, uh, a W s dashboard. Um, you can specify, Like how big you want things to be. How big you on the widgets to be. You can add title balls and all that jazz, but for now, we'll just leave it like that. There's also a theme option which allows you to sort of change the color in this case, working again. Keep it lite theme. Uh, leave the system fun and will leave the I believe the colors the same. But for now, we're going to just add some simple text. So the left down here again under dashboard, create a new text object by dragging in. I know it, and we'll do connected up and then double click on this. We have to define a new U I group. You are. Groups could be thought of as like the scaffolding around each of the components on your Web page. For now, you can just create a default group within a default group. You also need to you I tab so again, basically just create, create and then for a natural settings, we're gonna have it scented. So under layout, select label value that looks scented and we give it a name and key t t message. We're also getting a bit label MQ TT message. And just make sure the value format is like that message payload with two curly brackets running outside and hit done, then simply hit deploy. And then what we'll do is if you open up that your wagon, we should see some pretty much no data there. However, if we press a button, you can see that the payload is passed through and displayed within this text field here. Okay, cool not to need, but what else can we do? Okay, let's go back to no bread and let's say we wanted to generate a random number. We can't really do that. We can use an introduction, so we'll create a new inject. We'll leave this injectors. A time stamp will change its repeat into votes to everyone. Second, I will name it Random trigger. Cool. Then what we'll do is we're gonna create a new function. So under the functions tab on the left Here, we're gonna play in the random note. We're going to connect these up and double click on random. We're going to leave it as a whole number. So whole interview. And we just want the values between one and 10. We'll name it. Random num gin family. Done. Finally, we want a dashboard chart. We want to be able to chart and graph which numbers air coming up. So will score down to a dashboard and we'll check shot. We'll drag it in. We'll link them up, double click on shot and will make a few changes. We'll give the label random numbers. I lost 20 seconds. We will set the X axis to be lost 20 seconds. As we said, we'll have Thea X Axis label so we don't want the entire date because it's way too long. All we care about is more or less just two seconds since we're in the storing 20 seconds with the data. How y axis will be 1 to 10? Because that's the range for on that random numbers. Ah, interpolate. We're gonna be setting to step and we're gonna give it a name off random num chart. I believe that should be everything we need. Losses check in large points so they look nicer. You can decide which you want to use in. Okay, so just gonna use line shot, because it makes more sense. Wait, Deploy. We'll open back up a browser and we can basically just watch it. Every one second. It will select a new render number and it will chart it. You can see 37 38 39 seconds. 40 seconds. 41 2nd and then between one and 10. We had all random numbers beginning to be charted within a dashboard. So that's pretty much everything we're gonna do in terms of covering node red basics. If you want to take it a step further, you condemn splay charts from the data that you subscribe to from AWS society, which will probably cover later on in another section. But for now we're gonna jump into writing our very own chatbots built on slack. That's also utilizing AWS Lambda functions in order to generate a message that's sent to you whenever a button is pressed. So see you next video. 23. AWS Lambda - SlackBot JavaScript Code: walked this section, Guys, in these videos, we're gonna go through how we can set up and create our very own AWS slack bar that sends us a message to slack whenever we push the button or interact with data on AWS. I o. T. Now, to start with, you're gonna need to download obvious code or basically any idea you happy and comfortable writing job script code in once you've downloaded that installed in. We've probably really use this to a previous section, but I just want to make sure that you have got it installed because it's really useful. You also need no Js, which you can download from the know Jess Dog site just under downloads. Down with one. It's applicable to your system and install it once those two were installed. You have an option if you'd like to. You can download all the code from my repository, which is on get hub dot com for it. Slash Teaser for glove in a derby was Dash butler, but which will give you all the all of thesaurus code that you require for these coming sections or section just the one or if you prefer, we can go through it together, sir, I'm going to jump in to riding this code with you. Open up the s code, and what we're gonna do is create a new project. We go into a directory, were happy working, and we're gonna create a new folder called AWS Butler. But feel free to use the browser if you prefer to make folders that way. Um, but we're just gonna open this new folder. Once you have this folder open, we're gonna create two new falls we're gonna create index dot Js And we're gonna create package dot Jason. Now. We're not packaged O. J. So we need to define some. Basically the name of our package. Any dependencies. It has the version number and a description. So we're gonna go through a type that out now and this premature we need. In our case, we've named it eight hours butler, but version of one description is handles the pushing messages out of slack out of a select channel as butler. But the main isn't X address, which is thief are we're gonna run. We've just put in this line here, which basically says that if you try to run in PM test. It will throw an error because we haven't any tests. And the one dependency we have is slack bots, which is a NPM package that handles communication to ah, slack pot. So now what we're gonna do is gonna open up our index dot Js and we're gonna start to write the code that we require In order. Teoh, send messages from AWS Lambda Twist like channel. We're gonna require the slack bots library. We're also going to pulling the AWS sdk, which will be available to us when we upload this to Lambda. Now we're actually defining the slack but name and this process don't end is basically pulling an environment variable from AWS Lambda when we've got a kept it up so well defined it in the web interface later on it so that we're not putting private and secret tokens within our actual code. We did the same thing with a slack but token and finally with the channel that we want to send to. We're seeing US store of arable that will use to stole the decrypted took in because the target with passing is actually going to be encrypted with an I am encrypted token method, which we're going to in a little bit. We're gonna set up our base function, which is called Handler. That's gonna be exported. When this runs Handler is gonna be, like the main of our function, it's gonna be run. When this function gets executed, it's gonna be pausing in an event which will come from NATO. Was Landau Colback in context, But we really care about is the event in our face? Then we're gonna check to see if the slack book decrypted token and the slack boat name has been defined by default. It won't be until we've decrypted it. So this is basically saying that, you know, if they have been decrypted, if they have been decrypted, then we're gonna possum onto another function. Gonna write code purses event. We're gonna right the presses event function in just a little bit. This is quite a long line, but we're basically saying that else we're gonna store a instance of the K missile key management service. We're gonna run decrypt across it, passing in the encrypted token and saying we want to decode a base 64. Then we'll cola function passing the era and the data. If we get an era, man will print a decrypt era to console that long And then with the cold back well past the era else also basically, take the decrypt. It will populate the decrypted token with the data that plane textile to string informative asking which is going to give us the raw token decrypted Ah, Now we're gonna call process event as we did at the top. Him next gonna right the process event function, deposit In the event, the context in the Colback we're gonna create a new instance of a slack. But quote Butler bar and it needs a token, which is going to be the slack. But decrypted took it, and it needs a name which is gonna be our slack bought name. Then we'll also print Teoh console log that we've received an event we need to have a commoner. Then we'll create a new variable for the payload. And since we know that the date is gonna be in adjacent for men, we're gonna do a Jason String. If I which is going to take that Jason Data tend to a string for us, they were gonna call, but Labadee dock post message to channel, which is a function within these like bots as sdk that we're making yourself. And we postulated in the channel name we have deposited in the as user. We want to say it's true because I bought Is going to you act as a user and then all attachments are going to be a title fullback text, which we're just gonna make message received the actual text itself, which is gonna be payload. Is that cell constant? We've said here and then we're gonna define a color. Just so if anyone wants to change it, they can. And we're just gonna make it black. Basically. Fantastic. Then we also need to cold. Then were we going to close off the contact? Speckle in context are done with the data just to clean things up. And that should be all the code they actually need for us, like Bart. So finally, what we need to do is run NPM in Seoul in order to populate the node modules. Father, So do that. We're gonna open up a terminal. We're gonna change into the directory. We just read that coding. This should be the same for all operating systems. But you just need to go npm install. Assume you installed. No, Jess. In all one. You've gotten a repository of license file, but that's fine. But then if you go over into this photo here, you should see that the node module supporter has been populated along with a pay package dot package lock dot trace on. That's basically all the files we need. So now we're gonna to is we're going to Zippel this up. So we're gonna go with in Al folder, where all project falls are. This is very important. Don't sit the folder. You just want to sit the files. So just gonna select all those and compressed. Um, we're gonna rename this AWS butler, but don't zip. And if anyone's having troubles compressing, they can download this sit file, which all attached to this video. No, because that zip file we can move on to the next section. We're gonna be uploading up to eight over slander in order to prepare ourselves for running functions through it. So I'll see you in the video 24. Slack Bot - Setup & Configuration: Hey, everybody. And welcome to this video We're gonna be creating our very own slack space if you haven't already on preparing everything for slack Teoh in terms of creating a new but for us to use with our existing lambda function. So to start with, if you haven't already got a slack space that you can can sort of manage and add a P eyes and bots to you're going to go to slack dot com for its like create and create a new workspace. You know, if you've already got an existing workspace, you confined your workspace. But you find your workspace. I'm gonna be using my existing works based cold boats that matter. So within this workspace, what I'm gonna have to do is create a new Tranel, which we're gonna be using for the notifications from AWS. So many gay AWS Higher T home, which is the name of the channel. The purpose is gonna be aws i o t home automation notifications. I'm not gonna send any invites out so that we go now we've got a new channel. Next, What we're gonna do is we'll have to create a new but now in order to do that under any tad . I'm gonna go https ford slash ap. I thought slack don't come. And we're gonna want to start building a new tool. Let's go and create. And you up in this case, creating you slack out. I'm gonna call it Butler B, but we're gonna select the workspace that we'd like to deploy it to. In my case, it's that slack workspace boots that met create up. Next will bring us the basic information page for all. But if we scroll to the very bottom, we'll get to this field here. We can change the app, name and description. I'm gonna change description, too. Butler B. But or be three for short sieves, AWS coyote data. I'm going to change the color to be in nice people, and we need to add some icon data. Now. I've actually got some an existing like on that you can use. Basically, what you want to do is you're gonna go to page two bs get hub, don't come forward slash teaser for 11. Eight of us butler, but then under assets, open up. But look, But don't PNG click download right click save image. Now that we've got that image will add the icon That should say success. Then we'll do. Is we'll hit Save changes Next. What we want to do. You set up the boats permissions. So if you go to the very top off the, uh, configuration page, we're gonna be selecting a wolf and permissions from the left hand side. Then if we scroll down under scopes, we're gonna want to add a new scope, type in a message and click send messages as Butler bought, then hit save changes. Finally, we want to create a boat user to do that, scored a very talk and go under. But uses add a boat user and it will give you an idea of a display name you're able to use the user name is the important one here. I'm also gonna leave the display. Name is but Libby. But this needs to be unique across everybody, though, so you're probably going to be able to use this season name as I'm already using it. Well hit advert, user. And that should be done next. We're gonna go back to o both and permissions. I'm gonna click. Install app, toe workspace. This will prompt us with some permission saying that this boat would like to access your workspace. Just hit. Authorized. Once that's done, you'll be prompted with your oath access token. And you bought user orthe access token. This is the bottom one that we need to make sure we keep track off. And I would not lose this if you send it to somebody else, there will be able to send messages as your bought without any authentication other than this. So be very careful not to share this with anybody. Finally, we just need to add this bought 12 channel. So if you go back to Slack, what we'll do is under this channel. We're gonna go invite others to this channel in typing butler. I want your job and just click invite Butler, but should be invited the channel and you're now ready to for the next step. We're gonna hook everything up through Lambda and AWS, Sire. Tea. So I'll see you next. Video 25. AWS Lambda - KMS Encryption: Welcome back, everybody in this video, we're gonna set up a basic a diverse land of function and then upload the code that we wrote in the first video. In order to start to connect our I ate over society logic to else like Bob. So to start with from the AWS management console, we're gonna select Lambda. We gotta go create a function and just make sure that your region is indeed set to the same region that you had set for eight of society. In my case, I've been using Sydney or Asia Pacific, Sydney. Next, let's define our function. We're gonna call a function post button message Slick. The new Jess version is fine on 6.10 we're gonna create a new role from template. The role name is gonna be eight of us, Hyoty, Landau and then all policy template. We're gonna be using basic edge land of permissions. This basically will set a planned admissions on this role. Um, and then we're applying this role to this function. So we're only giving this function permission to access Landau next. Well, that's loading. We need to create a Caymus key. To do that, we're gonna go to aws. Don't amazon dot com. Just make sure was signed in and once was signed in. We're gonna go to I am. And then under I am, um we're gonna click encryption keys. We're gonna hit get started now and then we're gonna change this region down to the same region Where using Asian Pacific, Sydney for May. Now, I've actually got an encryption key is pending. Relate. Um, that was used for a similar purpose. So I'm going to create a new key that's very similar to this one. I'm gonna call it slack, but I A t token took in. Used to post to slack. That's we'll find that way. We're going next step, we'll skip tags under the key administrative Persians. We're going to select the Higher AWS Society. Landau under the key usage positions will do the same. We can view a policy here before hitting. Finish? No, that's that's done. We're gonna go back to our Lambda management console. We're gonna scroll down a little bit until we get to this code section function code. Gonna change function code to upload a zip file. I'm gonna make sure runtime is that we're gonna make sure that Index don't handle it is the main entry point to a function, and we're gonna upload all package. We're gonna select that AWS, but LaBolt and I'm going to scroll down to environment variables. And we need to have thought a few expand out the encryption tub and then enable this enable help us from encryption in transit. We're going to select the slack. But I R t token, which is the one that we just made, and then at the top here, we're gonna create a slack. But I just got token variable, and this value is gonna be that value that we got back here for the boat user with access token. So make a copy of that or paste it in here, and then we'll hit encrypt. Next, we'll make a slack, but name. We don't need to encrypt this. What is gonna make it? Butler B. But whatever the user name is for your But that was set back in the, um create a user field under slack. That's under but uses. And that's your default use names. That's what you need to put as you slept about name. Then we'll have all slack about channel, and we want to be posting to the Channel AWS i o t home, which, if we open slack back up is the name of this channel right here. Now that that's done, we're gonna hit safe. And what will happen is Philip Little code and confirmed. Everything went OK. It looks like everything's been sucked in. Okay, which is good. In order to test the we're gonna create a new test. So in the top here, we're going to select a new test event in configure a test event. Select the Hello will template and just call this event switch press within here. We're gonna create the payload. That's very similar to what we set up in No dread button I d. That looks good. We're gonna hit, create. And then now what we can do is just select that from the drop down and hit test, and we can see that we have indeed go to select notification with the paler that we just sent through that land. A function fantastic. That's are wrapping up everything that we need to do in terms of connecting lambda to slack . Now we need to connect aws, Sire Tea till Lambda. So that's what we're gonna do in the final video. I'll see you there 26. AWS IoT - Actions: Hey, everybody, We're on the home Stretch. In this video, we're gonna connect eight of us a tea across to the land of function we just generated in order to send messages through to slack. So stop with we're gonna jump into the fire T Cool Services page again. Just be sure that you're on the correct region. I've been using Sydney. Then we're gonna go under act. We need to create a new rule that we're gonna be using based on the data that's coming in. In order to trigger Atlanta function, we'll click, create rule. And it's not with distinct name this rule. Let's call it button message slack. We'll give it a description. Takes roll messages from the publishes writing to the button topic. This is basically saying that it's gonna take all of the payloads that are published to the button press topic and send it through the slack. Now, if we scroll down to the message source, we're gonna leave it on this version of SQL 16 3 2023 and now we want to define a few things attributes we don't need to define. We want to take all the payload, but we do want filter on the topic. We want to filter on home switches and then we'll just use the hash. They're basically saying that if we had saved switch one or switch to switch three, if we just use hash, it would cover all of those for us. We can also set a condition for now. We're not gonna do that. That's also an option. If you had some data within the payload that said, like value on or off, you could say condition value on. Now that that's done, we want to add an action to this. Score down and click. Add action, scroll to the top, and we want to invoke a land of function. Passing the message data configure the action. It will ask us to select a resource. We want toe klik that down and select post button message, just like hit at action that looks so good and hit. Create rule. The rule should have been successfully created. Now, if we jump back over, just like and then try to press the button on a raspberry pi, we should see that order bought sent through a notification, and I compress that multiple times and We should continue to see messages come through, but only when I press the button. Have you really enjoy this? It's been a lot of fun to make. And there's so many more places you can take this. I'm hoping to add more sections in the future in which we're gonna go through different concepts like taking more advanced sensor data and then putting them back onto the dashboard. Then no red, so hope to see you in the future and please let me know what you'd like to see.