Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1247

Python • Raspberry pi Bluetooth

$
0
0
Hi ,
I am writing a code for raspberry pi which makes the Pi's bluetooth visible to everyone and it would connect automatically to your phone without connecting the pi to your monitor .
1)Could you tell me if the code is correct
2) I got an error for installing the library . Can you tell me what is the mistake . i tried to install it still stating the same problem .I will attach the screenshot

[from bluezero import peripheral
import time

# Configuration (Customize these)
DEVICE_NAME = 'bChaturunga'
SERVICE_UUID = '0000ffff-0000-1000-8000-00805f9b34fb' # Change this UUID

# Create BLE Peripheral
pi = peripheral.Peripheral()

# Add GATT Service
pi.add_service(srv_id=1, uuid=SERVICE_UUID, primary=True)

# Start Advertising
pi.advertise(name=DEVICE_NAME, services=[SERVICE_UUID], appearance=0x00)

print(f"BLE Server Running - Advertising as {DEVICE_NAME}")

try:
while True:
time.sleep(10)
except KeyboardInterrupt:
pi.stop_advertise()
print("\nBLE Server Stopped")

Screenshot[Since i cannot directly open the screenshot using the img on the edior]:
https://drive.google.com/file/d/1MJJgEi ... sp=sharing
WhatsApp Image 2025-03-27 at 17.34.41.jpeg

Statistics: Posted by AlenHazard — Sat Mar 29, 2025 1:37 pm



Viewing all articles
Browse latest Browse all 1247

Trending Articles