In this we learn about esp32 inbuilt bluetooth. i'm alredy told about esp32 has inbuilt bluetooth and wifi now we learn about the bluetooth
How to buy ?
ESP32 is available on all online e-commerce websites. I'm giving amazon link If you buy the components using my affiliate links, it will help to our channel and website growth. so do these small help.
ESP32-WROOM BUYNOW
ESP32 DEVKIT BUYNOW
esp32 inbuilt bluetooth tutorial video :
esp32 bluetooth LED ON and OFF CODE :
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
String res = "";
int led=22;
BluetoothSerial SerialBT;
void setup() {
Serial.begin(115200);
pinMode(22, OUTPUT);
SerialBT.begin("ESP32test"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
}
void loop()
{
while (!SerialBT.available()); // Wait Until anything is coming from bluetooth client
while (SerialBT.available()) // Read until the bluetooth client is sending.
{
char v= SerialBT.read();
res = res + v;
delay(1);
}
// Assigning Actions on particular conditions
if (res == "T")
{
Serial.println("Connection Established!!!");
}
if (res == "A")
{
Serial.println("Turning ON 1st led");
digitalWrite(12, HIGH);
}
if (res == "a")
{
Serial.println("Turning OFF 1st led");
digitalWrite(12, LOW);
}
res = ""; // clearing the string.
}
if you have any doubts about this ESP 32 comment on my YouTube channel or contact me on Instagram. I'll respond as well as possible .
0 Comments