The use case is to control and monitor a fan. A Nano RP2040 at the fan is to receive commands from a nearby Raspberry Pi (RPi) and is to send periodically status reports to the same RPi using Bluetooth. The first tests to use Bluetooth on the Nano did fail.
The Nano is running CircuitPython 7.1.0. Module adafruit_ble is copied from library adafruit-circuitpython-bundle-py-20220114.zip to the directory CIRCUITPY/lib on the Nano RP2040. The following test program, taken from the documentation of module adafruit_ble, is used.
from adafruit_ble import BLERadio ble = BLERadio() print("scanning") found = set() scan_responses = set() for advertisement in ble.start_scan(): addr = advertisement.address if advertisement.scan_response and addr not in scan_responses: scan_responses.add(addr) elif not advertisement.scan_response and addr not in found: found.add(addr) else: continue print(addr, advertisement) print("\t" + repr(advertisement)) print() print("scan done")
When run, it immediately stops with the following error message:
File "<stdin>", line 3, in <module> File "adafruit_ble/__init__.py", line 146, in __init__ RuntimeError: No adapter available
Inspection of method BLERadio.init shows that the method can't find property _bleio.adapter. The output of
import _bleio dir( _bleio )
shows that 'adapter' is not defined. However 'Adapter' is defined
The test program is changed slightly, to invoke BLERadio with adapter _bleio.Adapter. Even with this modification, the test program crashes immediately:
scanning Traceback (most recent call last): File "<stdin>", line 8, in <module> File "adafruit_ble/__init__.py", line 250, in start_scan TypeError: function missing 1 required positional arguments
At line 250 method start_scan of object _bleio.Adapter is invoked. All the available parameters are specified, still there seems to be one parameter missing.
Does module _bleio for the nano RP2040 use the wrong name, that is 'Adapter' in stead of 'adapter'?
More importantly, how do I get Bluetooth working on a Nano RP2040 using CircuitPython?