I'm starting a project : read an ADC value on ESP32 (peripheral) and send it over BLE to android (central). I'm a bit confused looking for proper libraries . I found at least 3 solutions/libraries
Using 2 I can use .notify command to start publishing the value. Using 3 there is no documentation for this command, it looks like I should only use .writeValue and the .poll is taking care of publishing the value.Also 3 is using setEventHandler , while 1 and 2 don't have this described.
Is it right to use 3 because it is officially published by Arduino IDE and has full documentation within Ardiuno IDE ?
I think you must use option 2. I doubt the libraries are compatible but I have not tried it myself. I used option 2 with my ESP32 board and option 3 with Arduino Nano 33 BLE, IoT and RP2040 Connect.
I agree. I found the ArduinoBLE library to be the easiest to understand and use.
With the ArduinoBLE library you simply declare a characteristic with notification. e.g.,
Everything else is taking care of by the library. No need for a separate header file, you do not need to add the descriptor and you do not need to call notify when you write the characteristic.
As I said, I do not believe that would work with ESP32. I could be wrong.
You can see the documentation for the ArduinoBLE library here:
This library supports all the Arduino boards that have the hardware enabled for BLE and Bluetooth 4.0 and above; these include Nano 33 BLE, Arduino NANO 33 IoT, Uno WiFi Rev 2, MKR WiFi 1010.
This library is intended to provide BLE support for the official Arduino boards that have such a capability. Even though the ESP32 is the microcontroller that provides the BLE radio capability on the official boards with the NINA-W102 module (e.g., MKR WiFi 1010, Nano 33 IoT, Nano RP2040 Connect), the library code does not run on the ESP32, but instead of the primary microcontroller (e.g., ATSAMD21G18, RP2040). So there is not official support of this library for the ESP32. However, the Arduino community is not to be underestimated, and I notice that someone has a fork of the library that is claimed to have ESP32 support added:
I haven't tried it, so no idea whether it works or not, but certainly worth a look!
in the Boards Manager installed ESP32 version 2.0.0-rc1
compiled again and programmed an ESP32-WROOM-32E
My example has an environmental sensing service, some characteristics with READ and Notify and additional descriptors. There was no code modification necessary for my Arduino example and everything works as expected.