Micropython bluetooth is not working !!!
-
- Posts: 1
- Joined: Tue Oct 12, 2021 7:12 am
Micropython bluetooth is not working !!!
I'm using micropython esp32-20210902-v1.17.bin for esp32 & i tried using bluetooth following this code https://techtotinker.blogspot.com/2021/ ... tooth.html . but my phone can't communicate with my esp32's bluetooth. already tried another phone but got the same error. anyone can help me?
-
- Posts: 61
- Joined: Fri Feb 15, 2019 9:22 am
Re: Micropython bluetooth is not working !!!
The GitHub repository examples using microPython1.17 can be run
Third party examples may only apply to older versions
Third party examples may only apply to older versions
-
- Posts: 8
- Joined: Thu Apr 09, 2020 7:19 pm
Re: Micropython bluetooth is not working !!!
I was also unable to get this to work. My understanding is that BLE communications will work but the BLE Pairing has not been implemented yet. As far as I can tell, BLE on ESP32 is kind of useless without the ability to pair devices. Does anyone else have any insights on this or when Bluetooth will be usable?
Re: Micropython bluetooth is not working !!!
weird, I got my Arduino ro2040 connect to pair with my iphone with this code, still developing it. My plan is to send data over BT to the microcontroller to do stuff with motors and neopixels:))
Code: Select all
import bluetooth
bt = bluetooth.BLE()
bt.active(True)
UUID_HR = const(0x2A37)
_IRQ_ALL = const(0xffff)
HR_SERVICE = bluetooth.UUID(0x180D)
HR_CHAR = (bluetooth.UUID(UUID_HR), bluetooth.FLAG_READ|bluetooth.FLAG_NOTIFY,)
CID = None
((HR,),) = bt.gatts_register_services(((HR_SERVICE, (HR_CHAR,),),))
def bt_irq(event, data):
# >> bt irq 1 (64, 1, b'Y\xeb\n@uZ')
global CID
DATA=None
if len(data)==2: #connection only, no data
CID,EID = data
else:
CID,EID, DATA = data
print(data, len(data))
#print('connected > evt:{} id:{} eid:{} data:{}'.format(event,CID,EID,DATA))
bt.irq(bt_irq)
def adv_encode(adv_type, value):
return bytes((len(value) + 1, adv_type,)) + value
def adv_encode_name(name):
return adv_encode(0x09, name.encode())
def adv():
bt.gap_advertise(100, adv_encode(0x01, b'\x06') + adv_encode(0x03, b'\x0d\x18') +
adv_encode(0x19, b'\xc1\x03') + adv_encode_name('newname'))
def send(val=0):
# b'\x00\x42'
ba = bytearray(2)
ba[1]=val
bt.gatts_notify(64, HR, ba)
adv()