2

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

@1: #include <Adafruit_BluefruitLE_SPI.h>

@2: #include <BLEDevice.h>
   #include <BLEServer.h>
   #include <BLEUtils.h>
   #include <BLE2902.h>
 
@3: #include <ArduinoBLE.h>

It looks like the @3'rd one is most modern and officially published by Arduino IDE (see the link https://github.com/nkolban/ESP32_BLE_Arduino/tree/adc2aee2f0d01eb6b30dd5ad3589f2cc89934beb ), hence @2 has more examples then others.

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 ?

Adam M.
  • 21
  • 1
  • 3
  • `ArduinoBLE.h` works fine. You can find a nice example code [here.](https://forum.arduino.cc/t/arduino-to-raspberry-pi-communication-over-ble/874858/2). I've never used it with ESP32 though. – Mr. Panda Aug 07 '21 at 15:04

2 Answers2

1

It seems that only @2 is designed for ESP32 module. It's quite popular, for ESP32 it won't be a bad choice.

As a kickstart for @2, take a look at this project: BLEProof on gihtub - contains BLE Central & Peripheral for Android and ESP32, simple demo of BLE read, write and notify.

When starting a project, please choose the hardware wisely:

  • ESP32 modules are powerful but have high power consumption, minimum 60mA, they cannot sleep while advertising or keeping the active BLE connection
  • Other modules (for libraries @1 and @3), especially only-BLE-modules (without Wi-Fi), designed for lower power consumption: e.g. Nordic nRF51/nRF52 series processors consume 10-15mA when processor runs all the time, or 1-2mA when combining sleep with keeping active BLE connection

ESP32 with library @2 is a convenient way to prototype your project, but it's not an energy-efficient solution when you use only Bluetooth Low Energy. Also note that I don't have any experience with libraries @1 and @3.

alexander.cpp
  • 747
  • 6
  • 15
  • Thanks for the answer. I didn't realize that much difference in power consumption. Now during prototyping I'm using Wemos Lolin D32 ( it has BLE, ADC, battery charger and Arduino IDE compatibile - all in one board :) It looks like I should find different board ? Any suggestions for a board with this 4 futures ? – Adam M. Aug 08 '21 at 07:25
  • At first, I would definitely finish the prototype with Wemos Lolin D32. Suggestions, **lib @1**: [Adafruit Feather nRF52840 Express](https://www.adafruit.com/product/4062) or it's [Sense version](https://www.adafruit.com/product/4516) - one processor nRF52840 - Nordic flagship of nRF52 series; **or** [Adafruit Feather M0 Bluefruit LE](https://www.adafruit.com/product/2995) - main chip ARM M0 and nRF51822 for BLE (there is also 32u4 version, I think M0 is better). **Lib @3**: 1. https://store.arduino.cc/arduino-mkr-wifi-1010 - the only thing for @3 with battery charger, but also with Wi-Fi – alexander.cpp Aug 08 '21 at 13:10
  • Also check supported voltage range for your ADC, I think Adafruit Feather nRF52840 supports [ADC up to 3.6V](https://learn.adafruit.com/introducing-the-adafruit-nrf52840-feather/nrf52-adc) – alexander.cpp Aug 08 '21 at 13:15
  • Great help ! :) I will also check this : [SparkFun Pro nRF52840 Mini - Bluetooth Development Board](https://www.sparkfun.com/products/15025) – Adam M. Aug 10 '21 at 07:59
1

I was having the same question. I tried @2 and it worked fine but @3 had better API so I jumped to that option. Apparently @3 does not support esp32. There is an issue for the same with a pull request link. However, when I tried it, it had compile errors. So I'm going to use @2 for my project and suggest the same to anyone looking here at least until the @3 library supports it.