Arduino Nano 33 BLE Sense is not detected as a Bluetooth device

I connected a 0-5V output sensor to Arduino Nano 33 BLE Sense and uploaded the following code to record the sensor measurement signal via Bluetooth communication on the iPhone using the LightBlue app. The upload process went smoothly without any issues. However, the device is not being detected on the phone (and not on other laptops either). What could be the reason for this?


#include <ArduinoBLE.h>

const int analogPin = A0;
float x0;
unsigned long Time;

BLEService bleService("19B10000-E8F2-537E-4F6C-D104768A1214"); 
BLEFloatCharacteristic yCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLENotify); 
BLEUnsignedLongCharacteristic timeCharacteristic("19B10002-E8F2-537E-4F6C-D104768A1214", BLERead | BLENotify); 

void setup() {
  Serial.begin(115200);
  while (!Serial);

  //
  BLE.setLocalName("FSRArduinoBLE"); // 
  BLE.setAdvertisedService(bleService);

  // 
  bleService.addCharacteristic(yCharacteristic);
  bleService.addCharacteristic(timeCharacteristic);
  BLE.addService(bleService);

  // Advertising 
  BLE.advertise();
  
  // advertise() 
  BLE.advertise();
}

void loop() {
  x0 = analogRead(analogPin) * 5.0 / 1023.0;
  Time = millis();

  yCharacteristic.writeValue(x0);
  timeCharacteristic.writeValue(Time);
  
  delay(100); 
}


Don't confuse BLE and Bluetooth. They use completely different protocols.

Have you opened the Serial monitor with the Nano 33 BLE? If not, the sketch will stop before any BLE activity begins which can be seen by the phone.

I have resolved the issue mentioned above. There was a problem with the sketch code. I have made overall modifications to the code as follows and successfully paired and verified data using the nRF Connect app instead of LightBlue on the iPhone. For those who might be facing similar issues, I am leaving the final code below:

#include <ArduinoBLE.h>

// Define Bluetooth service and characteristic UUIDs
#define SERVICE_UUID        "your own UUID"
#define CHARACTERISTIC_UUID "your own UUID"

const int analogPin = A0;
unsigned long previousMillis = 0;
const long interval = 100; // Sampling and Bluetooth transmission interval (0.1 seconds - 100ms)

BLEService dataService(SERVICE_UUID);
BLEFloatCharacteristic dataCharacteristic(CHARACTERISTIC_UUID, BLERead | BLENotify);

void setup() {
  Serial.begin(9600);
  pinMode(analogPin, INPUT);

  // Initialize Bluetooth
  if (!BLE.begin()) {
    Serial.println("Failed to initialize Bluetooth!");
    while (1);
  }

  // Register Bluetooth characteristics
  BLE.setLocalName("FSRNano33BLE"); // Bluetooth device name visible during search
  BLE.setAdvertisedService(dataService);
  dataService.addCharacteristic(dataCharacteristic);
  BLE.addService(dataService);

  // Start Bluetooth
  BLE.advertise();

  Serial.println("Bluetooth started! Check data on your smartphone.");
}

void loop() {
  // Calculate current time
  unsigned long currentMillis = millis();

  // Read analog sensor value and transmit it via Bluetooth at regular intervals
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;

    // Read analog sensor value and convert 0~5V range to 0.0~1.0
    float sensorValue = analogRead(analogPin);
    float voltage = sensorValue * (5.0 / 1023.0);

    // Transmit sensor value via Bluetooth
    dataCharacteristic.writeValue(voltage);

    // Output to Serial Monitor as well
    Serial.print("Voltage(V): ");
    Serial.println(voltage);
  }

  // Handle Bluetooth events
  BLE.poll();
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.