How would I get the nrFToolbox for BLE app to use Arduino code written using the ArduinoBLE library?

How would I get the nrFToolbox for BLE app to use Arduino code written using the ArduinoBLE library?

For reference, I am using the Arduino Nano 33 BLE Sense board.

At the moment, I can get the nrFToolbox app to recognize the board as a Bluetooth device, but that’s about it. I would like to able to use the app to get data about the temperature and display it.

#include <Arduino_LPS22HB.h> //Pressure sensor, documentation found on https://www.arduino.cc/en/Reference/ArduinoLPS22HB
#include <Arduino_HTS221.h>  //Temperature sensor, documentation found on https://www.arduino.cc/en/Reference/ArduinoHTS221
#include <ArduinoBLE.h>      //Bluetooth LE sensor, documentation found on https://www.arduino.cc/en/Reference/ArduinoBLE


// Service for the BLE module, using a 128-bit UUID.
BLEService TestService("32BC370F-88AF-4928-B8AB-9B56902FA670");

//TODO: BLE temperature characteristic

//TODO: BLE humidity characteristic

//TODO: BLE pressure characteristic

void setup() {
// put your setup code here, to run once:
    Serial.begin(9600); //Initialize the serial connection
    while(!Serial); //Will pause until a serial connection is established.

    if (!BARO.begin() ) { //Initialize the barometer
    Serial.println("Unable to initialize the barometer, stopping.");
    while (1);
    }
    if (!HTS.begin() ) { //Initialize the Temperature & Humidity sensor
        Serial.println("Unable to initialize the temp/humidity sensor, stopping.");
        while (1);
    }
    if (!BLE.begin() ) { //Initialize the bluetooth module
        Serial.println("Unable to initialize the bluetooth module, stopping");
        while (1);
    }


    /* Set a local name for the BLE device
    This name will appear in advertising packets
    and can be used by remote devices to identify this BLE device
    The name can be changed but maybe be truncated based on space left in advertisement packet
    */
    BLE.setLocalName("TestDevice");
    BLE.setAdvertisedService(TestService); // add the service UUID



}

void loop() {
// put your main code here, to run repeatedly:
    Serial.print("Temperature: ");
    Serial.print(HTS.readTemperature(FAHRENHEIT));
    Serial.print(" -- Humidity: ");
    Serial.print(HTS.readHumidity() );
    Serial.print(" -- Pressure: ");
    Serial.println(BARO.readPressure() );
    delay(1000);
}


Source: StackOverflow C++

LEAVE A COMMENT