The Nano 33 BLE adds Bluetooth Low Energy (BLE) capabilities to your projects, in a very small PCB footprint. It supports BLE, Bluetooth and NFC connectivity.
In this guide, you’ll learn how to develop applications to run on the board, learning how to program the Nano 33 BLE as a BLE beacon that broadcasts a greeting message that can be read on a mobile phone.
Connecting higher voltage signals, like the 5V commonly used with the other Arduino boards, will damage the Arduino NANO 33 BLE.
Before you start programming you’ll need to configure the IDE to work with your specific Arduino model.
The green power LED on the Arduino will come on and the orange LED will be flashing, indicating that the board is powered up and running the default Blink sketch which comes pre-installed
The COM or modem port number will vary depending on your host computer.
Copy the code example below into the IDE window
/*
Arduino Nano 33 BLE Getting Started
BLE peripheral with a simple Hello World greeting service that can be viewed
on a mobile phone
Adapted from Arduino BatteryMonitor example
*/
#include <ArduinoBLE.h>
static const char* greeting = "Hello World!";
BLEService greetingService("180C"); // User defined service
BLEStringCharacteristic greetingCharacteristic("2A56", // standard 16-bit characteristic UUID
BLERead, 13); // remote clients will only be able to read this
void setup() {
Serial.begin(9600); // initialize serial communication
while (!Serial);
pinMode(LED_BUILTIN, OUTPUT); // initialize the built-in LED pin
if (!BLE.begin()) { // initialize BLE
Serial.println("starting BLE failed!");
while (1);
}
BLE.setLocalName("Nano33BLE"); // Set name for connection
BLE.setAdvertisedService(greetingService); // Advertise service
greetingService.addCharacteristic(greetingCharacteristic); // Add characteristic to service
BLE.addService(greetingService); // Add service
greetingCharacteristic.setValue(greeting); // Set greeting string
BLE.advertise(); // Start advertising
Serial.print("Peripheral device MAC: ");
Serial.println(BLE.address());
Serial.println("Waiting for connections...");
}
void loop() {
BLEDevice central = BLE.central(); // Wait for a BLE central to connect
// if a central is connected to the peripheral:
if (central) {
Serial.print("Connected to central MAC: ");
// print the central's BT address:
Serial.println(central.address());
// turn on the LED to indicate the connection:
digitalWrite(LED_BUILTIN, HIGH);
while (central.connected()){} // keep looping while connected
// when the central disconnects, turn off the LED:
digitalWrite(LED_BUILTIN, LOW);
Serial.print("Disconnected from central MAC: ");
Serial.println(central.address());
}
We encountered some issues where the Arduino changed its port after uploading. If so check the Board>Port setting is correct.
The Nano will start sending BLE advertising packets and wait for a Central (Mobile Phone) to connect.
In the nRF App on your mobile select Scan and you should see Nano33BLE as a device you can connect to.
BLE Peripherals can only connect to one device at a time – if the Nano33BLE is already connected it could be to another device nearby.
Congratulations! You have set up the Arduino IDE for use with your NANO 33 BLE board and configured it to act as a BLE Peripheral device that broadcasts a simple message using the BLE standard.
The Nordic Semiconductors nRF Connect App is a very useful tool for working with BLE devices to view the information they are broadcasting. You can drill down through the BLE services to individual characteristics and the data they contain.
You can explore many more examples available from within the IDE by opening them from File -> Examples. These can give you a starting point to modify and adapt code for your own projects.
From a quick tap to smashing that love button and show how much you enjoyed this project.