ImportError: No module named 'bluetooth'
Port, board and/or hardware
XIAO Seeed Sense BLE nrF52840
MicroPython version
MicroPython v1.23.0 on 2024-06-02; XIAO nRF52840 Sense with NRF52840
Reproduction
import bluetooth
Expected behaviour
Run the code
Observed behaviour
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: no module named 'bluetooth'
Additional Information
I'm using a XIAO Seeed Sense BLE nrF52840 in Micropython where I want to initialize BLE communication but when I try to run the code I get an error that says "ImportError: no module named 'bluetooth'"
Code of Conduct
Yes, I agree
zephyr: Add Seeed Studio's XIAO BLE NRF52840 SENSE board.
Summary
This PR adds Zephyr support for Seeed Studio's XIAO BLE NRF52840 SENSE board.
It also provides a good example of a richer Zephyr port than the default, adding:
- Frozen modules (including
asyncio,upysh,aioble,neopixel, andaiorepl). - Enough MicroPython features to support using
aioble(at least for thetemp_sensor.pyexample) - JSON,
random,re,struct, etc. - Support for my Zephyr ADC code (see PR #17615)
- Mounted LFS2 filesystem using the 2MiB flash mounted as
/flash
You can build it in the usual way:
$ cd ports/zephyr
$ west build -b xiao_ble/nrf52840/sense .
This will produce a .uf2 file in build/zephyr/zephyr.uf2 that can be copied into the XIAO-SENSE USB drive that appears when you double-click the RESET button.
Testing
I have tested this on several of these boards, with and without my ADC (#17615) and zensor.Sensor.attr_set() (#17653) PRs.
I have run the aioble temp_sensor.py example but haven't done much more with the BLE.
Trade-offs and Alternatives
The build size is as follows:
Memory region Used Size Region Size %age Used
FLASH: 428864 B 788 KB 53.15%
RAM: 165908 B 256 KB 63.29%
IDT_LIST: 0 GB 32 KB 0.00%