The Arduino Nano 33 BLE Sense was released in July 2019 and was a real step up for Arduino! Using the Arm Cortex-M4F based nRF52840, the Nano 33 BLE’s arrival made the days of Atmel based 8-bit microcontrollers seem numbered. With more complex offerings such as the Nano 33 series, a new era of seriously cool projects may be on the horizon.
Previously in The Hacky Super Loop Arduino Nano 33 BLE Sense Example You Have Been Waiting For I attempted to address the lack of meaningful working examples for this board. The interfaces for each sensor are not always ideal, and no concrete examples are widely available that enable uses to utilise Mbed OS to gather sensor values.
The ability to use Mbed OS with Arduino is a real step up for Arduino. Finally, a reasonably performant and relatively deterministic way of arranging our more complex Arduino projects! In attempt to simplify the collection of sensor data and at the same time utilise the power of Mbed OS, Nano33BLESensor was born.
The Nano33BLESensor LibraryNano33BLESensor leverages Mbed OS to automatically place sensor measurements in a ring buffer that can be integrated into programs in a simple manner. This means Nano33BLESensor takes care of placing measurements in to the buffer “in the background”, and your program can retrieve them from the buffer at a later time when your program has time. It can be found on GitHub here. It can also be found using Arduino’s Library Manager, and available when searched for when using the Arduino IDE. Simple examples also exist to help get people started.
Nano33BLESensor Features- Class implementation with common interface for all of the sensors found on the Arduino Nano 33 BLE Sense (3-axis Accelerometer, 3-axis Gyroscope, 3-axis Magnetic, RMS Microphone, Barometric Pressure, Temperature, Humidity, Proximity, RGBC Colour, and Gesture).
- Mbed OS usage, allowing easy integration with programs.
- Ring buffer usage, allowing the softening of time constraints in regard to the reading sensor measurements.
- Excellent examples for all sensors designed for BLE and Serial Plotter that help you to get started.
In the end, the result of this is:
- Super simple initialisation of on board sensors.
- No code required beyond initialisation for collection of sensor data.
- Super simple usage of sensor data.
- Common interface among different sensors.
- Using Mbed OS effectively makes the reading of sensor measurements happen “in the background”, and keeps it out of the main program loop.
The Nano33BLESensor Library comes with a series of powerful examples that include sensor measurement data output using both Serial and Bluetooth. It is possible to view this data at the same time using Arduino’s Serial Plotter and a Bluetooth packet analysis tool such as Bluetooth LE Explorer. Some of the examples available on the GitHub repository are as follows:
Below are the results of a few of those examples.
How Nano33BLESensor Simplifies Sensor UsageHere are a couple of examples of how Nano33BLESensor simplifies the collection of sensor data with the Nano 33 BLE Sense. For the full API, you can checkout the GitHub repository.
Accelerometer
#include "Nano33BLEAccelerometer.h"
Nano33BLEAccelerometerData accelerometerData;
void setup()
{
Accelerometer.begin()
}
void loop()
{
if(Accelerometer.pop(accelerometerData))
{
Serial.printf("%f,%f,%f\r\n", accelerometerData.x, accelerometerData.y, accelerometerData.z);
}
}
Colour
#include "Nano33BLEColour.h"
Nano33BLEColourData colourData;
void setup()
{
Colour.begin()
}
void loop()
{
if(Colour.pop(colourData))
{
Serial.printf( "%d,%d,%d,%d\r\n", colourData.r, colourData.g, colourData.b, colourData.c);
}
}
Temperature
#include "Nano33BLETemperature.h"
Nano33BLETemperatureData temperatureData;
void setup()
{
Temperature.begin()
}
void loop()
{
if(Temperature.pop(temperatureData))
{
Serial.printf("%f,%f\r\n", temperatureData.temperatureCelsius, temperatureData.humidity);
}
}
Comments