Which BLE Library to use for the NanoESP2?

I have been experimenting with the RemoteXY and bluetooth with my Arduinos. It works fine with the UnoR4Wifi but the seems to be library issues with the NanoESP32. Whe I upload the generated code for the NanoESP32 I get the warning :

In file included from /tmp/.arduinoIDE-unsaved2024105-78768-10g011s.4ta5/sketch_nov5a/sketch_nov5a.ino:35:
/tmp/.arduinoIDE-unsaved2024105-78768-10g011s.4ta5/sketch_nov5a/sketch_nov5a.ino: In function 'void setup()':
/home/stevetux/Arduino/libraries/RemoteXY/src/RemoteXY.h:194:91: error: expected type-specifier before 'CRemoteXYStream_BLEDevice'
   #define RemoteXY_Init() remotexy = new CRemoteXY (RemoteXY_CONF_PROGMEM, &RemoteXY, new CRemoteXYStream_BLEDevice (REMOTEXY_BLUETOOTH_NAME), REMOTEXY_ACCESS_PASSWORD)
                                                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-78768-10g011s.4ta5/sketch_nov5a/sketch_nov5a.ino:68:3: note: in expansion of macro 'RemoteXY_Init'
   RemoteXY_Init ();
   ^~~~~~~~~~~~~
Mehrere Bibliotheken wurden für "BLEDevice.h" gefunden
  Benutzt: /home/stevetux/Arduino/libraries/ArduinoBLE
  Nicht benutzt: /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE
exit status 1

Compilation error: exit status 1

So I tried to force the sketch to use the esp32 version of the BLEDevice.h library by setting the full path to that library with #include </home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEDevice.h> instead of #include <BLEDevice.h> But then the bluetooth connection doesn't work and the warning becomes

In file included from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLECharacteristic.h:25,
                 from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEService.h:23,
                 from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEDevice.h:25,
                 from /home/stevetux/Arduino/libraries/RemoteXY/src/RemoteXY.h:145,
                 from /tmp/.arduinoIDE-unsaved2024105-78768-10g011s.4ta5/sketch_nov5a/sketch_nov5a.ino:35:
/home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEDescriptor.h:28:7: error: redefinition of 'class BLEDescriptor'
 class BLEDescriptor {
       ^~~~~~~~~~~~~
In file included from /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLECharacteristic.h:17,
                 from /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEServer.h:20,
                 from /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEDevice.h:18,
                 from /tmp/.arduinoIDE-unsaved2024105-78768-10g011s.4ta5/sketch_nov5a/sketch_nov5a.ino:28:
/home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEDescriptor.h:25:7: note: previous definition of 'class BLEDescriptor'
 class BLEDescriptor {
       ^~~~~~~~~~~~~
In file included from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEService.h:23,
                 from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEDevice.h:25,
                 from /home/stevetux/Arduino/libraries/RemoteXY/src/RemoteXY.h:145,
                 from /tmp/.arduinoIDE-unsaved2024105-78768-10g011s.4ta5/sketch_nov5a/sketch_nov5a.ino:35:
/home/stevetux/Arduino/libraries/ArduinoBLE/src/BLECharacteristic.h:45:7: error: redefinition of 'class BLECharacteristic'
 class BLECharacteristic  {
       ^~~~~~~~~~~~~~~~~
In file included from /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEServer.h:20,
                 from /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEDevice.h:18,
                 from /tmp/.arduinoIDE-unsaved2024105-78768-10g011s.4ta5/sketch_nov5a/sketch_nov5a.ino:28:
/home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLECharacteristic.h:53:7: note: previous definition of 'class BLECharacteristic'
 class BLECharacteristic {
       ^~~~~~~~~~~~~~~~~
In file included from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEDevice.h:25,
                 from /home/stevetux/Arduino/libraries/RemoteXY/src/RemoteXY.h:145,
                 from /tmp/.arduinoIDE-unsaved2024105-78768-10g011s.4ta5/sketch_nov5a/sketch_nov5a.ino:35:
/home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEService.h:28:7: error: redefinition of 'class BLEService'
 class BLEService {
       ^~~~~~~~~~
In file included from /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEServer.h:21,
                 from /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEDevice.h:18,
                 from /tmp/.arduinoIDE-unsaved2024105-78768-10g011s.4ta5/sketch_nov5a/sketch_nov5a.ino:28:
/home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEService.h:49:7: note: previous definition of 'class BLEService'
 class BLEService {
       ^~~~~~~~~~
In file included from /home/stevetux/Arduino/libraries/RemoteXY/src/RemoteXY.h:145,
                 from /tmp/.arduinoIDE-unsaved2024105-78768-10g011s.4ta5/sketch_nov5a/sketch_nov5a.ino:35:
/home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEDevice.h:39:7: error: redefinition of 'class BLEDevice'
 class BLEDevice {
       ^~~~~~~~~
In file included from /tmp/.arduinoIDE-unsaved2024105-78768-10g011s.4ta5/sketch_nov5a/sketch_nov5a.ino:28:
/home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEDevice.h:31:7: note: previous definition of 'class BLEDevice'
 class BLEDevice {
       ^~~~~~~~~
Mehrere Bibliotheken wurden für "BLEDevice.h" gefunden
  Benutzt: /home/stevetux/Arduino/libraries/ArduinoBLE
  Nicht benutzt: /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE
exit status 1

Compilation error: exit status 1

How can I use the correct BLE library for the NanoESP32?

The library is part of the hardware libraries as seen in the samples

Strangely the eamples for the NanoESP32 no longer work. It appears that the ArduinoBLE library is somehow taking preference because I get this warning with the examples:

Mehrere Bibliotheken wurden für "BLEDevice.h" gefunden
  Benutzt: /home/stevetux/Arduino/libraries/ArduinoBLE
  Nicht benutzt: /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE
exit status 1

I seem to remember that the ArduinoBLE was needed for the UnoR4Wifi. Is it true that different BLE libraries are required for different Arduino (ESP32) models? If so, how can I select the right one for each model?

Edit: The UnoR4WiFi does require the ArduinoBLE library.

Are you 100% positive you selected the ARDUINO NANO ESP32, NOT the ESP version board. Perhaps do a screen grab as below.

Why shouldn't it take preference, it is an Arduino board.
Yes, different libraries may be needed for each board, the board you select selects the correct library which can be seen in the examples drop down menu under
Examples for Arduino Nano ESP32 as I posted above.
Post all your code in code tags, screen grab the selected board.

None of the NanoESP32 examples work now. The whole error message reads:

/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:12:8: error: 'BLEUUID' does not name a type
 static BLEUUID serviceUUID("4fafc201-1fb5-459e-8fcc-c5c9c331914b");
        ^~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:14:8: error: 'BLEUUID' does not name a type
 static BLEUUID    charUUID("beb5483e-36e1-4688-b7f5-ea07361b26a8");
        ^~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:20:8: error: 'BLEAdvertisedDevice' does not name a type
 static BLEAdvertisedDevice* myDevice;
        ^~~~~~~~~~~~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino: In function 'void notifyCallback(BLERemoteCharacteristic*, uint8_t*, size_t, bool)':
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:28:42: error: invalid use of incomplete type 'class BLERemoteCharacteristic'
     Serial.print(pBLERemoteCharacteristic->getUUID().toString().c_str());
                                          ^~
In file included from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEService.h:23,
                 from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEDevice.h:25,
                 from /tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:8:
/home/stevetux/Arduino/libraries/ArduinoBLE/src/BLECharacteristic.h:43:7: note: forward declaration of 'class BLERemoteCharacteristic'
 class BLERemoteCharacteristic;
       ^~~~~~~~~~~~~~~~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino: At global scope:
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:36:52: error: expected class-name before '{' token
 class MyClientCallback : public BLEClientCallbacks {
                                                    ^
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:37:18: error: 'BLEClient' has not been declared
   void onConnect(BLEClient* pclient) {
                  ^~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:40:21: error: 'BLEClient' has not been declared
   void onDisconnect(BLEClient* pclient) {
                     ^~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino: In function 'bool connectToServer()':
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:48:20: error: 'myDevice' was not declared in this scope
     Serial.println(myDevice->getAddress().toString().c_str());
                    ^~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:48:20: note: suggested alternative: 'BLEDevice'
     Serial.println(myDevice->getAddress().toString().c_str());
                    ^~~~~~~~
                    BLEDevice
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:50:5: error: 'BLEClient' was not declared in this scope
     BLEClient*  pClient  = BLEDevice::createClient();
     ^~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:50:5: note: suggested alternative: 'DNSClient'
     BLEClient*  pClient  = BLEDevice::createClient();
     ^~~~~~~~~
     DNSClient
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:50:17: error: 'pClient' was not declared in this scope
     BLEClient*  pClient  = BLEDevice::createClient();
                 ^~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:50:17: note: suggested alternative: 'Client'
     BLEClient*  pClient  = BLEDevice::createClient();
                 ^~~~~~~
                 Client
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:50:39: error: 'createClient' is not a member of 'BLEDevice'
     BLEClient*  pClient  = BLEDevice::createClient();
                                       ^~~~~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:61:60: error: 'serviceUUID' was not declared in this scope
     BLERemoteService* pRemoteService = pClient->getService(serviceUUID);
                                                            ^~~~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:72:43: error: invalid use of incomplete type 'class BLERemoteService'
     pRemoteCharacteristic = pRemoteService->getCharacteristic(charUUID);
                                           ^~
In file included from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEDevice.h:25,
                 from /tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:8:
/home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEService.h:26:7: note: forward declaration of 'class BLERemoteService'
 class BLERemoteService;
       ^~~~~~~~~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:72:63: error: 'charUUID' was not declared in this scope
     pRemoteCharacteristic = pRemoteService->getCharacteristic(charUUID);
                                                               ^~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:72:63: note: suggested alternative: 'char'
     pRemoteCharacteristic = pRemoteService->getCharacteristic(charUUID);
                                                               ^~~~~~~~
                                                               char
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:82:29: error: invalid use of incomplete type 'class BLERemoteCharacteristic'
     if(pRemoteCharacteristic->canRead()) {
                             ^~
In file included from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEService.h:23,
                 from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEDevice.h:25,
                 from /tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:8:
/home/stevetux/Arduino/libraries/ArduinoBLE/src/BLECharacteristic.h:43:7: note: forward declaration of 'class BLERemoteCharacteristic'
 class BLERemoteCharacteristic;
       ^~~~~~~~~~~~~~~~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:83:48: error: invalid use of incomplete type 'class BLERemoteCharacteristic'
       std::string value = pRemoteCharacteristic->readValue();
                                                ^~
In file included from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEService.h:23,
                 from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEDevice.h:25,
                 from /tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:8:
/home/stevetux/Arduino/libraries/ArduinoBLE/src/BLECharacteristic.h:43:7: note: forward declaration of 'class BLERemoteCharacteristic'
 class BLERemoteCharacteristic;
       ^~~~~~~~~~~~~~~~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:88:29: error: invalid use of incomplete type 'class BLERemoteCharacteristic'
     if(pRemoteCharacteristic->canNotify())
                             ^~
In file included from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEService.h:23,
                 from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEDevice.h:25,
                 from /tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:8:
/home/stevetux/Arduino/libraries/ArduinoBLE/src/BLECharacteristic.h:43:7: note: forward declaration of 'class BLERemoteCharacteristic'
 class BLERemoteCharacteristic;
       ^~~~~~~~~~~~~~~~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:89:28: error: invalid use of incomplete type 'class BLERemoteCharacteristic'
       pRemoteCharacteristic->registerForNotify(notifyCallback);
                            ^~
In file included from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEService.h:23,
                 from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEDevice.h:25,
                 from /tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:8:
/home/stevetux/Arduino/libraries/ArduinoBLE/src/BLECharacteristic.h:43:7: note: forward declaration of 'class BLERemoteCharacteristic'
 class BLERemoteCharacteristic;
       ^~~~~~~~~~~~~~~~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino: At global scope:
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:97:72: error: expected class-name before '{' token
 class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
                                                                        ^
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:101:17: error: 'BLEAdvertisedDevice' has not been declared
   void onResult(BLEAdvertisedDevice advertisedDevice) {
                 ^~~~~~~~~~~~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino: In member function 'void MyAdvertisedDeviceCallbacks::onResult(int)':
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:103:37: error: request for member 'toString' in 'advertisedDevice', which is of non-class type 'int'
     Serial.println(advertisedDevice.toString().c_str());
                                     ^~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:106:26: error: request for member 'haveServiceUUID' in 'advertisedDevice', which is of non-class type 'int'
     if (advertisedDevice.haveServiceUUID() && advertisedDevice.isAdvertisingService(serviceUUID)) {
                          ^~~~~~~~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:106:64: error: request for member 'isAdvertisingService' in 'advertisedDevice', which is of non-class type 'int'
     if (advertisedDevice.haveServiceUUID() && advertisedDevice.isAdvertisingService(serviceUUID)) {
                                                                ^~~~~~~~~~~~~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:106:85: error: 'serviceUUID' was not declared in this scope
     if (advertisedDevice.haveServiceUUID() && advertisedDevice.isAdvertisingService(serviceUUID)) {
                                                                                     ^~~~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:108:18: error: 'getScan' is not a member of 'BLEDevice'
       BLEDevice::getScan()->stop();
                  ^~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:109:7: error: 'myDevice' was not declared in this scope
       myDevice = new BLEAdvertisedDevice(advertisedDevice);
       ^~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:109:7: note: suggested alternative: 'BLEDevice'
       myDevice = new BLEAdvertisedDevice(advertisedDevice);
       ^~~~~~~~
       BLEDevice
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:109:22: error: expected type-specifier before 'BLEAdvertisedDevice'
       myDevice = new BLEAdvertisedDevice(advertisedDevice);
                      ^~~~~~~~~~~~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino: In function 'void setup()':
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:121:14: error: 'init' is not a member of 'BLEDevice'
   BLEDevice::init("");
              ^~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:126:3: error: 'BLEScan' was not declared in this scope
   BLEScan* pBLEScan = BLEDevice::getScan();
   ^~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:126:3: note: suggested alternative: 'doScan'
   BLEScan* pBLEScan = BLEDevice::getScan();
   ^~~~~~~
   doScan
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:126:12: error: 'pBLEScan' was not declared in this scope
   BLEScan* pBLEScan = BLEDevice::getScan();
            ^~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:126:12: note: suggested alternative: 'doScan'
   BLEScan* pBLEScan = BLEDevice::getScan();
            ^~~~~~~~
            doScan
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:126:34: error: 'getScan' is not a member of 'BLEDevice'
   BLEScan* pBLEScan = BLEDevice::getScan();
                                  ^~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino: In function 'void loop()':
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:157:26: error: invalid use of incomplete type 'class BLERemoteCharacteristic'
     pRemoteCharacteristic->writeValue(newValue.c_str(), newValue.length());
                          ^~
In file included from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEService.h:23,
                 from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEDevice.h:25,
                 from /tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:8:
/home/stevetux/Arduino/libraries/ArduinoBLE/src/BLECharacteristic.h:43:7: note: forward declaration of 'class BLERemoteCharacteristic'
 class BLERemoteCharacteristic;
       ^~~~~~~~~~~~~~~~~~~~~~~
/tmp/.arduinoIDE-unsaved2024105-128338-swyvhz.qzix/BLE_client/BLE_client.ino:159:16: error: 'getScan' is not a member of 'BLEDevice'
     BLEDevice::getScan()->start(0);  // this is just example to start scan after disconnect, most likely there is better way to do it in arduino
                ^~~~~~~
Mehrere Bibliotheken wurden für "BLEDevice.h" gefunden
  Benutzt: /home/stevetux/Arduino/libraries/ArduinoBLE
  Nicht benutzt: /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE
exit status 1

Compilation error: 'BLEUUID' does not name a type

Save the file first and try verify again.

I just tried the same example and it compiles fine. Are you sure you are selecting the right board, the names are the same but the greyed out text is different.
I just tried the wrong board and it only throws one error even at msg level all.
The only other thing is what boards url you are using, here is the official entry
https://espressif.github.io/arduino-esp32/package_esp32_index.json

Here is what the Boards entry looks like

There is only one NanoESP32 for me to choose:

I am using the IDE 2.3.3

By the way, thank you for taking the time to help me withthis.

No, there is a second board identically named but since you used the old interface you didn't see that. So far so good. IIRC, I grabbed your code and it compiles just fine. You need to post the VERBOSE error log in code tags so we can see if there is an error mentioned in there somewhere. BTW, reading error logs is an art, they often do not point at the actual error that is why we need to see all of it.

What do you mean by "old interface"? I am using the very latest IDE 2.3.3.

I get the feeling I am missing something very basic here.


Whichever board I select I get the same errors.

There are two ways of selecting the board in 2.3.3, the way you did which is a carry over from 1.x and the new UI see below.



But selecting the board with the new UI and checking it is 2.0.18-20240930.arduino3 still gives the same error: Compilation error: 'init' is not a member of 'BLEDevice' for the eample sketch "BLE_Beacon_Scanner.ino

Something is messed up in your libraries, mine works fine.
Post the code in code tags again, and post the verbose error log in code tags. Tracking down errors is seldom a direct path, you need to read the entire log and sniff out the discrepancies.

I have reset the NanoESP32 using this method and uploaded some non-BLE sketches to be sure that everything is working.

The ArduinoBLE Library works with my UniR4WiFi so I am reluctant to mess with that.

If you would post a simple BLE sketch that works with your NanoESP32 then I could test that with mine and if it doesn't compile post the error log.

I used this example with Arduino NANO ESP32

/*
   Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleScan.cpp
   Ported to Arduino ESP32 by Evandro Copercini
*/

#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>

int scanTime = 5; //In seconds
BLEScan* pBLEScan;

class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
    void onResult(BLEAdvertisedDevice advertisedDevice) {
      Serial.printf("Advertised Device: %s \n", advertisedDevice.toString().c_str());
    }
};

void setup() {
  Serial.begin(115200);
  Serial.println("Scanning...");

  BLEDevice::init("");
  pBLEScan = BLEDevice::getScan(); //create new scan
  pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
  pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
  pBLEScan->setInterval(100);
  pBLEScan->setWindow(99);  // less or equal setInterval value
}

void loop() {
  // put your main code here, to run repeatedly:
  BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
  Serial.print("Devices found: ");
  Serial.println(foundDevices.getCount());
  Serial.println("Scan done!");
  pBLEScan->clearResults();   // delete results fromBLEScan buffer to release memory
  delay(2000);
}

Here is the output


16:02:07.815 -> Advertised Device: Name: , Address: 06:31:ba:cf:e2:a3, manufacturer data: 4c0002152686f39cbada4658854aa62e7e5e8b8d00010000c9, rssi: -79 
16:02:07.849 -> Advertised Device: Name: , Address: 60:7e:2a:11:58:fb, manufacturer data: 4c0009081302c0a804461b581608002d0e7ef0a17dc5, rssi: -57 
16:02:07.881 -> Advertised Device: Name: SOFA3526154BDEH, Address: ec:c5:7f:73:39:4d, serviceUUID: 0000180a-0000-1000-8000-00805f9b34fb, rssi: -87 
16:02:07.882 -> Advertised Device: Name: ihoment_H7140_6AB9, Address: d4:ad:fc:84:6a:b9, rssi: -89 
16:02:07.882 -> Advertised Device: Name: , Address: 46:4e:58:53:73:69, manufacturer data: 4c001006351e8590c601, txPower: 7, rssi: -69 
16:02:07.915 -> Advertised Device: Name: , Address: 47:24:c9:23:77:cc, manufacturer data: 2d01020001105ce61f7fb0c744c2a57fc83ad6d781db46b626978509, rssi: -76 
16:02:07.915 -> Advertised Device: Name: , Address: 65:d9:48:8e:15:dd, manufacturer data: 4c001005501cd8a6bc, txPower: 12, rssi: -85 
16:02:07.915 -> Advertised Device: Name: , Address: 4d:37:85:6e:d3:99, rssi: -70 
16:02:07.947 -> Advertised Device: Name: , Address: 5e:ae:81:e6:2b:ae, rssi: -75 
16:02:07.947 -> Advertised Device: Name: , Address: bc:7e:8b:fb:f9:12, manufacturer data: 75004204018066bc7e8bfbf912be7e8bfbf91101000000000000, rssi: -79 
16:02:07.947 -> Advertised Device: Name: , Address: 59:f9:0a:fb:60:68, manufacturer data: 4c0010064a1d6a285138, txPower: 12, rssi: -65 
16:02:07.980 -> Advertised Device: Name: Govee_H5151_6922, Address: c2:38:33:33:69:22, manufacturer data: 0188ec000101, rssi: -53 
16:02:07.980 -> Advertised Device: Name: , Address: e2:73:e7:f7:0e:b3, rssi: -76, serviceData: ��j��mM|�w��Ǟ�[ 
16:02:07.980 -> Advertised Device: Name: , Address: c8:ff:77:6c:ec:68, serviceUUID: 2dd10010-1c37-452d-8979-d1b4a787d0a4, rssi: -84 
16:02:08.013 -> Advertised Device: Name: , Address: c0:95:6d:4c:a4:20, manufacturer data: 4c001005061441e899, txPower: 12, rssi: -77 
16:02:08.013 -> Advertised Device: Name: , Address: 67:f6:f3:d5:89:1b, manufacturer data: 4c00021550765cb7d9ea4e2199a4fa879613a492e07d2609ce, rssi: -75 
16:02:08.013 -> Advertised Device: Name: GVH5103_3162, Address: ca:35:34:31:31:62, manufacturer data: 4c000215494e54454c4c495f524f434b535f48575075f2ff0c, serviceUUID: 0000ec88-0000-1000-8000-00805f9b34fb, rssi: -70 
16:02:08.046 -> Advertised Device: Name: , Address: 7d:22:2c:44:25:85, manufacturer data: 4c0010052798e910b6, txPower: 0, rssi: -57 
16:02:08.046 -> Advertised Device: Name: , Address: 72:b3:89:cf:06:d0, serviceUUID: 0000fef3-0000-1000-8000-00805f9b34fb, rssi: -90 

Thanks! Here is the error message I get from compiling your code. Do you also have a ArduinoBLE library on your system? I will try removing that and re-compiling your code.

In file included from /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLECharacteristic.h:17,
                 from /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEService.h:15,
                 from /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEClient.h:20,
                 from /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEUtils.h:16,
                 from /home/stevetux/Arduino/NanoESP32BLE_Test/NanoESP32BLE_Test.ino:7:
/home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEDescriptor.h:25:7: error: redefinition of 'class BLEDescriptor'
 class BLEDescriptor {
       ^~~~~~~~~~~~~
In file included from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLECharacteristic.h:25,
                 from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEService.h:23,
                 from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEDevice.h:25,
                 from /home/stevetux/Arduino/NanoESP32BLE_Test/NanoESP32BLE_Test.ino:6:
/home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEDescriptor.h:28:7: note: previous definition of 'class BLEDescriptor'
 class BLEDescriptor {
       ^~~~~~~~~~~~~
In file included from /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEService.h:15,
                 from /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEClient.h:20,
                 from /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEUtils.h:16,
                 from /home/stevetux/Arduino/NanoESP32BLE_Test/NanoESP32BLE_Test.ino:7:
/home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLECharacteristic.h:53:7: error: redefinition of 'class BLECharacteristic'
 class BLECharacteristic {
       ^~~~~~~~~~~~~~~~~
In file included from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEService.h:23,
                 from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEDevice.h:25,
                 from /home/stevetux/Arduino/NanoESP32BLE_Test/NanoESP32BLE_Test.ino:6:
/home/stevetux/Arduino/libraries/ArduinoBLE/src/BLECharacteristic.h:45:7: note: previous definition of 'class BLECharacteristic'
 class BLECharacteristic  {
       ^~~~~~~~~~~~~~~~~
In file included from /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEClient.h:20,
                 from /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEUtils.h:16,
                 from /home/stevetux/Arduino/NanoESP32BLE_Test/NanoESP32BLE_Test.ino:7:
/home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE/src/BLEService.h:49:7: error: redefinition of 'class BLEService'
 class BLEService {
       ^~~~~~~~~~
In file included from /home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEDevice.h:25,
                 from /home/stevetux/Arduino/NanoESP32BLE_Test/NanoESP32BLE_Test.ino:6:
/home/stevetux/Arduino/libraries/ArduinoBLE/src/BLEService.h:28:7: note: previous definition of 'class BLEService'
 class BLEService {
       ^~~~~~~~~~
/home/stevetux/Arduino/NanoESP32BLE_Test/NanoESP32BLE_Test.ino: In function 'void setup()':
/home/stevetux/Arduino/NanoESP32BLE_Test/NanoESP32BLE_Test.ino:24:14: error: 'init' is not a member of 'BLEDevice'
   BLEDevice::init("");
              ^~~~
/home/stevetux/Arduino/NanoESP32BLE_Test/NanoESP32BLE_Test.ino:25:25: error: 'getScan' is not a member of 'BLEDevice'
   pBLEScan = BLEDevice::getScan(); //create new scan
                         ^~~~~~~
Mehrere Bibliotheken wurden für "BLEDevice.h" gefunden
  Benutzt: /home/stevetux/Arduino/libraries/ArduinoBLE
  Nicht benutzt: /home/stevetux/.arduino15/packages/arduino/hardware/esp32/2.0.18-20240930.arduino3/libraries/BLE
exit status 1

Compilation error: 'init' is not a member of 'BLEDevice'