ESP32 Bluetooth Classic - ESP32 Beginner's Guide

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone and welcome back to my YouTube channel in this new tutorial I'm going to show you how to use the Bluetooth module so this bird which is an esp32 board comes with a built-in Bluetooth that you could use for some projects for example you could control some devices using Bluetooth from your smartphone in this video I'm going to show you how to use this feature and before we get started make sure to watch my first video about the esp32 course I've talked about the esp32 board and how to set up the Arduino IDE because you have to make some changes to the Arduino IDE so that we can program esp32 boards make sure to check it out the link will be under the description and before we get started make sure to smash the Subscribe button that helps me a lot and without any further Ado let's Dive Right In [Music] so as I said at the beginning of the video the esp32 board comes with the built-in Bluetooth module that you could use first we have to plug in the USB cable so that we can program it with the Arduino IDE then let's open up the Arduino IDE here we have an empty sketch so first of all we have to include a library which is called the Bluetooth serial that allows you to use the Bluetooth feature and you don't have to install this Library it is built in you simply need to include it using hash then include and the name of the library in these double quotes which is a Bluetooth serial then we add dot h because it's a library after that we can create a Bluetooth serial object that represents the Bluetooth module of the esp32 board using a Bluetooth serial and we can give it a name you could call it whatever you want I'm gonna call it serial BT then we have to enable it under the setup function using serial BT which is the name of the object then dot begin this takes a string in these double quotes and it's going to be the name of the device so when you open up Bluetooth you will see the name of the Bluetooth module for example I'm going to call it esp32 Dash BT and don't forget the semicolon then enter the loop function we can check if we have received a command or some sort of message from Bluetooth and to do that we can use an if statement using F serial BT dot available so this is a built-in method it's going to be true when we have a message that we can read or a character in such case we use serial BT dot read and this is another method that Returns the character that we read we can put it inside a variable so let's go on top the type is character or char let's call it C and D then we can assign the value to width using CMD equals serial BT to treat and that's pretty much it now you could use this command to control LEDs or other devices that are connected to the esp32 board for example let's turn on and off the built-in LED so the esp32 board comes with a blue LED that we can control and it is connected to the pin number two I've talked about that in the first video so let's add this logic we can check if the command CMD equals for example the character one in such case we turn the LED on using digital right this command takes the pin number which is due and to turn it on we use high and that outputs a voltage from the pin number two and turns the LED on and with the same way we can check if the command equals zero using IF CMD equals the value 0 then we could use this to write low so I will just copy it and paste it and don't forget to change this to low and last but not least it is recommended to add a little bit of delay to the loop function because it is called so fast we have to slow down the program to smooth it using delay so this method takes the number of milliseconds I think 20 milliseconds is fine and that's pretty much it but I think I forget to add the pin mode under the setup function we have to add then mode we give it the pin number two and the output keyword because in some cases we have to use the pen as an input for example to read a value from a sensor like the temperature and the humidity anyways before we upload the code we have to select the kind of board that we have for me it is called node MCU esp32s and to do that you have to go to tools then board under here we have esp32 of course you have to set up the Arduino IDE and install the esp32 package make sure to watch my first video I've talked about that now I can select the kind of board that I have so let's go all the way down and search for it and here it is node MCU 32s after that we select a d port using tools port for me it is complex of the USB cable then let's set upload now it is compiling the sketch I think everything is fine and when you get connecting you have to hold down the boot key which is this one and there you go it is uploading the code and once it's done we can reset our board using the rst key or it is called en in my board now let's test it but I think you are asking how we are going to send the values 1 and 0. to the Bluetooth module so that we can control the LED basically we can install an app from Google Play Store let me open up Google Play Store and search for serial Bluetooth terminal so just write the name serial Bluetooth terminal and it is this app for me it is installed let's open it up first we have to pair the device of course you have to open up Bluetooth then let's go back to the app under this menu we have to select the device under devices you see that we have the name esp32-bt which is the name of the Bluetooth module click on it and there you go we have connected now we can send the values 1 and 0 to control the built-in LED so let's write one and send it and there you go the built-in LED turns on and if we send the value 0 it turns off so I think that's pretty much it guys for this video I hope you like it if you have any question or comment make sure to write it under the comment section down below and they will see you in the next one
Info
Channel: Enjoy Mechatronics
Views: 47,123
Rating: undefined out of 5
Keywords: Arduino, tutorial, enjoy mechatronics, how to, esp32 bluetooth, getting started, esp32 beginners, esp32, introduction, esp8266, beginner, learn, sketch, connected, basic tutorial, gpio, pin, esp32 bluetooth serial, classic bluetooth, basics, wireless, course, esp32 tutorial, ESP32, esp32 introduction, esp32 arduino, arduino ide, diy, how, to, beginners, guide, project, bluetooth, control, ide, easy, Bluetooth Classic with Arduino IDE, ESP32 Bluetooth Classic Read Inputs, Bluetooth Classic control outputs
Id: EWxM8Ixnrqo
Channel Id: undefined
Length: 8min 35sec (515 seconds)
Published: Fri Nov 18 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.