Adafruit NRF52 BLE Example - Gists · GitHub
Maybe your like
I use PlatformIO for most of my embedded dev these days, rather than the Arduino IDE. I find it to be a generally better experience. But I hacked this example together originally for use with Arduino IDE, since that's more common for hobbyist developers.
If you're like me, and you want to use this example with PlatformIO, there are a couple of things you'll want to do. First is to use pio init to create a new project. Once you've got that, add this to the project's platformio.ini:
[env:adafruit_feather_nrf52832] platform = nordicnrf52 board = adafruit_feather_nrf52832 framework = arduino upload_protocol = nrfutilNote that is is using the current, upstream version of the PIO nordicnrf52 platform (which was needed as of 7/24/19, because it includes the Adafruit BSP version 0.11.1).
That will set up the device target and uses the develop version of the Nordic nRF52 board support in PlatformIO (required as of 3/3/19, as the Adafruit Feather support hasn't been included in a release yet). This will use the current production release of the Adafruit Feather nRF52 board support from PlatformIO. Note: Release 3.4.0 of platformio-nordicnrf52 has a bug that will attempt to force the inclusion of the nrfjprog utility. On most platforms, this is not an issue. I run most of my PlatformIO code from a Raspberry Pi, however, and nrfjprog isn't available for ARM-based systems (I rely on adafruit-nrfutil instead).
PlatformIO can handle .ino files, but I prefer to use more standard C++ .cpp files for Arduino projects. So the next step is to copy the contents of adafruit_nrf52_example.ino into src/main.cpp in the project. You will need to include the Arduino framework, too, so append the following above the other #include statements:
#include <Arduino.h>Lastly, because this is real C++ and not the Arduino IDE, the functions used in the code need to get defined, so create include/main.h and put this in it:
#include <Arduino.h> bool getUniqueID(); void setUniqueID(); void writeState(); uint8_t readState(); void setState(); void connectCallback(uint16_t handle); void disconnectCallback(uint16_t handle, uint8_t reason);You'll need to make sure main.h is used, so append this after the other includes at the top of main.cpp:
#include "main.h"With this done, everything should be set and you can get all of the needed dependencies and build the example with:
$ pio runAssuming that works (I've tested it, so it should), you can deploy this code to an Adafruit nRF52 Feather with
$ pio run -t uploadTag » Arduino Nrf52 Ble Example
-
Arduino BLE Examples | Bluefruit NRF52 Feather Learning Guide
-
Arduino BLE Examples | Introducing The Adafruit NRF52840 Feather
-
Very Low Power BLE Made Easy With Arduino -- Part 1 - Instructables
-
Arduino BLE Example - Evothings
-
Nrf52 - Arduino Library List
-
BLE Multi Role On Nano 33 BLE - NRF52 - Arduino Forum
-
NRF52 Bluetooth (BLE) Tutorial. Does It Consume Less ... - YouTube
-
Part 1 – Developing NRF52840 Application | Arduino Nano 33 BLE ...
-
Nordic NRF52 — PlatformIO Latest Documentation
-
Connect Two Nrf52832 Using BLE - Nordic Q&A
-
Nordic NRF52840 Advanced Bluetooth 5 With Arduino IDE
-
NimBLE-Arduino: Overview - GitHub Pages
-
NRF52832 Breakout Board Hookup Guide - Sparkfun Learn
-
NRF52 Boards - Arduino-FOC