In this tutorial we are going to see an example of using Bluetooth Low Energy technology using the Arduino MKR WiFi 1010 and Arduino Nano 33 BLE Sense boards together with the ArduinoBLE library. Specifically, we are going to show an example of how you can subscribe to a characteristic of a service.
The Bluetooth on the Arduino Nano 33 BLE Sense is managed by the NINA B306 module (Bluetooth 5.0 qualification).
In the Arduino MKR WiFi 1010, Bluetooth is managed by the NINA -W102 module (Bluetooth 4.2 qualification).
The following links explain the basic concepts of Bluetooth Low Energy technology that will help us understand how it works:
https://www.arduino.cc/en/Reference/ArduinoBLE
https://learn.adafruit.com/introduction-to-bluetooth-low-energy/introduction
In this project we will see how the central device will subscribe to a characteristic of a peripheral device service and will only receive information on the value of this characteristic in case its value is updated, in this way the central device will not have to request the value constantly.
To illustrate with an example what was explained above, we will mount a metal structure with a servomotor that will hold a hand drawn on paper that will move depending on the movement detected by the gesture sensor present on an Arduino NaNo 33 BLE Sense board.
The operation will be as follows:
The central device will connect to the peripheral device looking for the characteristic of the specified service to which you want to subscribe.
Once the connection is established if the gesture sensor of the Arduino Nano 33 BLE Sense (ADPS-9960) detects any of the following movements: UP, DOWN, LEFT and RIGHT, the peripheral device will write the corresponding value (associated with these movements) in the characteristic of the service whose central device is subscribed causing the servo motor to move in the direction marked by the movement (we will only consider the movements of UP, LEFT and RIGHT, the “DOWN” movement will be ignored).
NOTE: The latest version of the ArduinoBLE library is required.
Peripheral device: Arduino Nano 33 BLE Sense
Comments