seeking help for connectivity issues in esp32 bluetooth with android
I found this code for connecting the bluetooth
#include "BluetoothSerial.h"
BluetoothSerial SerialBT;
bool isConnected = false;
void setup() {
Serial.begin(115200);
SerialBT.begin("ESP32_BT"); // Bluetooth device name
Serial.println("The device started, now you can pair it with Bluetooth!");
}
void loop() {
if (SerialBT.hasClient()) {
isConnected = true;
Serial.println("Connected");
} else {
isConnected = false;
Serial.println("Disconnected");
SerialBT.disconnect(); // Ensure any previous connections are closed
delay(5000); // Wait for 5 seconds before attempting to reconnect
SerialBT.begin("ESP32_BT"); // Restart Bluetooth
}
if (isConnected) {
// Handle your code when connected
}
delay(1000); // Check connection every second } but i can connect with this when the "serial bluetooth app "(available in playstore) for only serial communication but i want to make a home automation system with bluetooth so i want that when i am in range of esp then bluetooth will automatically connect with android and i can on off any device with my app
delay(1000); // Check connection every second } but i can connect with this when the "serial bluetooth app "(available in playstore) for only serial communication but i want to make a home automation system with bluetooth so i want that when i am in range of esp then bluetooth will automatically connect with android and i can on off any device with my app
0 Replies