Micropython and Bluetooth on the nRF chip

A few months ago I bought a Seeed XIAO BLE nRF52840 because of the bluetooth features. I did a first exploration of this chip with Micropython. My plan was to replace the Raspberry Pi Pico Heartrate display I build a while ago.

Meanwhile my Watch got an Update that solved this issue for me completly. Coros added the possibility to mirror the watch in the Android App. This even shows the (estimated) stroke rate.

img1

Before knowing about this I fiddled with the ubluepy code in Micropython. I didn't figure out how to read the heartrate values.

The nRF chip doesn't have the "normal" bluetooth module and therefore aioble doesn't work. Most of the examples out there use aioble though. Micropython plans to merge all the bluetooth code , so maybe in the future there is a working solution.

This is how far I got:

import time
from ubluepy import Scanner, constants, Peripheral
def get_node():
    for _ in range(10):
        s = Scanner()
        for node in s.scan(500):
            scan = node.getScanData()
            if scan:
                for entry in scan:
                    # find the sensor that starts with TICKR
                    if entry[0] == constants.ad_types.AD_TYPE_COMPLETE_LOCAL_NAME and entry[2].startswith("TICKR"):
                        print(f"NODE found:", entry[2])
                        return node
        time.sleep_ms(100)

# get device
dev = get_node()
print(dev.addr())
# returns: eb:d4:07:40:52:a0 -- the address I used in my Raspberry PI code -- good until here
p = Peripheral()
# and this here hangs forever
p.connect(dev.addr())

So the connect doesn't work and I don't know what to change, or if this even should work. Seems for me that this is not fully implemented in the ubluepy stack for the nRF chip. The examples in the Micropython github are mostly for advertising sensors and none for actually reading values from a (BLE) sensor.