15Min Fridays - AWS IoT Lamp using ESP32

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello everyone and welcome back to the session i hope everyone is doing well um just confirm quickly if you're able to actually hear me is my audio coming through guys quickly if someone can confirm on the chat okay that's great so welcome everyone welcome to the 15 minute friday session by aws user group hydropath we are going to do quick 15 minute sessions which includes demos so let's get started with uh today's session okay everyone just to give you a quick introduction about myself my name is faisal khan i'm the founder and ceo of a company called ecom.in uh what we do is we do digital transformation into the aws cloud uh i'm also an aws community builder and i'm a certified aw solutions architect and i also happen to be the lead for the aws hyderabad user group so once again uh thank you for joining in and let's take a quick look at what we're going to cover today okay so we are going to do 15 minute fridays which is about getting you interested in areas of aws that you have so far not you know discovered or that might not have come across for yourself we're going to do quick demos and walk through of those steps on how you can get them done i'm also going to give you some documentation or basically kind of the same steps on how you can perform it yourself and i'll also refer you to some sessions that we have along with our user group as well as other user groups that are conducting similar sessions on on iot okay so let's get started with the basics uh before we go into the demo which is just understanding what is iot um internet of things and here the things can be anything literally anything but of course that thing has to have some kind of logic that it can run like a microcontroller which can actually run logic and perform actions the idea here is to have devices that you can control remotely from anywhere uh whether whether that be you know actually performing actions like we're gonna see today in terms of using lights or something like that or whether it is you know monitoring let's say something like soil temperature or let's say you know um understanding where a particular truck is for example in your in your delivery fleet so this can be whether it is at work whether it's within community like maybe tracking buses to understand you know uh where they are and when you can actually get to the uh actual bus stop in order to get the bus so those are ideas that you can work on when you talk about uh iot and of course at the home we already have things like smart bulbs where you can actually remotely turn it off and on so we're going to work on something like that today okay so um when we talk about how all of this comes together we have the iot devices or the things on one side and then we have the aws iot service which allows you to actually use existing aws services in order to perform actions um on the devices themselves or maybe even remotely collect data about what's happening with that device so that's kind of what aws gives you in in aws iot so aws has a whole full stack that's available for you when you're doing uh iot this can be anything from data services um to to which contains things like analytics and then you have the actual control plane which is like the message brokers like mqtt etc then you actually have device software which is things like iot green grass where you can actually uh implement that actual software on your iot device what we're going to look at today is one part of this which is the aws iot core so this is kind of the original iot service so to speak so this actually gives you the basic tools in order to get started with using an iit device so what are we going to do today so we're going to do a demo setup on aws iot core which includes something called an esp32 microcontroller which i'll show you in a second and as well as we're going to use the aws iot core service in order to run some functions right let me give you a quick idea of what this is so you have the aws iot core platform and you have something called a device gateway this is kind of what helps you make get your connection working with your actual iot device so your iot device has to talk to something right so this gateway actually maintains that connection uh there is something called message brokers when you talk about uh protocols such as mqtt which actually helps you maintain the connection and send and receive messages between your devices so that's what this device gateway actually takes care of then you have the rules engine where you define what to do when something happens whether something that the device does or whether you want something the device to do so that's kind of what the rules engine is uh then you have something called the device shadow which is kind of like a an actual shadow or a ghost of the actual device so when you perform actions you're performing actions on the shadow and then the shadow is going to mirror those actions on the actual device so you're not directly perform the actions on the device you're kind of performing actions on the shadow when then the shadow kind of mirrors the actual device this helps you to maintain some state uh for example sometimes when the device is not reachable uh it kind of helps you at least perform some actions so that when the device comes online it kind of gets those actions and performs them once it's online from the shadow then of course you have the topic which is basically the subscribe and publish model which helps you connect sorry which helps you receive and send messages to your iot device then of course you have a whole bunch of other aws services which you can use so the reason we are using aws lambda api gateway and amazon s3 is so that we can actually have a web page where we can interact with the service right so our web page will basically be hosted on s3 and we will have the amazon api gateway url which we're going to use to actually open up the web page and when we perform some action on that webpage that is going to be going to lambda which is then going to kind of push a message or actually create some action on the topic and then it further gets processed into the rules engine and then you have some action taking place okay so um let me first show you exactly what's um what we are talking about um let me actually show you the device itself first okay so what we're going to look at today is uh this esp32 board this is the actual microcontroller so this is the processor which is on the board and on the board you basically have other components which is things like your usb controllers and several other controllers which actually help you make use of these uh pins that you have over here okay we have the basic power power pins that we are connected right now which is this red wire and then we have the blue wire which is actually the ground so this is the positive 5 volt and this is the ground and then you have the signal cable which is right here which kind of sends the signal whenever you perform an action now this device is the one that actually talks to aws iot okay and all of the code is actually on this and when we perform some action from um our console like the web page it sends a message to this it performs the action and the action here being that this signal wire this control signal wire which is i believe brown and dark brown in color this is basically going to send an action or this is basically going to perform an action on this item which is basically nothing but a switch it is literally a switch which turns on and off i have wires that are running uh from the switch into the actual lights that you will see behind me let me quickly show you what happens when i turn the lights on and off in one second so right now the device as you can see there's it's it's kind of on but there's no lights anywhere else which means the actual switch is off now i'm going to turn on the switch you can actually see the lights that are there behind me as well as what's happening here on the switch so i'm going to perform an action which is turning it on as you can see the switch turned on as well as the other light that you see here turned on and as you can see the light behind me also turned on so i'm just going to quickly show you how you can get this done so that you can you can perform this yourself right okay so let's switch over so this is the page where we are actually going to perform the action so if i turn this on and off like you see here behind me the lights i'm turning this on and off and because you can see it's kind of turning on and off now this is the one that performs the action on the aws lambda function which then kind of performs the action on the device shadow so what do we need here uh in order to perform this what we need is uh these are the steps that you basically need to perform you need to add the thing uh in aws iot the thing here basically being your esp32 chip then you have to configure that with certain certificates and policies applied on it and then you actually have to upload the code which includes the certificates onto your esp32 device then you have to create the lambda functions that require you to perform the actions and of course finally we have the api gateway and the s3 web page so what we're going to do here is um let me quickly kind of walk you through all of these steps so we'll need to first go into iot core so we need to first go ahead and create a policy uh so that we can create the certificates required so first we're going to secure and we go into policies and there's also already a policy that i've created but the idea here is that you create a policy for example as esp32 demo and then what you do is you go into advanced and then you set up your policy here now what is the policy i'll just show you that over here so this is kind of the policy that we are going to use uh this includes what are the permissions that the device needs all right now if this is the first time that you're doing this uh i wouldn't advise you to kind of fill in all of this information rather you know do a star which is iot uh star on on the resource right now this is going to require the region and the account id but as an example you just copy this and put this in here and you just create this right i'm not going to create this right now because it needs to put the account id in the region okay so once this is done you basically need to create your device or the thing right so you will go to manage and you'll go to things and i've already added one here again but the idea here is that you create a thing okay there is actually a better way to do this if this is the first time you're doing this we'll go to onboard and we'll go to get started and you have the option to onboard a device over here so let's do that and get started now there are several ways you can do this this is just a guided wizard right which helps you do it very quickly and then you go to linux and select python next and then you give your thing a name in this case i'm just giving it this name and i go next and you need to download this because this has the certificates that you need to install on your esp32 microcontroller so that it can actually talk to aws otherwise you know you're not going to have a secure connection you're not going to make be able to make changes right so you'll need to download this uh i'm not going gonna do this right now because i've already uploaded one uh once that is done you basically go into your things you go into your esp32 and you go to your certificates and then what you do is you kind of apply the policy that you just created onto the certificates right so you'll go to policies and you'll go to actions and you'll go to attach a policy right simple here once you uh select attach a policy then you will just select the policy that you need to attach and then attach that particular policy okay so that's pretty much it on the console itself uh because when you do the get started an onboard device it does create a lot of things that are normally what you would have to manually do but it kind of sets up everything for you right including the i the topics uh that you're going to use for uh sending and receiving messages so that's on the iot side right uh the next part is to actually upload the code into uh your esp32 device right now as far as the code is concerned uh this is kind of what it looks like now um the first thing is the uh file that you get from aws actually contains some certificates like i mentioned because it needs to communicate securely so you kind of put that information in here you have the aws root certificate you have the device certificate as well as a private key that is there in the package that you downloaded when you created the aws iot core you of course also need to configure your wi-fi credentials as well as the iot endpoint which you can find inside aws iot core so this is the file that is going to use in order to make the connection and this is the file that has the actions that it will perform so the first few actions are basically subscribing to a topic and getting started and initializing the wi-fi right and once the wi-fi is initialized uh then it starts to listen uh it starts to listen for messages right and that's kind of uh what it's doing over here it's listening to messages and whenever we send a message or update something it kind of performs that action okay now once you have all of this code you basically need to kind of upload it which is basically this button here if you click on it it kind of uploads that code onto your device now i've already done that so i'm not going to redo this right now on my device now once that is done the next steps are basically to create your api gateways and the lambda functions so uh i'm not gonna show you how to create the api gateway functions right now uh because i've already set it up and it takes a long it kind of is a few steps but i'll show you one that is already set up right so let me just open that up quickly okay so i have the apis over here which is the iot lamp api let me just switch over one second okay so here's the api that's already set up right so you have the aws iot lamp api this has the shadow state that you're going to create as a resource and then you have the get option and the post option right now in the get over here you can see that in the method request um over here right now it is okay one second if i go to post sorry in the get request if you see the integration you can see that the integration is with lambda function right and there is a particular lambda function that it's actually going to invoke when i try to get the information same with the post you can see that it is integrated with a lambda function and what are those lambda functions i'll just show that to you as well so there are two functions which is uh it checks the status because if you see on this page i can check the status here right so when i hit check status it says it's on and as you can see it's actually on right now and if i turn it off as you can see it updates the status so it's actually checking the shadow not the actual device but anyways the shadow gets updated so these are the two functions one is to actually update so when i click the button to turn it on and off it's actually performing this lambda function and when i uh check the status it's basically doing this right so the update function this is basically the code for the update function uh i will show you where to get all of this which is you know the update the shadow status check as well as the update function right and once we have these integrations done and we have the file which is the html file which is basically this file that is uploaded into the s3 bucket and whenever i use the api gateway url it is basically going to open up the html page on s3 and if i check the status right now it's off and as you can see i just turned it on again off and on okay so uh where can you find this you can actually find this um i'll i'll be posting the link for you but basically there is a workshop which you can use on the aws documentation which is the using esp32 right so these steps are a bit you know here and there but if you're doing this for the first time this is what you follow you actually going to get started guide and you follow this step by step now there are other things that you can do which is uh creating something called an iot button where you know it's basically a touch touch button let me just show that to you it's basically kind of a touch sensor that you can use right but what we are doing is this one so you can actually find all of the steps that i just mentioned over here on this one all right um what i want to do is if there is anyone who's actually listening in right now you know i'd like to give you this link so that you can actually try pressing this link and see if it works for you and see if you can turn the lights on and off for for me right over here right so um if you are in the group the whatsapp group uh please ping me or if you're also in the discord chat just ping me and i'll try to give you this link so that you can perform the function for everyone else let me quickly ask if there's any questions that you have if you have any questions please go ahead and post them in the chat okay so no questions so far um if you do want to try this out which is turn off the lights on and off over here i'll try to give you the link on the whatsapp group and i'll just show you live when that happens so i hope this session has been informative for you we do have a bigger a longer one-hour session that is actually being conducted by one of the other aws user groups which uh the link i will be posting in the uh information for the video so do have a look at it after an hour or so okay so i hope you enjoyed this session if you do have any questions uh please drop it on our chat groups which is on discord as well as in the meetup or even on our facebook group i hope to see you in the next session for 15 minute fridays we'll keep you posted on what the topics are see you soon and thank you [Music] you
Info
Channel: AWS User Group Hyderabad
Views: 7,391
Rating: undefined out of 5
Keywords: aws, iot, cloud, hyderabad, ecomm, faizal, awsughyd, aws user group, aws group, aws iot, esp32
Id: 4hdA3XSb3-A
Channel Id: undefined
Length: 22min 11sec (1331 seconds)
Published: Sat Jul 24 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.