Nordic UART not working on ESP32-C6 #17116
Answered
by
shariltumin
ondrejkarpis
asked this question in
ESP32
-
I tried basic BLE UART example with ESP32-C6-DevKitC-1 and it doesn't work. When I use a BLE scan app, it is not able to discover any UART service (just the Generic Access 1800, Generic Attribute 1801, and Service FFE0). import bluetooth
class BLE():
def __init__(self, name):
self.name = name
self.ble = bluetooth.BLE()
self.ble.active(True)
self.ble.irq(self.ble_irq)
self.register()
self.advertiser()
def ble_irq(self, event, data):
if event == 1:
print('Connected')
elif event == 2:
self.advertiser()
print('Disconnected')
elif event == 3:
buffer = self.ble.gatts_read(self.rx)
message = buffer.decode('UTF-8').strip()
print(message)
def register(self):
# Nordic UART Service (NUS)
NUS_UUID = '6E400001-B5A3-F393-E0A9-E50E24DCCA9E'
RX_UUID = '6E400002-B5A3-F393-E0A9-E50E24DCCA9E'
TX_UUID = '6E400003-B5A3-F393-E0A9-E50E24DCCA9E'
BLE_NUS = bluetooth.UUID(NUS_UUID)
BLE_RX = (bluetooth.UUID(RX_UUID), bluetooth.FLAG_WRITE)
BLE_TX = (bluetooth.UUID(TX_UUID), bluetooth.FLAG_READ | bluetooth.FLAG_NOTIFY)
BLE_UART = (BLE_NUS, (BLE_TX, BLE_RX,))
SERVICES = (BLE_UART, )
((self.tx, self.rx,), ) = self.ble.gatts_register_services(SERVICES)
def send(self, data):
self.ble.gatts_notify(0, self.tx, data + '\n')
def advertiser(self):
name = bytes(self.name, 'UTF-8')
print('Advertising',name)
self.ble.gap_advertise(100, bytes([0x02, 0x01, 0x02]) + bytes([len(name) + 1, 0x09]) + name)
ble = BLE("ESP32 uart")
while True:
pass |
Beta Was this translation helpful? Give feedback.
Answered by
shariltumin
Apr 23, 2025
Replies: 1 comment 3 replies
-
Try changing your self.ble.gap_advertise(100, adv_data=b'\x02\x01\x06' +
bytes([len(name) + 1, 0x09]) +
name) I tested it on ESP32-C3 and it works. It should also work on ESP32-C6. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am sorry to hear that it is still not working for you.
I downloaded and flashed the latest firmware to my ESP32C6 board.
Here is the result of my test:
I was using the "Serial Bluetooth Terminal" app on an old Android phone.
The difference between your code and the one I used: