Arduino launches yet another round of innovation for the IoT world. The Nano 33 Sense BLE is loaded with environment monitoring sensors whose data it can stream over to a host using Bluetooth communication protocols. It is the ideal platform to assess mobile solutions that can take advantage of input from gestures and sound. As with the majority of Arduino platforms, development is conducted using the versatile Integrated Development Environment (IDE) or cloud interfaces. The micro-controller for the board is nRF52480 by Nordic Semiconductor.
This note is the first in a series of simple exercises to explore the libraries that interface with the on-board sensors such as:
- Inertial measurement unit (IMU) with 9 axes (degrees of freedom)
- Temperature
- Pressure
- Humidity
- Light
- Color
- Microphone
Since the sensors are mounted on the board, there is a faster learning curve since debugging connecting wires on a breadboard is redundant. The board used in these exercises came with the headers mounted – again eliminating the need for post-purchase soldering adventures (for the uninitiated). For more custom solutions, one can purchase a model without the headers.
The MicrocomputerThis project is the start of several self-paced training exercises that will illustrate the use of the libraries for the Nano 33:
- NINA B306 for Bluetooth
- LSM9DS1 for IMU
- LPS22HB for barometric pressure and environmental temperature
- HTS221 for humidity
- ADPS-9960 for proximity, light, RGB and gesture sensor
- MP34DT05 for microphone
This note examines only the NINA B306library for Bluetooth connectivity.
NINA B306The chip-set from u-blox for standalone Bluetooth 5 low energy has its antenna radiation patterns illustrated in the corresponding data-sheet. There are 28digital pins.
Power ModesThere are three power modes for the module:
- Active
- Standby
- Sleep
The module supports the following serial communication interfaces:
- Universal Asynchronous Receiver/Transmitter (UART), 4-wire, 2x
- Serial Peripheral Interface (SPI),3x
- Queued Serial Peripheral Interface (QSPI), 1x
- Inter-Integrated Circuit (I2C), 2x
- Inter-IC Sound (I2S), 1x
- Universal Serial Bus (USB), 2.0, 1x
There are two key digital interfaces:
- Pulse Width Modulation (PWM)
- Pulse Density Modulation (PDM)
There are 12independent PWM channels to control:
- Motors
- Light Emitting Diode (LED)
- Audio signals
Each channel uses a single General-purpose input/output (GPIO) pin for output signal.
PDMPDM in the current application is primarily for use with the digital microphone for 16-bit samples at 16 kHz rate. It supports single or dual channel data over a single GPIO pin.
Analog InterfacesUsing 8 from 38 digital GPIOs, the analog operations are supported through the following functions:
- Analog-to-Digital (ADC), 8-channel, 1x
- Full swing input range from 0 V to VCC
- 8/10/12-bit resolution
- 14-bit resolution with oversampling
- Upto 200 kHz sample rate
- Single shot or continuous sampling
- Two operation modes:
- Single-ended with a single input pin
- Differential with two input pins and the voltage level difference between them is sampled
- Either: Analog comparator, 1x
- Or: Low-power analog comparator, 1x
For the limited purposes of this note, the commands are examined for the Bluetooth functions in the sample code only that introduces the client-server operation which in combination with the notify characteristic becomes and publish-and-subscribe model.
The introductory example illustrates the use of the library withthe following classes:
- BLE
- BLECharacteristic
- BLEService
The primary class in the library to enable Bluetooth services forthe device is BLE (Bluetooth Low Energy or Bluetooth Smart).The key interfaces used in the sample code are illustrated below:
The begin method initializes the BLE device upon which itreturns 1 for success or 0 for failure.
endThe end method stops the BLE device.
addServiceThe addService method adds a BLE service to the set of services provided by the BLE device.
setLocalNameThe setLocalName method sets the local value (i.e.text string) that is used to advertise the BLE device.
advertiseThe advertise method initiates the advertising of the BLEdevice for service.
BLECharacteristicThe BLECharacteristic class permits the settings for the services at the device.
The BLECharacteristic constructor for this class createsa new BLE characteristic for the device.
writeValueThe writeValue method, as the name implies, writes thevalue of the specified BLECharacteristic.
valueThe value method, queries the current value of specified BLECharacteristic for the BLE device.
BLEServiceThe BLEService class enables the services of the BLE device.
BLEServiceThe BLEService constructor instantiatesa new BLE service for the BLE device using the uuid stringpassed as parameter to the method.
The following uuid string references the LED service:
"19B10000-E8F2-537E-4F6C-D104768A1214"
addCharacteristicThe addCharacteristicmethod adds a bleCharacteristic to the instantiated servicefor the BLE device.
The bleCharacteristic parameter is set by instantiating from the corresponding class as shown below:
BLEChacteristic ledCharacteristic(uuid, option)
BLEChacteristic buttonCharacteristic(uuid,option)
where option is the union of any of the following modes:
- BLENotify
- BLERead
- BLEWrite
All projects in this introductory set of basic and elementary projects, the microcomputer board and the breadboard are mounted on abase-plate. The advantages of this base-plate are:
- A recessed profile to eliminate exposure to the bottom side
- Sufficient screws to mount Arduino (UNO or Mega) or RaspberryPi boards
- Pre-drilled aligned holes for accompanying screws
- Holes to restrain the base-plate on a table
- Full size breadboard slot
The image below illustrates the mounts for the Nano33 in the middle of the full-size breadboard with the push button to the edge to facilitate the insertion of other components and associated wiring for future exercises.
The diagram below illustrates the schematic for the elementary exercise to test the ultrasonic sensor:
The assembly diagram below illustrates a proposed layout for the exercise:
Digital Proximity, Ambient Light, RGB and Gesture Sensor
Capacitive Digital Sensor for Relative Humidity and Temperature
Comments