Recently I used bluepy in ESP32 and RPI4 Bluetooth connection, ESP32 for server, RPI for clint, found that the data is collected about 5 to 50 times , the connection will be disconnected, after querying the google, I found that someone mentioned before, but it seems that the problem has not been solved, please ask 2022 Someone has found a solution? This is a question raised by others stackoverflow
This is the resource of code source
This is my code
from bluepy import btle
import time
MAC = "mymac"
SERVICE_UUID = "myID"
CHARACTERISTIC_UUID = "myID"
print("Connect to:" + MAC)
dev = btle.Peripheral(MAC)
print("\n--- dev ----------------------------")
print(type(dev))
print(dev)
print("\n--- dev.services -------------------")
for svc in dev.services:
print(str(svc))
print("\n------------------------------------")
print("Get Serice By UUID: " + SERVICE_UUID)
service_uuid = btle.UUID(SERVICE_UUID)
service = dev.getServiceByUUID(service_uuid)
print(service)
print("\n--- service.getCharacteristics() ---")
print(type(service.getCharacteristics()))
print(service.getCharacteristics())
#----------------------------------------------
characteristics = dev.getCharacteristics()
print("\n--- dev.getCharacteristics() -------")
print(type(characteristics))
print(characteristics)
while True:
for char in characteristics:
if(char.uuid == CHARACTERISTIC_UUID ):
print(char.read())
time.sleep(0.5)