Selecting file>examples>examples for esp32 modules>BLE>client loads sketch client.ino + ci.json
Compiling gets: Many errors ending in Compilation error: 'BLEUUID' does not name a type
Selecting file>examples>examples for esp32 modules>BLE>server loads sketch server.ino + ci.json
Compiling gets: Many errors ending in Compilation error: 'init' is not a member of 'BLEDevice'
Using IDE 1.8.19, ESP32C3 module, win 11
Selecting file>examples>examples from Custom libraries > ESP32 BLE Arduino > BLE_client by unknown & chegewara
Compiling gets: Many errors ending in error...'BLEUUID' does not name a type
Selecting file>examples>examples from Custom libraries > ESP32 BLE Arduino > BLE_server by Kolban
Compiling gets: Many errors ending in error ...'init' is not a member of 'BLEDevice'
Selecting SimpleBlsDevice by espressif Compiles -No errors, but does not suit my needs.
Tried with other ESP boards but no joy. I do not have any Arduinos with BLE.
I have only tried client and server sketches. Need a client that works...
I suspect that you're the victim of the latest update of the ESP32 board package.
If you're using version 3.x of the ESP32 board package, I suggest that you roll back to the latest 2.x version and try again.
Note that 3rd party libraries might have been written for an older version of the ESP32 board package and might not have been updated to cater for the breaking changes. You might want to inform the author of that custom library of the issue (usually via github).
Are you still experiencing this problem? If so, I'm going to ask you to provide the full verbose output from a compilation.
This procedure is not intended to solve the problem. The purpose is to gather more information.
Please do this:
Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
The "Preferences" dialog will open.
Check the box next to "Show verbose output during: ☐ compile" in the "Preferences" dialog.
Click the "OK" button.
The "Preferences" dialog will close.
Select Sketch > Verify/Compile from the Arduino IDE menus.
Wait for the compilation to fail.
You will see a "Compilation error: ..." notification at the bottom right corner of the Arduino IDE window. Click the "COPY ERROR MESSAGES" button on that notification.
Open a forum reply here by clicking the "Reply" button.
Click the <CODE/> icon on the post composer toolbar.
This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
This will paste the compilation output into the code block.
Move the cursor outside of the code block markup before you add any additional text to your reply.
Click the "Reply" button to post the output.
In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here.
Open a forum reply here by clicking the "Reply" button.
Click the "Upload" icon () on the post composer toolbar:
The "Open" dialog will open.
Select the .txt file you saved from the "Open" dialog.
Click the "Open" button.
The dialog will close.
Click the "Reply" button to publish the post.
Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.
OK, great. That makes the cause of the error clear:
Background
Arduino IDE has a "library discovery" system. For each #include directive in the program being compiled, the IDE first checks to see if the file is present in the the compiler's "search path". If not, it then searches through the root source folder of each of the installed libraries to look for a file of that name.
Sometimes multiple libraries contain a file matching the #include directive. In this case, Arduino IDE must decide which of the libraries to use. It has a sophisticated algorithm for picking the best library so it usually makes the right decision, but not always.
Explanation
This is a case where Arduino IDE made the wrong decision when discovering the library for the "Client" example's #include "BLEDevice.h" directive:
A file of that name is present in the "ArduinoBLE" library as well as in the "ESP32 BLE Arduino" library that is bundled with the "esp32" boards platform installation. The IDE chose to use the "ArduinoBLE" library, but the "Client" sketch is meant to use the "ESP32 BLE Arduino" library that is bundled with the "esp32" boards platform.
Solution
There are a couple of possible solutions to this problem. I'll describe them below. You can pick whichever one of the two is most suitable for you:
Uninstall Problematic Library
If you don't actually have any use for the "ArduinoBLE" library, then you can solve the problem by simply uninstalling the library.
I'll provide instructions you can follow to do that:
Select Sketch > Include Library > Manage Libraries... from the Arduino IDE menus to open the "Library Manager" view in the left side panel.
Type ArduinoBLE in the "Filter your search..." field.
Scroll down through the list of libraries until you see the "ArduinoBLE" entry.
Hover the mouse pointer over the "ArduinoBLE" entry.
You will see a ●●● icon appear near the top right corner of the library entry. Click on that icon.
A context menu will open.
Select "Remove" from the menu.
An "Uninstall" dialog will open.
Click the "YES" button in the "Uninstall" dialog to confirm that you want to uninstall the library.
The dialog will close.
Wait for the uninstall process to finish, as indicated by a notification at the bottom right corner of the Arduino IDE window:
ⓘ Successfully uninstalled library ...
Force Arduino IDE to Choose Correct Library
If you do need the "ArduinoBLE" library for use in other projects then the other solution will not be acceptable.
In this case the solution will be to influence the library discovery system to chose the "ESP32 BLE Arduino" library over the "ArduinoBLE" library.
As I mentioned before, files from the include search path are always given priority by the library discovery system. Once a library is "discovered", its path is added to the include search path. So if we can cause the "ESP32 BLE Arduino" library to be discovered before Arduino IDE does discovery for the ambiguous BLEDevice.h file, then it not discover the "ArduinoBLE" library. This is accomplished by placing an #include directive for a file unique to the "ESP32 BLE Arduino" library above the ambiguous #include directive.
I will arbitrarily choose the file BLEUUID.h, which is present in the "ESP32 BLE Arduino" library, but not in the "ArduinoBLE" library. Simply add an #include directive for that file above the #include directive for BLEDevice.h in your sketch.
So change this part of your sketch:
#include "BLEDevice.h"
to this:
#include "BLEUUID.h"
#include "BLEDevice.h"
Now try compiling the sketch again. Hopefully this time the error will not occur and everything will work as expected.
You have selected Tools > Board > esp32 > ESP32 Dev Module from the Arduino IDE menus. This board definition is for use with boards based on the original ESP32 microcontroller.
However, you have indicated that your board is instead based on the newer ESP32-C3 microcontroller. You can not use the "ESP32 Dev Module" board definition with ESP32-C3-based boards. You must instead select Tools > Board > esp32 > ESP32C3 Dev Module from the Arduino IDE menus when using an ESP32-C3-based board.