Scan QR code to Send WiFi Credentials | No Hardcoding | ESP32 Projects

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so one common thing that every iot project needs is the Sid name and password of the Wi-Fi router to make it talk to internet and generally we used to write those Wi-Fi credentials inside the core itself and then later on if you need to change the Wi-Fi credentials we need to reprogram the esp32 board which is a hectic task in itself and when you start selling those iot projects the tasks become really challenging as you need to program all those projects based upon your customers Wi-Fi credentials and when later on the customer wants to change the Wi-Fi credentials while it's an impossible task for them if they don't know coding well for all these problems aspressive systems came up with an amazing solution called as Wi-Fi provisioning so in this video I'll be guiding you how to provide those Wi-Fi credentials wirelessly via Wi-Fi or ble using expressive systems mobile applications well this is going to be really useful learning for your entire iot journey and if you are excited enough well do hit the like button right now and now let's get straight into it this video is sponsored by LTM which is a PCB designer based software company now in is not just another PCB designing software rather it's a world class and award-winning PCB designing tool that has some features like Advanced interactive routing with auto completion any angle routing bus routing face and line tuning follow me more and much more which makes it an ideal choice for PCB designing by a lot of companies along with this they do also have LTE 365 that not just covers the PCB designing part but also helps with design sharing via web sharing designs to Mechanical team for product design centralized cloud storage and a lot more and along with all this they do have a very useful search engine made just for electronic components called as octopart using octopart you can search for any components and you will be able to compare its price and availability around the globe not only that you can also get the details about the components like its specifications and data sheet all at one single place so LTM provides everything to make your production task a lot easier so do try out all these Services right now as you'll be getting a free trial version by just clicking the link manager in the description happy making so now if you use ESP Rainmaker you must be aware about the Wi-Fi provisioning in which we scan the QR code shown on the uh what you can say serial Monitor and after scanning the QR code through an application we are able to provide the Wi-Fi credential through the app itself now the same process will be following here in this video but this process will be useful not just for Rainmaker but you can use it for any of your iot projects with any of the iot platform so for that first of all we'll open the Arduino ID and we'll go to files into examples and here we'll be opening this example called as Wi-Fi provisioning okay so I'll open this example code and this is that example code that will help us to do all those provisioning tasks okay so I'll go through this code line by line and explain you each and every line of this code so first of all necessary libraries Wi-Fi provisioning.ash and Wi-Fi dot h after that here one line is commanded which is really important okay so you can uncomment it if you want to do the provisioning via Wi-Fi okay so by uncommenting this the ESP board will create an access point you can connect to it and then you can provide the Wi-Fi credentials and if you comment it out this will still work but it will work via ble and not Wi-Fi okay so this is that line and don't worry I'll be testing both the methods like the Wi-Fi and the bla in this video so you'll be come to know each and every step for both uh you know Wireless Technologies okay after that here a couple of credentials are provided so here first of all we have pop which means proof of possession which is kind kind of a pin that we need to provide while provisioning so next is service name which is the name of the device so it will be accessible with this device name to all the mobile applications okay now you can change this name but make sure your name should start with provisioning underscore okay this is the default thing which the application looks for so you can write out the name as provisioning underscore techy SMS and it will work okay so let's keep it as one two three only after that service key is written as null and the reset provision is written as true now what is this reset provision so when it is provided as true it means that when you reset the ESP board it will erase the Wi-Fi credentials it received okay and if you want that Wi-Fi credential to be stored even if you reset the board then you have to make it as false okay so I'll make it as false because in our iot projects even we reset the board we don't want the Wi-Fi credential to be erased we want to stay them in the non-volatile storage okay so I'll keep it as false after that here is one necessary function kind of a callback function you can say which is system provisioning event I will discuss this function later on first let's complete the setup part of the code so in the setup part first of all the serial beginner DeLeon 500 pretty common then Wi-Fi dot on event system provisioning event so we are assigning the Callback function with this uh you know line of code after that here we have couple of if condition which will decide whether it is a ble provisioning or a Wi-Fi provisioning okay so if it is a ble then this function will be called if it is based on Wi-Fi or soft AP this function will be called and accordingly we'll be printing the bleqr and Wi-Fi QR based upon the condition we have provided okay so that's the basic setup part the loop you can see is completely blank which is a great part so this code is not like a stuck in between it is running in the background and in the loop you can run any of your tasks that you want that's a great part of this code okay so now let's see the system provisioning event and let's see what's its task is okay so here we have a couple of cases okay switch cases So based upon the specific condition a specific case will get satisfied for example once the Wi-Fi board is connected it got the IP address then this will be getting satisfied and will be able to see the current IP address assigned to our board then in case it get disconnected this will be satisfied and will be able to see this data on serial monitor in case the provisioning starts so at the time of beginning of provisioning this will be satisfied we'll be able to see this much line of data on the serial monitor so why I'm explaining this is like you can change this thing like according to your you know application okay if you want to send some data to the wireless device you can write down the code here and it will send the data as well okay if you want to change whatever it is printing on the sale model you can do that as well okay so moving ahead we have this event Pro provisioning credential so once uh this device receive the credentials from the mobile application this case will be satisfied and will be able to see the Sid and password received from the mobile application in case the provisioning gets failed due to any reason this will be printed okay and in case the provisioning gets successful like the credentials are correct and the board is getting uh gets successfully connect with the internet this condition will be satisfied it will just print as provisioning successful and at the end like when the provisioning is ended it will just print out as provisioning ends okay so all these things will be running in the background and as soon as any event occurs we'll be able to see the corresponding response on the serial monitor so let's just straight away upload this code and let's see everything in action but before uploading it to make sure one thing which is so you need to go into tools first of all to select the board as esper Dev model after that in the partitions came you have to select this as huge app and after that you need to select the right com port and then just hit the upload button I already connected my esp3 to board with my computer and now let's just wait for the code to get uploaded now in the meantime let's have a look over the mobile application so when you open the Play Store and App Store and search for ESP Pro on to the particular application you'll be able to see two results one is the ESP ble provisioning and other is the ESP soft AP provisioning okay so as the name suggests the first one is for providing the credentials of ibele and the second one is for providing the credential via soft AP now in this video I'll be showing both the demo so I installed both the uh application on my smartphone first we'll start with the ble provisioning so I'll open this application okay so on the computer the code is all successfully uploaded I'll open the serial Monitor and just maximize this window I'll reset this board and as you can see begin provisioning using ble and we also got a QR code now this QR code is not clear so we won't be able to scan it using our smartphone but what happens is it is not clear only in these Arduino IDE serial model but if I open some some other ID maybe let's say thorny IDE and if I select the right com Port here and if I reset this board as you can see I'm able to see the QR code which I can scan through my smartphone so we're coming back to our smartphone so here we can click on provision device and now we need to scan the QR code here so I'll scan the QR code and it automatically started uh connecting to that bleed device okay it says connecting to device and we got connected with our esp32 board now in case if you don't want to scan the QR code okay and if you do this process without QR code well we can do that as well let me show you that process I'll click on the cancel button I'll click on provision device and I will click on I don't have a QR code in this case it will manually search for the ble device okay so as you can see here is a ble device Pro underscore one two three I'll click on it and now I need to provide the pin or pop which we have assigned into the code okay which was by default abcd1234 so I'll click on next and now I'll be able to connect with my esp32 board so there are two ways either you can scan the QR code or you can provide the pop or the pin and you can manually connect it okay so now we are ready to uh you know provide the Wi-Fi credentials to our esp32 board for that you can click on join other network and give the Sid name and password of your Wi-Fi router crosstalk everything and click on the connect button and now on the serial mode as you can see I got the credentials and it got connected with the internet or the router we can say and it got its own local IP address as well after that it printed provisioning successful and in the end it printed Province ends okay so that was the process of providing the Wi-Fi credentials via ble now let me show you how to provide the Wi-Fi credentials via soft AP or Wi-Fi okay for that I'll go back to the code I'll uncomment this line and let's just click on the upload button okay so it's throwing one error so what I'll do I'll manually delete everything related to B Ali and like I'll keep everything related to Wi-Fi here okay let's just do that manually okay seems pretty much good now I'll click on the upload button and now let's test this provisioning via Wi-Fi so till the code gets uploaded let's go back to the App Store and here this time you need to download this ESP soft AP provisioning and you need to open this application so we have two different applications for two different Wireless Technologies okay so on the computer the code is uploaded I'll open the serial monitor I'll maximize this window I'll reset my board and it says begin provisioning via soft AP this time again it generated QR code which is not properly visible but let's just uh you know connect it manually okay so I'll click on provision device and I'll click on I don't have a QR code now here I'll click on the connect button and I need to manually connect my smartphone with the Wi-Fi you know access point or the soft access point created by my ESP board which is provisioning underscore123 after successfully connecting to it we need to provide the pop or the pin you can say click on the next button and now we are good to go to provide the credentials I'll click on join other Network provide my Wi-Fi credentials quickly cross track it and click on the connect button on the seat reminder we received the Wi-Fi credentials and uh yeah it got connected with the router it got it IP address it says provisioning successful and it says provisioning and okay so that was the same process but this time we did it with the Wi-Fi access point okay so through this uh you know Wi-Fi and ble provisioning you can provide the credential without hard coding it inside the ESP code so that was a basic example code but now let me show you practically by implementing this a particular line of code in a practical working project let me show you so now to show you how you can use Wi-Fi provisioning in a practical working iot project I took an example of amplitude client particularly working on Adafruit IO dashboard so here's the Adafruit IO and I am I will be publishing the data to the feed called as temperature okay so let me explain you the code like how I indicate that provisioning into the existing iot core so first you need to provide the Wi-Fi credit oh sorry necessary Library pretty common then here I have introduced one new variable called as Wi-Fi connector initially it is set to zero okay so what am I doing here is as soon as we get the Wi-Fi credentials I will make this Boolean variable as one until we don't get any Wi-Fi credential it will be a zero value only okay and this Boolean variable is used inside the main Loop so the Dig is the main Loop so here is the main Loop and here what I did is I just provided one condition that if Wi-Fi connected is true then and then only you need to run all the internet related tasks else you just need to print as waiting for Wi-Fi okay so this is what I have embedded here and later on I do have embedded one more Logic for resetting the Wi-Fi credential okay so earlier we have seen how to provide the Wi-Fi credential to the board but in that example code we were not having any logic to you know manually reset the Wi-Fi credentials in case we generally need to change the Wi-Fi credential okay so I have provided logic in which you just need to press and hold the boot Button or the gpio zero so it will print as a reset button press and in case the reset button is pressed even after 5 second then it will print as a resetting it will reset the Wi-Fi credentials and it will reset the ESP board and it will start once again okay so that's how you can manually or forcefully reset the wifi credential and enter the new one okay so these two Logics are embedded here in this code rest of all the thing is same in the code I will provide this example code in my GitHub repository for your reference okay so I have already uploaded this code so I'll open the serial monitor here I'll maximize this window I'll reset this board and let's see what happens okay so it just printed the QR code and now as you can see it is just waiting for Wi-Fi and it is not doing anything okay so now I'll grab my smartphone let me just start the screen recording on my smartphone okay so here I'll open the ESP ble provisioning and I'll click on provision device I don't have a QR code let's wait for our device name here is the device click on next and let's enter the Wi-Fi credentials after that just click on the connect button okay so it received the Wi-Fi credential and let's just wait for it to connect okay it got connected and now it also connected with mqtt as well it says provisioning and so that's how we have provided the Wi-Fi credentials and now let's just see if this code sends the impurity data or not okay it says sending temperature value as 0 and it is printed as okay let me just check on my uh dashboard okay so here it is 17th of August 8 44 PM okay we got a new value as well so it is you know sending the data via mqtt which it was previously not happening because it was waiting for Wi-Fi okay I got a new value as well and now let me show you how you can erase the credentials so you just need to press and hold the boot Button on your espg board or the GPS 0 you can say and as you can see reset button press let's just wait for five seconds and yeah it erased the Wi-Fi credential it has it restarted the ESP board and now it is again waiting for Wi-Fi so now we can provide the new credentials so that's how you can easily implement this wi-fi provisioning a logic in any of your iot projects how was this learning according to you if you genuinely allowed this learning what a value out of it well don't forget to hit the like button and share this video with your friend who is struggling to you know find this kind of logic uh to be added in their iot projects or products so yeah that was it about this video I will be implementing this Wi-Fi provisioning in my upcoming project which is a very interesting iot project so make sure to subscribe our Channel our channel to watch watch that upcoming project is and yeah that's it about this video and I am the in this video here and now it's just very next video and they'll explore learn share with me techie SMS [Music]
Info
Channel: techiesms
Views: 13,767
Rating: undefined out of 5
Keywords: techiesms, electronics, electronics projects
Id: JYtDibqJMs0
Channel Id: undefined
Length: 16min 0sec (960 seconds)
Published: Sat Aug 19 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.