im trying to print the values in bluetooth from esp32 and i want to receive the data in python by using bleak library.
the problem im facing with this whenever i run the program it shows address not found.
ill attach the code for the reference purpose.
ESP32 device details:
Address: 0C:B8:15:F6:78:4A
Minor Type: PDA
RSSI: -49
Services: 0x802000 < Braille ACL >
char *devicename = "ESP32";
#include "BluetoothSerial.h"
BluetoothSerial SerialBT;
void setup() {
// initialize serial monitor
Serial.begin(115200);
SerialBT.begin(devicename); //Bluetooth device name
// get Bluetooth classic address and print to serial monitor
uint64_t btAddr = ESP.getEfuseMac();
SerialBT.print("Bluetooth classic address: ");
SerialBT.println(btAddr, HEX);
}
void loop() {
// code here will not be executed
}```
the python code:
import asyncio
import logging
from bleak import BleakClient
logging.basicConfig()
log = logging.getLogger(__name__)
async def run(address, loop):
log.info("Connecting to %s", address)
async with BleakClient(address, loop=loop) as client:
log.info("Connected. Reading data...")
while True:
data = await client.read_gatt_char("<802000>")
log.info("Received data: %s", data)
if __name__ == "__main__":
# Replace <device address> with the address of your Bluetooth device
address = "<0CB815F6784A>"
loop = asyncio.get_event_loop()
loop.run_until_complete(run(address, loop))
error: raise BleakDeviceNotFoundError(
bleak.exc.BleakDeviceNotFoundError: Device with address <0CB815F6784A> was not found