HC-05 Bluetooth Module with Arduino-MIT App Inventor

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so in this lesson we will going to learn how to control the LED connected to Arduino Uno using Bluetooth app right so you see here I press the button and LED turns on and I press the off button and LED turns off right so here what we have is at c05 bluetooth module if you look at the front side it will look like this it will show you some kind of antenna here on hc-05 bluetooth module and in the back side when we look at that we will see the every pin on this module okay look at this every pin on this bluetooth module has a name so say for example the first pin is enable en second pin is VCC then this one third one is a ground and then the fourth one is a txt fourth one is I think fifth one is rx T and then the state right so this is how the the pin label has been given on this hc-05 bluetooth module like in above VCC ground TX Rx and state so enable and state these are the two pins we are not using here when it comes to connecting hc-05 bluetooth module which must be point and the other pins like VCC ground to power up and TX Rx we will be using in order to communicate this hc-05 with our arduino uno okay so let's take this bluetooth module and connect it to Arduino Uno so here we have a bluetooth module and you see on our Arduino Uno there are the pins like the first pin is DRX okay and like digital pin zero is our X and digital pin one is a TX right so if you can look at this carefully you can able to see it pin number 0 on Arduino is alright and pin number 1 on Arduino is a TX right so basically to make the communication between this hc-05 and Arduino Uno we need to have a couple of male to female jumper wires right so we can take the jumper wires and start connecting this XC 0 5 bluetooth module with our you know right so let's take the first male to female jumper wires and let me take the backside of the hc-05 bluetooth module and this will be say for example TX so let me plug it to TX okay and thus DX on hc-05 bluetooth module will going to connect to the RX on arduino uno okay because it's a transceiver the TX on bluetooth module go to our X on the arduino uno right then take another jumper wire okay male to female jumper wire and the female part of the cable we are going to connect to the RS okay and then this yellow color rx will going to connect to the TX on Arduino Uno right so that's how it's going to connect okay and then we will take one black color and we should connect the crowd on hc-05 to the ground on arduino uno i would rather use this one okay go on pin on arduino uno okay and then only one remains were just the VCC so here is a VCC pin okay and that will connect you look at this it says like three point six two six one point so i would going to connect to the five volt on arduino una okay and this is how we will have to connect at c 0 v bluetooth module with arduino uno okay so i don't know it's not staying here but i think it looks a little bit better no and then we can check one LED the longer leg of the LED will going to connect to 13 and the the leg of the LED will going to connect to the ground according to the program that we have written right so I will take this LED and longer leg is to 13 and the shorter leg is to ground let me just plug in okay so this is how you were going to connect s c05 bluetooth module with Arduino Uno so basically this is a piece of code that we want to upload on Arduino Uno what you see here is a character variable we have to define our character variable incoming value and we make it as a zero right in the beginning and then in a set of function you see every our do you know how program has to have a set up function we have to say serial don't begin 9600 because we will be connecting this hc-05 to Arduino Uno / TX and rx pin which is a serial Yod communication protocol and that's why we also have to initialize this CDL you are in order to receive the data coming from mobile lab to Arduino Uno and that's why we say serial dot begin 9600 baud rate and then our LED is connected to pin number 13 on Arduino Uno that's why we say pinmode 13 comma output to configure pin number 13 on Arduino as an output time figure into the output mode basically then in the loop function here is a loop function okay let me make it a little bit readable here okay in the loop function here comes the logic so this is the logic this if statements basically takes care what to do when you press the button right so look at this if serial dot available so when you press the button on your mobile app the on button which we will going to create later on this when we press the on button then it will send one character one or maybe the number one to our hc-05 Bluetooth module which is connected to Arduino so when Arduino receives one okay means basically when it's e05 receive something means a serial dot available if one comes that means there is a data available if it's greater than zero that means the data is available if data is available then we want to say serial dot read we read the data and store into incoming value variable right and then we want to print this incoming value variable by saying serial dot print incoming value and then just give you no new line so it will just every time whenever it press the button the new value 1 and 0 will come on a new line right and then we check here with the EPS statement if incoming value is 1 then it will turn on the LED connected to pin number 13 and then we say digital right 13 comma hi so this will turn on the LED so basically when we press the button on on our mobile app it will send one from the mobile app and it will turn on the LED connected to Arduino pin number 13 right so it will turn on so when you press the off button on the mobile app it will send a 0 mobile app will send a 0 to the serial hc-05 Bluetooth module and Arduino and when Arduino receives the value of 0 after pressing off button then it will turn off the LED connected to pin number 13 and that's why we say digital right 13 comma Lou now if you are not aware of this code if you have a problem then you might want to check out my serial communication with Arduino Uno tutorial and then you will be good to go with right but I believe it's not very difficult it just like we are just reading a serial data and then see if it's a 1 then turn on the LED connected to 13 if it's a 0 ok then turn off the LED connected to pin the both or do you know now do we know you know the next step is we have to go to tools make sure the boat Arduino Uno is selected go to tools once again go to port and select the comport where your arduino uno is connected and then upper left corner there is upload button so we can click on this upload button and this will upload the code on our Arduino Uno and after uploading the code then only we have to connect hc-05 so make sure those things very very important if you have connected this hc-05 model with Arduino Uno then you will not see look at this in lower left corner then uploading you can't able to upload the code because the uploading process of the code also uses TX and rx pin so first upload the code on Arduino Uno and then connect at C 0 of my bluetooth module so once the code is uploaded ok done uploading now to create a mobile app using MIT App Inventor we have to browse the web page App Inventor mit.edu so we first have to come to this web page and then we have to click on create amps button in your upper right corner upper lip corner so once we click on that it will take us to the page where it will ask us if you have the account then it will not ask you it will take you straight away to MIT App Inventor just to login normal if you don't have account then I would rather like to use my Google account to associate with App Inventor so I will click on that and it will create a quick account with my password so let me insert my password here with the Google credentials and it's very easy to create a count by the way with the App Inventor and then it will take you it will ask you here we'll come to the App Inventor and it says like nonsense they continue and then here comes the another dialogue which we can say close and here is how it looks like right so App Inventor so if you look at the URL okay it says AI 2 dot App Inventor dot mit.edu so basically this is an App Inventor - AI - App Inventor write whatever you like to call now to start creating a mobile app we have to create a project and you see there is a button called start a new project upper left corner and I would like to give the name to the app as a Bluetooth okay and then hit on okay so you see it creates a project with the name Bluetooth it takes a couple of minutes and then it will straightaway take you to the project itself and you can see right now look at this Bluetooth project which you just have created and it will present you this kind of live right and if you look at the App Inventor how it works is it basically gives you two views right if you look at upper right corner there is a designer view which we can see if I can zoom out a little bit okay just for you to see okay you see so upper left corner you see there is a designer view so if I click on block view you can see there are some widgets in the left pan so there we can select some widgets and then we can create an app so design of view and the block will okay so we have to stay at the designer view itself and I can zoom in again so we can see how it looks like basically and now we can start laying down the components which we need in order to make this app work with the hc-05 bluetooth module right with arduino of course so the first component we need is we need a list picker so we have to take a list picker element and you see here is a list speaker I can select the list picker in the left pan and drag it to my mobile app right so this is a mobile screen where I can drag down I I select the list picker element and you see here is a list speaker 1 you see it's added here in a component section this bigger one and because it looks ugly right now this list speaker it so it looks the way like it's just a line to the left I want to look a little bit better this one and you see in the left pane here the width I will make it as a fill parent and say okay and it looks a little bit better now and I would like to give it a name so if you scroll down this you can see there must be a text field right and here is a text field so I would like to give the name LED blue dude okay and okay so look at this when I when I hit enter you see the name of the list picker is changed so basically this is a button a normal button which you can click and then you will see a different Bluetooth client in a list so there we have to select hc-05 because that's the Bluetooth module that we want to communicate with using this mobile app right that we are creating right now the second component we want is an horizontal arrangement right so if we click on layout section there is a horizontal layout look at this in a layout section so I will drag it to my mobile apps and I select it and then I would going to say width and say fill parent and that's that's it right so basically that's how I will going to put the horizontal arrangement and then go to user interface once again and then select the button in the left pan and put one button and then I will select the button and I will put another button so now we I have two buttons right but it looks very ugly so I select the first button here in the user interface and I will say worth fill parent okay and then again just the way we did in the text section I will give the name on and you see the name of a button one is changed to on because when I want when I press the button in a mobile app it will turn on the LED connected to Arduino using hc-05 Bluetooth module and let's give it a name to other button button number to select the button number two and then weight fill parent it okay and then give it a name like of it and all right so now we have the app which looks a little bit better and it has you know two three two buttons basically and one listpicker element right and the one very important thing is we have to add now the bluetooth component right so we will go to connectivity section select the connectivity in the left pan and select the bluetooth declined from the list and then drop it to your mobile app right and you see this bluetooth client is added into the component list and you also see that Bluetooth component will be here it's so it's shown like Bluetooth component here right Bluetooth client 1 so it will be acting as a Bluetooth line now we laid down the user interface components now we have to write a logic so that it will take an action that we want it to perform through the mobile app so we will click on upper right corner you see there is a block view so we click on block view and then we select the list picker and there are two components we want list speaker 1 basically after picking and let speaker before picking right so before you press the button the speaker button and after you press the list picker element right or component so to say so when you don't connect then it just doesn't do anything just have the Bluetooth connections and when you press after picking okay so when you press the button then it will show you the list of Bluetooth clients so the next thing in order to make the logic work is we have to go to the list speaker element again and then we have to select your list speaker 1 element so this speaker 1 element that we want to put it here just place it and it will take by itself and then we have to use the Bluetooth client if there's any so bloated client could be found into the Bluetooth client section okay okay it says some kind of issue I don't know let me check my internet it's name Internet is D right so click on okay it says please help us stealing what you were doing it's time happening okay so some issue is there but I don't mind this rather something went wrong I guess not sure some load of the element is having issue so let me go to design of view I would rather delete this component select the Bluetooth component and remove it okay and now I select this and I will drag the Bluetooth component once again and go to block view and now I go to Bluetooth components and now you see I have this list of elements right and I would select a Bluetooth client address name basically and I will put it here right so that's how it works and then we have to go to this speaker once again and then we have to take the selection okay lemon and a selection so where is it let me look in it okay so you see that component we are looking for and then I need to go to the Bluetooth element and then we have to select for the Bluetooth client and the Bluetooth client is to connect so okay this one we want because whenever we press the whenever we press the list bigger one that means LED bluetooth button this button okay this button then it will give us the list of Bluetooth connected Bluetooth declined which are paired with your mobile phone right on which this app is running basically so the next component is a list bigger and then we have to select the list speaker one selection element speaker one selection element so this is that one you're looking for and then we have to go to this speaker once again and we just want to through the text right so whenever you select the hc-05 bluetooth module then the button name has to be changed from LED bluetooth to say for example something like connected or something right so it will make a little more sense so I will take this one and put it here and then go to text and then just add a normal text so whenever you select Bluetooth line then okay it will change the text to be connected so once you place the button in order to connect to the Bluetooth Arduino Bluetooth when you press this button then it will I'll give you the list you select at zero five and then the name of this pattern will be changed as a connected so you then confirm that your mobile phone and the app is connected to your hc-05 Bluetooth module which is connected to other we know then go back to the blog section and in a button I have to take button one and then we have to go to button two and take the button to right so here we have two buttons okay and then we have to write a logic where when we placed the button then the button one will send the text to Arduino over at c05 right so this will be i'll send text element that we want to put here and then in the next section we want to so whenever somebody press the button one then it will send one so that will turn on the LED connected to Arduino and then you can copy and paste by the way so I can just duplicate the element and put it here and I would just say zero so whenever somebody pressed the button - it will send a zero right accordingly over logic is written so when we press on button then it will send one because that's what we wrote and when we press a button it will send zero so it will turn off the LED connected to Arduino right so one button will send one and turn on the LED when you pressed your button it will send zero to Arduino over Bluetooth module and it will turn off the LED that's how you create basically and mobile app using MIT App Inventor now to make this app work with your mobile phones now once the project is ready on a screen that we have to take our phone in order to transfer the mobile app from our MIT App Inventor to the mobile phone so let me take my mobile phone on okay and then I would open up this MIT ai - companion app okay and then you see no Wi-Fi so continue without Wi-Fi that's fine and then I would go here in the build and also like the build option I hope you can see let me just don't know so here's the built option I can select provide a QR code for apk and in a moment there will be n QR code will be generated if not maybe then we have to turn on the Wi-Fi but I don't think it's needed let's see what happens so we see the QR code is there so I can take my phone and connect scan QR code I can click on scan QR code and here is the QR code I can scan and I will click on Chrome here and it will start installing this mobile app right I hope so it will come up oh no there's no internet so I have to turn on the deter Network here okay and just try once again okay so scan QR code and here I scan again okay and then select the Chrome and then you see here I don't know this matzoh okay it says in the down corner do you want to download yes I want to download so let me press the download button and you see now app is installed I can say open and stole and it is installing right it's very easy you don't even need to create generate an apk you can transfer the apk from the App Inventor straight away to your mobile phone okay app is installed and I can say here open button and here is my app I can now use this app later right so this is how the shortcut looks like for the Bluetooth app that we have gridded and this is mi d AI - companion app right you need to download this first before you use it right we have to take our mobile phones ok and because we are using bluetooth as a protocol we have to turn on the bluetooth first one over phone once the Bluetooth turns on you see the phone will show you the Bluetooth is on right once the Bluetooth is on we go to settings on phone and then inside the Bluetooth option you will see it will list the point which is available right so 983 is one of the Bluetooth client and you see my bluetooth module is powered up so I can able to see it so let me select and it will ask me the password for the Bluetooth and the password default password is 1 2 3 in form ok and then hit ok and now this Oetzi 0 5 comes from available devices to the paid devices so the first thing is we have to pay at the hc-05 this hc-05 bluetooth module with our mobile phone and then we can then go to the mobile app that we just created so bluetooth mobile app and then you see I have led Bluetooth the first button that I can click and it will show me the list of Bluetooth clients of my labels so hc-05 is the one that I want to connect to so I will select hc-05 here and you see now the name LED connected is LED bluetooth is converted into connected and now you see when I take this phone here and when I press the on button LED turns on when I press off LED turns off right so on all right so this is how we will going to control the LED connected to Arduino Uno using mobile app and using hc-05 bluetooth module right
Info
Channel: BINARYUPDATES
Views: 967,689
Rating: undefined out of 5
Keywords:
Id: aQcJ4uHdQEA
Channel Id: undefined
Length: 27min 56sec (1676 seconds)
Published: Fri Dec 20 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.