ESP32 Bluetooth Low Energy (BLE) #ElecrowMaker

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello magicians say good afternoon good morning good night good evening whatever time is there for you and again today we are here to learn something exciting and really something new just let me quickly see if i am live on youtube tonight yes i am live on youtube so we are good to go and we can go ahead for today's section as you are seeing that i have two years fees today and you already know the subject for the day today it's really using esp 32 so today we will understand what is ble how do we implement ble in our esp32 okay so let me share my screen with you and let me show you what all i have for you today okay so here is the screen in front of you and this is the document that i will be covering today esp32 bluetooth low energy ble so magicians and if you have not subscribed my channel please do that and share the channel for the benefits of others if you need this document or the code that i have used in the session if you need that let me know uh let me know in the comment section of this video or ask me in my facebook group or connect me in my whatsapp or any number is there in the description of this video so okay magicians without uh any further delay let's get started and understand what is ble and how do we implement uh ble in our esp32 so we will be implementing ble in both the esps and one of the esp will be used as bna server and another will be used as bi client or you can say the bld scanner okay so let us understand what is ble and how it is different than the classic bluetooth so today's aim is understanding bluetooth low energy and implementing esp32 as a ble server and ble scanner so we have we will have two esp's one will be acting as ble server and another one should act as ple scanner the esp32 comes not only with the wi-fi as we already know we have already been using the wi-fi feature of our esp32 so it doesn't come only with the wi-fi but also the bluetooth as well as the bluetooth low energy so bluetooth is uh classic bluetooth and the bluetooth ble is something new that we have with our esp32 let us understand uh first let us understand what is bluetooth low energy or ble understanding really bluetooth low energy blue ble for short is a power conserving variant of bluetooth ble's primary application is short distance transmission of small amount of data unlike our traditional or classic bluetooth where we pair our two uh devices and we have a continuous connection or continuous communication between two ble devices one sends the data and another receives the data and continuously we have a connection between two classic bluetooth devices but in case of bles the case is something different unlike bluetooth that is always on ble remains in sleep mode constantly so this is the biggest difference in the ble devices when there is a communication ble communication in this scenario we do not have a continuous communication unlike our classic bluetooth most of the times it remains in sleep mode except for when a connection is initiated so as soon as some connection is initiated that time it wakes up otherwise most of the times devices are in the sleep mode that's why it's called power conserving variant of bluetooth so if a device is not always running or not always in the connection mode then definitely that device is going to save the energy save the power so this is what exactly happens with our ble devices and these devices are generally used to send small amount of data so you can consider this as a device one already have ble enabled and this is the device too which is already also have ble and we use a small amount of data that you are seeing that a data transmission is happening between two devices these bl devices additionally ble supports not only point-to-point communication like we are saying if we have two devices and we can have a point-to-point communication between two ble devices this bled one this ble mechanism not only supports this one-to-one communication or point-to-point communication it also supports broadcast mode or and the mesh network where more than one ble devices can communicate with each other and they can form a mesh network okay ble is suitable for applications that need to exchange a small amount of data periodically running on a coin cell so as you are seeing that it is uh they are real devices are running on just on the coin cells right so they are it is that's why they are very energy efficient they they conserve the energy and they just uh transfer a small amount of data as you can see like a sensory sensor in some kind of sensor data can send or or any other information we will see as soon we will see what information that we can send from the bi devices but just remember that they just need to exchange a small amount of data periodically for example ble is great used in healthcare it is greatly used in healthcare domains fitness tracking beacons security and home automation industries where one device is sending a small amount of data that do not continuously periodically that's why these ble devices nowadays are being hugely used in all these applications like health care fitness tracking weekend security systems home automation systems take a look at the table below that compares ble and the bluetooth classic in model i have uh given a small difference between the classic bluetooth and the bluetooth low energy ble so you can you can see a basic difference between these two in this table so really just uh just let's look at in couple of parameters if you see that ble is actually optimized for short burst of uh data transmission while in our classic bluetooth we have a continuous data streaming or continuous data transfer now for both the ble and the classic ble they both run on the same frequency band 2.4 gigahertz ism band so as far as the frequency or the radio frequency is concerned both uses the same isom band 2 for 2.4 gigahertz uh if you talk about the channels so the channels are same but they are somehow grouped differently in ble so if you if you will see in ble we have 40 channels with two megahertz specific spacing uh while in really classic bluetooth classic we have 79 channels but one megahertz spacing so these are some couple of uh parameters and um if you will talk about the network topologies the ble supports point to point as i already informed it suppose it it supports broadcast as well as mesh while our bluetooth classic it supports point to point which includes piconet as well okay and here you can easily see the data rates between the ble and the classic ble and the maximum tx power you can see between ble classic ble and sorry the ble and the bluetooth classic okay now let's try to understand what are the ble server and the client now with really low energy bluetooth low energy there are two types of devices one is the server another is the client the esp32 can act either as a client or as a server so if you have an esp32 you can implement this esp as a server as well as a client or rather ble client or the ble server now who is the server what is the purpose of the server let's see the server advertises its existence so it can be found by other devices and contains the data that client can treat so it's something like you can imagine a server like your fitbit band where your band your fitness band which is when it is paired to your phone in that case your band is sending some data to your mobile phone in this case the your fitbit band or the fitness band which is acting as a server or it is advertising some kind of data which our mobile phone is trying to receive it in this case our mobile phone will act as a client and the fitness band who is serving the data who is sending some kind of information about uh about the gadget or about our health so that information in that case that fitness band is can be can be used as a ble server and who is the client the client the one who scans the nearby devices as i explained in this case in our fitness band and the mobile app or in the mobile case our mobile i will act as a ble client who will scan the nearby devices and when it finds the server it is looking for it establish a connection and listens for incoming data so it's the same case whenever our mobile phone is searching for some kind of data or searching for some server and as soon as it finds a server or we can see when our mobile phone finds uh the fitness band which is acting as a server as soon as it finds it it tries to connect it and it start listing and the data which can come from our fitness plan this is called point-to-point communication so here you can see this is the server or in our example case that we are discussing the fitness band is the server who keeps on saying i am here i am here and this is the client in our case of a mobile phone the application who is trying to connect to some of the server who is uh actually broadcasting or advertising its existence so now our mobile phone can easily connect to this fitness pad so this is now this is a high level of example for ble server and the ble clients hope uh you you got an idea what is the ble client and what is the ble server if you still have any confusion or if you still have any doubt let me know uh i can take offline and then we can discuss more or for the phone or you just ask me in my whatsapp okay as mentioned previously ble also supports broadcast mode and mesh network what is the broadcast mode the server transmit data to many clients that are connected so this is the broadcast mode so in this case the server will transmit data to many clients that are connected to that and in the mesh network all the devices are correct this is a many-to-many connection so this is the basic difference between the broadcast mode and the mesh network so now let's uh before before moving ahead let's try to understand uh get because this is the important terminology that we will be using in our further discussion get stands for generic attributes it defines the hierarchical data structure or you can say a metadata that exposed to connected to bla devices however ble devices should be connected how should they uh communicate what should be the protocol so all these things will be governed by get or generic attribute generic attributes actually defines a data structure which will be exposed to the how the ble device will be connected that means get it defines the way to bla devices sent and receive standard messages so it's not like any vla device can or a server can send data or in any format or it can send data with any data structure it's not like there should be a fixed data structure there should be a fixed metadata structure and that data structure is governed by the get understanding this hierarchy is important because it will make it easier to understand how to use ble and write your own applications ble programs or uh the ble applications are not uh pretty straightforward or they are not simply sending and receiving programs as we have been doing in our other sensor programs while uh doing ble programs or bl application we need to uh actually consider a particular format uh and we need to follow the gad standard or the get um or the gat way that the ble devices can communicate so first of all let's try to understand uh what what is the what is the basic data structure or basic block for a ble device or a ble service so first of all as you are seeing here i have shown here a profile service characteristics you are seeing some kind of jargons here right so don't don't worry about that let's try to understand one by one so that you have a pretty good idea what are all these things so first of all let's try to talk about ble service so let's talk about the service the top level hierarchy is a profile as you are seeing that for any ble device we need to maintain this kind of hierarchy the top level hierarchy is called the profile as you are seeing there this is the profile which is composed of one or more services you are seeing that this profile here and it is composed of one of the service one service but this can be composed of more than one service also usually a real device can contain more than one service just for example purpose i am just showing one of the service that a ble device or this profile has in our case [Music] and then you are seeing every service again has more than one characteristics i have two characteristics here every service contain at least one characteristic here i am showing an example with two characteristics but at least one service should have one characteristic or can also refer some other service also a service is simply a collection of information like sensor reading for example so what is service actually service is nothing but it's a collection of information what kind of information this particular bl device is going to give me this is what defined by a service like if a ble device is giving me some sensor data then we can say that the sensor reading is a kind of service that this bla device is providing me or the temperature data or the body heat so all this kind of information if the bare device is providing me then we can say that this bl device is providing this kind of service they are predefined service for each type of data defined by the sig there is a group called bluetooth special interest group that they have defined uh several types of services that a bl device can provide like a battery level a device can a bl device can provide a battery level like when you connect your fitness band to your mobile application you may have observed that your mobile application is able to show or indicate the battery level of your fitness band right so in this case our fitness bandage is providing a battery level information or battery level service you can say to the mobile application so in that in that case our fitness band has this kind of service the battery level service similarly it can have blood pressure uh it can have a heart rate or weight scale so all these are kind all these are kind of predefined services uh that a bla device can support and all these predefined uh services are pretty much maintained by sig which is the bluetooth spatial group special interest group community and if you want to see what all services they have defined uh a bld find all the predefined services for a device you can visit this link let me show you the link so you can have a high level of idea what all services a ble device can have so if you will go to this link you can see there are a lot many devices you so you here you can see uh the profiles you can see hands-free profile let's try to see generate access profile so here in this pdf you can see what all uh generally access profile they have defined like pairing modes pairing hash something like that okay so or if you want to check some health device profile let's try to see if you find something useful in this yes so like as you are seeing that the data type is pulse oximeter so this provides the health informatics and blood pressure monitor for this they have the code is defined like this blood pressure monitor the code is this and uh it is again the health informatic a personal health care device device specializing specializable pressure monitor these these are different kind of services uh that uh or predefined services uh which sig is maintaining and our vl device can use all those predefined uh services hope you are understanding and you are with me and uh you are getting something new today which you have never learned or which you have never so gone through so now let's talk about vle characteristics after ble services we have uh ble characteristics as you can see we have two ble characteristics defined here inside uh one ble service so now what are the characteristics let's talk about the bld characteristics the characteristics is always owned by a service as you are seeing there seeing here i have a characteristics which is contained by a service so a characteristics is always owned by a service and it is where the actual data is contained in the hierarchy so like if you talk about uh the temperature if you talk about a service like let's talk about uh the battery level service so if a ble device has a service called battery level service then in the case so the battery level the actual value like 40 battery 50 battery level what is the battery level so that information that data is uh residing inside the correct characteristic so the actual data actually it is present in the characteristic so uh the characteristics always had two attributes as you are seeing here our characteristics always has these two attributes one is called properties and that is called value so at least it will have a characteristics must have at least these two attributes properties and values and now let's see what are the properties and values so here you are seeing that a characteristics always has two attributes characteristics properties and characteristic value additionally the characteristics values can all they it can also be followed by descriptors which further expands on the metadata contained in the characteristic detection as you are seeing here we have a descriptor this is optional not mandatory uh having a descriptor for the characteristic but yeah it can have a descriptor also the properties so now what are the properties so there are two attributes as i told properties and the values so what is the property the property actually describes how the characteristics value can be interacted with as you are seeing that we have two attributes of characteristics one is the property another is the value the value i triggered actually contains the actual value and like battery level like 50 of battery level so the information 50 will be stored inside the value pop portion and in the property portion properties actually it tells us how we can use the value or you can say what action can be taken on that value whether we can read the battery level or we can write so these kind of characteristics read characteristics write characteristics or you can say notify so what can be done actually on the on the particular value that information is stored in the properties so you are seeing that the properties it describes how the characteristic characteristics value can be interacted with so basically it has these many values it could be a broadcast it could be a read it could be a right it could be notify it would be indicate so if a property if you will see that if the property is the read property of a particular characteristic if the property is a read then the value of that characteristic can only be spread we cannot write uh any value for the or to that characteristics if the property is only read but if it is read and write both then in that case the value could be written or it could be read for the particular characteristic hope you are getting it now and if you still have any confusion or if you need this document or the code that i have used in this uh session if you need that let me know i can provide it to you my whatsapp number is there in the description of this video so i hope now you are clear what are the profiles service characteristics properties values so all these things if you already know then there is a concept of called uuid so what is uuid let's talk about that each service characteristic description or the descriptor they have a uuid univering is universally unique identifier so as you are seeing here each service so this is the service i have so we are seeing that this services have having a uid similarly each characteristic this is the characteristic so each characteristics is having another uid and you are seeing a descriptor and a descriptor has its own uu id so this is the universal unique id which represents a particular service a characteristic or a descriptor so uh whenever you are going to write a ble program or if you are going to create a ble server in that case you need to mention a unique id for the particular service characteristic or a descriptor this is this is how a particular ble service is identified when it when a scanner or when a client tries to connect to the particular service so each service as i told characteristics and the descriptor so they all they all have a uuid a universally unique identifier a uid is a unique 128 bit number for example you are seeing that this is an example of a uuid so if you are going to create a ble server then you need to provide a unique uh id for a particular service you need to provide a particular id for the characteristic and if you are going to define the descriptor in that case also you need to define you need to provide a unique id to that descriptor of the particular characteristic so how do you get this unique id right so um there are shortened uids for all type services and profile specified in the sig so in this sig group the bluetooth special interest group they already have defined so many uids and they are short formed uids also which is not these 128 bit long so you can use those uids in your project but you can also generate these uuids on your own if you are going to create a different service for your ble server in that case you can you can define or you can have your own uids and you can generate uh online these uids from this website for free let me show you this website first and i will show you how do we generate a unique ids from this website so this is the uid generator if you are seeing here we have two uh versions version one and version four ui degenerate usually you need to use the version one uid generator now the only difference is the way they define or the way they create the unique identifier if you will see this version one this version one it is universally it generates a uuid using the timestamp and the mac address of the computer on which it was generated so it there it the mechanism for version one is it uses the timestamp and the mac address of the computer while for version four it has a separate it has some different algorithm it generates the uid using some random number the version 4 uid produced by this site were generated using a secure random number generator so this version 4 generates a unique ident unique id based on some random number while for version one it generates using the timestamp and the mac address so you can use any of the version let me try to use the version one so how many uids you want to generate you can simply write it here so i just want to generate one so you will give one here and then you will click generate so as soon as you click on generate you will see that you have got one uid so you can give this uid to your service similarly you can create another uid for your characteristic so if you want to generate it again you can give one and generate click generate so again if you will click on generate it will give you another uid which you can use for your descriptor also so this is how we can we can get a unique ids online in summary the uid is used for uniquely identifying information for example it can identify a particular service provided by a bluetooth device as you are seeing that a unique id is a you know unique for all the ble services and the characteristics and the descriptor so you can easily identify a particular service uh provided by the bluetooth device if you know its uid so now how do we implement esp32 as a bla server so hope uh guys all the magicians uh i hope that uh you would have a pretty much good idea about now ble and what are the different terminologies that are used in realis now we will move ahead and we'll try to make our esp as a bne server so how do we implement esp32 as a vlt server let's try to follow that the usb 32 can act as a ble server or as a ble client as i already informed you you can implement your esp32 as a pd server as well as ble client first let's implement esp32 ble server please follow the below steps for this so you need to connect your esp32 with your laptop open arduino ide select your board and select your port whatever is importing so i have connected my esp32 to my laptop so this is uh this is the esp which i am going to implement as a vle server so i have connected to my arduino ide e now you have to uh copy our code esp32 ble simple server dot i know so this is the code that you have to use so where you will get this code yes i will give it give this code to you just let me know ask me in my whatsapp or my facebook group or just in the comment here i will provide it to you my whatsapp number is already there in the description of this video so go ahead and ask me about this code i will provide it to you so you have to copy this code and save it so this is the code uh esp32 ble simple server so here you are seeing that we have uh defined uh service uid and the characteristics uid so all these these two uids i have simply generated from this website which i had shown you i'm not using the descriptor uid here because i am not going to define descriptor for characteristics which is optional but for a characteristics two attributes are mandatory one is the property another is the value okay so once you have copied the code let's follow the document now now we don't have to change anything in the code unless until so this is our code you don't need to make any change in this code unless until you want to change the let me open not the code discord so this is the code so you don't need to make any change in this code in the simple server code unless until you want to change the uids and you want to use your own uid so in that case you can directly change these two values here and then simply next step will be you need to keep pressing the boot button and upload the code into esp32 once upload done release the boot button so you might not require to press the boot button if your code is automatically uploaded into the esp32 but for me on this esp32 i need to push the boot button in order to upload the code but for this esp32 this is the newer is esp32 in this esp i don't need to press the boot button so the code is directly uploaded so okay let's try to first upload the code in esp32 and make it try to make it as bnd server and we'll see how that this work okay so this is the simple server code i will simply upload it and you can see that it is uploading it is compiling the sketch now and the compilation is almost finished it's finishing yes compilation is done now upload started i need to press the boot button so if i press the boot button yeah it started writing and i release the button so it's almost written 70 percent yes it's uploaded 100 percent and you can see that now uh the upload is done now you can let's follow the document again once successfully uploaded you need to open the serial monitor and press the enable button to re-execute the code okay and you should see the result with the below result okay let's try to do that so i will open a serial monitor so this is the serial monitor com com port 4 for the esp server and i need to press the enable button i will press this so as soon as i press this you can see that image creating ble server and characteristics defined now you can read it in your phone so it means my ble server the esp32 uh has started a ble service or ble server uh in this so now my esp32 is acting as a ble server so any ble client now can easily connect to the ble server now from where we'll get the ble client the one thing is we we create or we implement a ble client or ble scanner on another esp32 and we try to connect this is uh this can be one of the case so we will see that also but to make it little easy first let's try to use some other ble client which is easily available for us so where is that ble client that we can see let's try to follow the document as per above result you will see you see that our esp30 now the esp32 is now working as a ble server now we need to somehow use a ble client to get connected to over the esp32 server because now if it is acting as a server it is providing some service or it is advertising some information we need to read that information what this ble server is uh providing so in that case we need some client who will connect to this phd server the simplest ble client that we can find is an rf mobile app so there is a mobile app android or an iphone for both of those we have an app which acts as a ble client and using that app we can easily connect over esp32 and then we can see what uh information this esp32 over server is advertising okay so where you will get this app so here these are the two links for android this is the link and for iphone this is the link so this is how it looks like let me show you how it looks like [Music] so i will open this so let me show you for android so this is the app you are seeing that for me it's already installed here so this is the app nrf connect for mobile you need to install this app in your android phone and for iphone users you can use the other link so this is the link for iphone users this is the app that you have to install and this is the free app so once you have installed the app on your phone tell me your mobile phone's bluetooth you need to open the app and then turn on your mobile phone so let me now show you my mobile and i will do it here okay i'm not sure whether you are able to see that so this is the mobile phone and this is an rf connect so this is the app i'm talking about you need to open this nrf app so you will see that it is asking for enabling the bluetooth so you will click on enable so it will enable the bluetooth okay so we will follow the document and i will show you uh i will stop sharing the screen and i will show you in the bigger screen how this app looks like and how do we get the information but first let's try to see what we have to do in our document try to follow the document so on the scanner tab we need to click scan and then it will find all the ble servers so in the mobile app you are seeing if you see that there is a tab called scanner tab here so and the scan button here so when you will press on this scan it will scan all the ble servers and uh if our esp32 should be supposed to be appear when it will scan the ble server so our esp32 will be visible when i will scan this so once our esp32 server is found by our app then what do we do then we need to so you will see that it will look something like this so our esp32 ble server will appear after the scanning is done and then you can need you need just need to click on the connect button in order to connect to the esp server so then our mobile app will directly connect to our ble server as soon as we click on connect don't worry about this uh theoretical portion i will directly show you and when i will stop sharing my screen then i will directly show you on my phone uh how do we connect it and what all the information we see so once you connect with your esp32 then you can see a kind you know kind of information like this so where you will see that our e our esp32 ble has been connected and you can see couple of uh attributes generic attributes and you will see a kind of unknown service a service by the name of unknown service and you will see the uid of the particular service then you can when you will click on the service here then you can see uh it will show the characteristics what all characteristics are there inside that service so remember i have shown you there is a service and inside the service there must be at least one characteristic all right and the characteristics has a property and a value so now you are seeing that when you will click on the service it will open the characteristic what all characteristics it has and then here you are seeing a property of the characteristic so the property is read and write and there is a button here in the download button when you will click on this you can see the value use of the particular characteristics so when you will click on this button the download button you will see uh the value also right so now here from here you can see a detailed view of your service that you had just created uh using your esp32 so we had created a service inside that a characteristics is there it has a uid and it has a property characteristics has a property called read and write and you can see a value is hello from image so this is the value that this characteristic has so from where all these values are coming yes of course these all are coming from our code if if i will show you the code so this is our code so this is the service uid so if you will see the uid of the service that you are seeing on your mobile app it should exactly match the service uid that you have here i will just show you when i will connect uh the vle server using our mobile app and you should you must see the characteristics uid also and you will see that we have a value we have value set so before value i will show the property also so the using these two this line using line number 27 we are assigning a property with uh attribute with value property read and property right so read and write these two values these two things we are providing to the property and the value for the particular characteristics we are providing the value here hello from image so this is the value of the characteristic and these are the properties of the characteristics which we have provided and we have given the uid to the characteristics this and the uid to the service we had provided this okay so hope uh this is okay and clear to you now let me [Music] just close this sharing so that you can see my camera in zoom form so okay so this is the app that i was talking about nrf and this is the scanner tab and here we have a scan button so let me try to click on the scan so when you will click on the scan so it will scan here and you are seeing that it has already found image esp32 the first one you are seeing so when you will click on the connect so this is our uh ble device which it has already found so you will connect click connect on it so you when you will connect uh click connect so you are seeing that it is connected uh to the imh esp32 ble service now this sbl device and you are seeing that i have got a unknown service with the uid so here if you will observe the uid of the service it will be the exactly same that we had provided from our code now when you will click on the service you should be able to see the characteristics here so now you are seeing the characteristic with a uid over here so if you will see the uid of the characteristics this will be the exactly same which we are providing from our code and you are seeing the properties of this characteristics are read and write right so okay so now if you want to see the value of this characteristics you can directly directly click on this read value so let me press on this so when you will click on this read button on this download kind of button which is nothing but a read button so when you will click on that you can see the value of the particular characteristics the first is the hexadecimal equivalent of the message hello from irs so you are seeing a value called hello from imh and you are seeing is hexadecimal equivalent also so this is how uh you uh how you have created esp32 as a ble server so now in all this information all this ble information is directly coming from your esp32 ble server so that was about uh implementing esp32 as a ble service and in this case we used our mobile phone and nrf app as a really client okay so now the same thing or uh the ble scanner or the ble client implementation you can do with your esp also so now this is what we are going to implement now and we are we will implement the nether esp32 as a ble scanner or ble client which will read or which will scan the all the ble services all the ble servers which are nearby to this esp so as soon as it will scan it should be able to identify this server and it should be able to provide the service uids or whatever information is exposed by this ble server this esp will this esp client will get to know so now how do we implement esp32 as a client we will see now okay so now let me share my screen again so magicians hope you are understanding things and uh things are getting getting easier now and understandable if still you have any confusion or if you still have any doubt you need further clarification on something just let me know in the comment section or ask me in my facebook group or let me know in my whatsapp my whatsapp number is already there in the description of this video if you need this document or you need the code that i have used uh for this that also you can let me know i will provide you so now let's try to implement esp32 as a ble client or the ble scanner so how our esp32 can scan the available ble servers nearby so let's try to do that so now we will implement esp32 as a ble scanner to scan the available ble servers in this implementation we will take another esp32 and keep the first one as ble server so i am not going to implement the same uh esp as a client because i am i have already implemented this as a server the first one so now i am taking another esp32 and i will implement this esp32 the second esp32 as a ble client so how do we do that kindly follow the below steps for this implementation leaving the first esp32 as a ble server take another esp32 yes connect it to your laptop open another instance of arduino ide so you need to connect your esp to your laptop and you need to open another instance of arduino ide and select the board and select the com port okay and then you have to copy this code so okay i will open another instance so this is the instance for a simple server i will open another instance and i will copy the code esp32ble simplescanner.ino so in this case our code is scanner dot io and you have to copy this code so from where you will get this code yes i will give you this code if you will ask me in my whatsapp or facebook or the comment section my whatsapp number is already there in the description of this video please go there and ask me about this code so you need to just copy this code in your another instance of arduino ide yes so i have copied the code here so this is esp32 ble simple scanner so in this code also you don't need to make any changes so you need to just copy and paste and save the code as is and so there is no change required in this code so let's let's now follow the steps now we need to keep pressing the boot button if needed upload the code to second esp32 and once upload is done release the button so i so you had open so this is another instance of arduino ide so from here you need to select the board so my board is esp32 dev module it's already selected and the combo which is it so i have to compute com4 and comp 8 as you had already seen the com 4 this com 4 serial port is for my first esp32 and for second esp32 the com port is eight okay so for the first esp the com port is four for the second esp the com code is eight so i have connected to the com 8 and i will click upload button so now it is trying to compile uh the sketch and luckily i don't need to press the boot button on this esp32 so it will be automatically uploaded as soon as the compile compilation is done successfully i like this uh if it automatically uploads uh yeah so you are seeing that it is already uploading uh started i did not need to press the boot button so it happened automatically so it's done uploading so now you have seen that the ble client code or the ble scanner code has been uploaded to my second esp so now remember the first esp is running already running the ble server and the second esp is now running dna client now what to do let's follow the step after successful upload open the serial monitor and press the enable button to re-execute the code and we should observe some results okay let's try to do that so i will open the arduino ide from here i will open the serial monitor so let me try to a little bit resize it so this is the com8 yes for the second esp now we need to press the reset button if i press the reset button so you will see that it is scanning yes so if you will see that it has scanned some devices but it looks like it don't scan did not found our device esp32 server this ble server it did not find because you are seeing there is no name all the names that you are seeing are blank it did not find our esp we do we are seeing that it is searching or just scanning for all the ble servers nearby but it could not find our ble because the possible reason is i already have connected this ple so first i need to disconnect this ble from here so i will disconnect it and i will close my bluetooth from here so that i am totally out uh from this so now you are seeing that from my nrf app i am not at all connected because my bluetooth is also disabled and i can simply close this app so now my esp32 is not connected to any of the client now uh i will restart i will restart my esp32 server again so i will press this esp32 ble server so once you have pressed it you can check the progress on the com4 so there are two com ports now this is this serial monitor is for this is com4 is for e first esp32 as you know and you are seeing that it is creating ble server and the characteristics has been defined and now you can read it in your phone or you can read it in any client so now uh i will i will again press the reset button for our ble client and try to see if this time it finds our ble server or note so this is the comet so let me first clear it so clear the screen for comport comment okay so now i will press the reset button for ble client so you will see that it is scanning and the scanning is done it is still scanning so you are seeing that it has found some devices and one of the device that you are seeing here it has already identified as image as you see that image esp32 ble so as you can see that it has identified our ble server which is with the name is image esp32 ble so if i will maximize it so if you see that you will see a service uid also here so if you will see that uh it has found uh the device is image esp32 ble with address so this is the mac address of our you know esp server uh and the service uid that you are seeing that uh this exit decimal number or uid which is the same let me copy it and i will show you i am just copying it and i will show you in the server and let me just try to paste it somewhere somewhere let me try to paste it here i am pasting it here so you can compare so you can compare the service uid which was scanned by ble client and the service uib which we have declared both are same so it means our ble ah the scanner or the client has successfully searched uh the ble server here so this is this was the simple demonstration how we can scan or how we can identify the nearby ble servers further if you want you can connect to this client and can read information or can read the characteristics values or you can write some characteristics values as well so this is these are some um different or generalized form of this session or the project which you can do on your own so magicians so so that's it that's that's all i had uh for the day and hope you enjoyed the session and you learned something new um definitely this will be helpful for you in your future projects if you are going to implement any ble device if you have any confusion if you have any doubt or you are getting any issues while implementing this let me know i can help you on this and till then uh magicians uh take care of yourself hope uh i will meet you soon in some another interesting session till then take care of yourself bye bye and just let me stop sharing it and i will close the meeting till then arigato magicians and have an
Info
Channel: IMH Videos
Views: 497
Rating: undefined out of 5
Keywords: IOT, Raspberry Pi, IOT Course, Online IOT projects, Amazon AWS IOT, MQTT IOT, Wireless IOT, XBEE, Home Automation, Learn IOT Online, firebase, Realtime database, ESP8266, ESP32, Micropython, IoT Core, Webserver, ESP Webserver, Telegram, BOT, Telegram Bot, Amazon Voice Service, Smart Home Skill, Amazon Alexa, SPIFFS, ESP Filesystem, ESP FileSystem Uploader, ESP32FS, Interrupts, PIR Sensor Motion, PIR, ESP NOW, ESP 2 Way communication, CloudWatch, IoT Rule Engine, WiFiManager
Id: _8GcrwXFFnA
Channel Id: undefined
Length: 57min 17sec (3437 seconds)
Published: Sat Sep 11 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.