Home Automation with WiFi & Bluetooth together

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] in this video we're gonna make our own wi-fi and bluetooth control home automation system using just esp32 board yes it's possible so let's get started but previously i made the exact same project but using two different models like nodemcu for wi-fi control automation and h605 model for bluetooth control automation okay well i made using that because previously the project was not at all working on this esp32 world like i was not able to use wifi and bluetooth simultaneously into the single model but now i figured out the solution and now we can use like both the protocols using one single module and that's the esp32 board so for making this project you'll require all these components well i have the link of one article in the description of this video where i have test like the list of all components used and every other details regarding this project so do check out the article after completion of this video so for getting all the components you have to connect them all in this manner now again due to complex and a lot of connection i just designed my own custom pc before this project and gave its order straight away to jlcpcb well you can also order your own custom pcbs from jlcpcb by uploading your gerber file off the pcb project i'll select the color masking if you want and pay for your order well they started delivering india again but this time using the fedex service option so now you can start ordering your own custom pcbs for your next projects or maybe products after getting the pcbs and shouldering all the components on it i just connected it with one of my switchboard and the connection diagram is also provided in that website article so you can refer that for the connections so this was all about the hardware part of the project now let's just move on to the wi-fi and bluetooth application part so for wi-fi control i use this blink app in which i just created a new project gave its name as wi-fi control selected the board as esp32 and well connection type is wi-fi after creating a new project just step on the screen and add a button here now tap on that to configure it select the pin as virtual pin v1 and more as switch similarly i've created three more buttons with virtual pin v2 v3 and v4 so that's it about the wifi application setup so now talking about the bluetooth application then our team has developed our own custom bluetooth application on mit app inventor whose detailed explanation i already covered in the previous video so i'll suggest you to watch out that video in case you want to understand like how we made that uh bluetooth application and how the bluetooth application is actually working i'll attach the link of that video in the i button as well as in the description of this video so with this we completed the application part of the project now let's just move on to the most important part of this project and that's the coding so here's the code that we have used for our project so the code start with the declaration of the necessary libraries that is the blink library and the bluetooth serial library whose respective links are attached in the code itself so you can download it in case you don't have it okay and here we are declining an object for you know serial bluetooth communication that is called as serial bt okay then here we have a variable that will be storing all the data coming from the bluetooth client side pretty simple here we have defined the pin numbers according to the relay we have attached on the pcb that's also pretty simple so now here you have to provide the authentication token which must be sent to your blink registered email id okay so just go to the inbox of that email id and just copy the authentication token and paste that here that's it then you have to provide this id name and password as this project do require the internet connection at time of working with the blink application okay that's it now let's just jump on to the setup part of the project so here we are just beginning the serial communication at the okay then here comes the most important line uh without which the project was not at all working previously and that is bt start that means like bluetooth start this function is responsible for turning on the bluetooth of the esp32 board well i was already knowing about this particular function previously but why i have not included that in the previous project is just because it was already included in the source file of the bluetooth serial library let me just show you okay as you can see uh so this is the source file of the bluetooth serial library that is uh bluetooth serial.c plus plus and here if you search for a bt start let me just show you here if you search for bt stat as you can see this function is being called here and and this function is already called from the main loop okay so this function is already been initialized in the project even if we don't write this function okay but still in the previous code if i just comment out this line this project was not working previously but if i include this function in the main code itself it started working and now if i remove it again it will still start working i'm really not sure like what's happening inside the code you just need to include this function for only once and now if i remove it the program the project will still work on the esp32 but it won't be working on the new esp32 if i upload this much in line of code so that's the reason which i found uh during like like doing trial and error in different esp32 boards so this was the line using which i was able to you know control it with wi-fi and with bluetooth simultaneously okay so this is a function let's go ahead so here is the serial bt dot begin inside which we have to provide the bluetooth name to this bluetooth model of esp32 so for my project i have defined as esp32 underscore bluetooth you can give name according to your choice maybe bluetooth automation or any any random name okay so that's you have that that so that thing you have to mention here great after that declaring relays at output and just turning off the relay at beginning pretty simple and we are just making our wi-fi communication with the router and we are also establishing the communication with the blink server providing the authentication token great now let us jump on to the loop part of the project okay so loop part is pretty short and pretty simple okay let's just understand it line by line first is the if condition which checks if whether it is connected with internet or not okay so if it is not connected with internet okay so if it is not connected with the internet it will straight away print as not connected and it will jump out of jump out of this if function in case it is getting connected with internet what it will do it will just print uh connected on the serial monitor and then it will be running the blink services okay so in case it is not at all connecting to internet there is no need of running the blink services correct so if in case it is connected then only blink.run function will be called and all the blink services will be you know running so what are the blink services let me just show you so inside the blink.run it will be you know serving all the blink function for example if you're pressing the relay one button on the blink application this blink write virtual pin v1 function will be called and it will be reading the data coming from the button maybe it's one or maybe it's zero the data will be stored inside this pin value variable and according to the data received we are just turning on and off the relay one so pretty simple right so this is how we'll be able to control appliances using the blink application when we are having internet okay now let's see how we will be able to control the uh appliances using bluetooth okay so we were here previously okay okay it says when it is connected to internet uh just run blink.run function okay so this was the if and else condition just to check the internet connection now let us move ahead so here we have another if condition which checks if serial bt.available that means if there any data coming from the bluetooth client side okay now this if condition will be checked regardless of whether it is connected with internet or not okay bluetooth uh doesn't really need to check whether it is connected with internet or not hence i have just declared this if condition outside this you know internet checking loops or internet checking functions okay so in case there is something coming from the bluetooth client side it will just calling the function called bluetooth handle now let's see what's inside the bluetooth handle function so here's the bluetooth handle function what we are doing is first of all whatever data we are receiving from the client side we are just storing in the blue data variable pretty simple and we are just comparing the data with the predefined data that we have set inside the bluetooth application side okay for example in case we are pressing the on one button on the bluetooth application the data one will be sent okay so in case we receive the data one we are just blindly turning on the relay one that's that's all we are doing and in case we are receiving the data as to we're just turning off the data so this is how we have encoded the data for on one button we are sending the data one for off one button we are sending the data to now for on two button we are sending the data three and likewise for off four button will be sending data eight so this is how we have encoded the data for you know bluetooth communication not really encoded just define the numbers okay so what we are doing is uh in case we receive one from the loaded client side we'll simply turn on the rename and here there's one more line which says blink.virtual right now this line is used to send the live feedback from the bluetooth application to the bling side in case it has an internet connection so this will be used as a feedback on the blink application side that will be you know having a look over it or while you're running this code in action okay so this is what is happening inside the bluetooth handle function according to data receipt we are just turning on and off the respective relays okay so that's it about the coding of how you can control the appliances using wi-fi and bluetooth with internet and without internet as well i hope you got to know about how the things are working inside the core okay so that's it about the coding part and i'll straight away upload this code onto my esp32 board so that was all about the configuration of hardware application and coding part of the project now i'll let you know how to use this project but before that make sure you hit the like button if you really love the explanation of this project till now and just comment down your thoughts regarding uh what's happening like why it was not working previously and why it started working right now with that single function which was already inside the library do you know anything regarding this or do you have any suggestion on it thought regarding this do let me know your thoughts in the comments i really need to clarify the things so now that being said let's see our project in action so i'll insert the esp82 board in the pcb and power up the project now first i'll open the bluetooth settings on my android smartphone and pair it with my esp bluetooth module after that i'll open the android application tap on the bluetooth icon and connect it with the same esp bluetooth model so now as you can see i'm able to control the appliances using the bluetooth application on my smartphone and on the bling side as you can see i'm even getting the live feedback of the relay not only that i can also control the relays using this blink application as well over internet so everything seems working pretty fine with internet let's turn off the router and see how it works without internet so in this board we can still control the appliances using the bluetooth application on my smartphone so now no more standing up to control appliances in any situation this project will ensure that your appliances can be controlled using your smartphone regardless of any situation so isn't it a great project to make what do you think so that is all about this video now once again to get all the important links and details regarding this project i suggest you to go to our website and check out that article whose link is also mentioned in the description and one more thing that you can also follow me on instagram just to stay updated with what i am working on okay so make sure you follow me on instagram as well if you have an account there so that's it about the video now we do have one more scope regarding this project is to make it control with the manual switches as well it's like wi-fi bluetooth and manual switches that can be a topic for our next upcoming videos so till then subscribe my channel if you haven't already and now just to wait for my next video until then explore learn share with me techy sms
Info
Channel: techiesms
Views: 52,591
Rating: undefined out of 5
Keywords: esp32 wifi & bluetooth, wifi bluetooth esp32, home automation, wifi & bluetooth simaltaneously, smart home, home automation project, esp32 projects, iot projects
Id: N3s5m2NkBD4
Channel Id: undefined
Length: 12min 10sec (730 seconds)
Published: Sat Aug 15 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.