I recently had a project idea that would benefit greatly from a low power Bluetooth Low Energy capable MCU.
Picture this: Running a BLE Microcontroller on a coin cell for years. With the nRF52 and the newer nRF54L series, this doesn’t have to stay a dream.
So I ordered various Modules for this undisclosed project:
- MinewSemi MS88SF3 (very small nRF52840 pre-certified module)
- some Nice!Nano Clone from Amazon
I’m still on the fence whether to use the nRF52 or nRF54 Series. But I’ll prototype on the nRF52 and moving the code to the newer chip shouldn’t be too much of a hassle.
Setup - nRF Connect SDK
I recommend the nRF Connect SDK Extension for VS Code, which also works great so far on Code OSS, an Open Source Version of VS Code without all the Microsoft telemetry.
Install the code-marketplace package from the AUR to get all Extensions that are available through Microsoft!
My OSS Code tells me the “C/C++ Extension by Microsoft” will only work in the official VS Code build, but so far this was just a warning, everything works as expected!
Setup - Arduino IDE
While I wasn’t able to build anything with the professional nRF Connect SDK for I lack the J-Link Probe, I decided to try my luck with in the Arduino IDE.
Adafruit nRF52840 Feather Express
That’s at least what shows up when I connect the board to my Computer. I grabbed Adafruit’s custom board file link and added it in my Arduino IDE config:
https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
Afterward, in the Board Manager, add the Adafruit nRF52 Library and you are set!
Linux Oddities
For Linux Users, there’s an additional setup step: the Adafruit custom build of the nrfutil package.
Simple,
I though.
Just grab it via pip:
pip3 install --user adafruit-nrfutil
# I'm using Arch/Manjaro, so I got:
error: externally-managed-environment
Ok, I’ll just install it via pacman directly. But it’s not available, so back to the AUR it is.
For some reason yay -S python-adafruit-nrfutil sent me straight to dependency hell.
It wasn’t able to install these specific dependencies:
python-behavewhich depends onpython-cucumber-tag-expressions
At some point I got the error that python-uv-build couldn’t be installed,
But I can’t find this dependency listed on any of those packages in the AUR.
To our rescue: the humble python virtual environment: I simply installed all these dependencies in a virtual environment I already had set up as a kind of development environment for all kinds of projects. Specifically, I needed these dependencies:
pip install build installer uv-build
And I was finally able to run yay in this environment, which built the python-adafruit-nrfutil package correctly.
Huzzah!
Arduino IDE can now properly upload code to these neat little dev boards.
Hello World over BT
I simply selected one of the Example Sketches included with the Adafruit nRF52 board library: the Peripheral → Beacon Example.
⚠️ EDIT: Remember to select the “Adafruit nRF52840 Feather Express” as a Board first, before hunting for the correct Example in the menus. It won’t show up unless the right Board has been selected.
I can highly recommend the nRF Connect App for Mobile to play with the nRF5x Ecosystem. That app, over a long time of struggle setting this all up, finally showed me the nRF52840 Feather Express was advertising over BLE!
Next Steps
To further my upcoming project, I’ll try integrating an accelerometer and gyroscope with BLE Connectivity to send rotation data to an Application. I might stick to the Arduino IDE for now, but the nRF Connect SDK for (VS)Code allows for Graphical Pin Mapping and so much more.
This is a quick article, but I do hope this is useful for some at least…
Some more thoughts
Custom Bootloaders, as found on this Adafruit nRF52840 Feather Express or Nice!Nano Clone (IDK what it really is) and many more dev boards, try to make it easy for us developers and hobbyists to get started. And I like the thought of that.
There is still so much f***ing around involved in making these work.
Some of these abstractions of the underlying SDK and many of the MCU’s Special Hardware Peripherals tend to turn the microcontroller into a black box.
Arduino is super simple to get into, but along your journey you will undoubtedly encounter weird faults and error messages with special hardware and software combinations. It’s a shame really, that this dream of an easy to use but still powerful IDE is not more but a dream.
So make your choice:
use the Arduino IDE and trade away special Hardware functions (for some libraries) and understanding, for significantly easier programming,
or,
use the professional programming Environments and gain superb Hardware access via provided Libraries from the manufacturer, but gain a harder time actually writing the code (and understanding it!).
I strongly encourage thee to taketh thy dev board and experience the warmth (and often suffering) of developing with vendor provided tools.