Comments on: Getting Started with ESP32 Bluetooth Low Energy (BLE) on Arduino IDE https://randomnerdtutorials.com/esp32-bluetooth-low-energy-ble-arduino-ide/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Fri, 02 May 2025 09:30:57 +0000 hourly 1 https://wordpress.org/?v=6.8.1 By: Sara Santos https://randomnerdtutorials.com/esp32-bluetooth-low-energy-ble-arduino-ide/#comment-1033203 Fri, 02 May 2025 09:30:57 +0000 http://randomnerdtutorials.com/?p=63505#comment-1033203 In reply to Ben Rodanski.

Ok.
pioarduino worked just fine in my setup.

Regards,
Sara

]]>
By: Ben Rodanski https://randomnerdtutorials.com/esp32-bluetooth-low-energy-ble-arduino-ide/#comment-1033040 Thu, 01 May 2025 21:28:49 +0000 http://randomnerdtutorials.com/?p=63505#comment-1033040 In reply to Sara Santos.

Thanks, Sara!

After installing the pioarduino extension, the error did not disappear. Had to dive deep into the BLE libraries and found the problem. The libraries used by Arduino IDE are different thae the ones used in PlatformIO. Comparing them I found that the offending function BLEScan::start(scanTime, false) was declared differently in the PlatformIO dependencies directory:
C:\Users\ben.platformio\packages\framework-arduinoespressif32\libraries\BLE\src\BLEScan.cpp

Before modification:

BLEScanResults BLEScan::start(uint32_t duration, bool is_continue) {
if(start(duration, nullptr, is_continue)) {
m_semaphoreScanEnd.wait(“start”); // Wait for the semaphore to release.
}
return m_scanResults;
} // start

After modification:

BLEScanResults *BLEScan::start(uint32_t duration, bool is_continue) {
if(start(duration, nullptr, is_continue)) {
m_semaphoreScanEnd.wait(“start”); // Wait for the semaphore to release.
}
return &m_scanResults;
} // start

Of course, the header in BLEScan.h had to be modified as well.

Now it compiles and works ok on the old version of the Espressif 32 platform.

I tried to install the new version, as per your latest tutorial, but run into trouble. After changing the platform line in the platformio.ini file, the system started resolving the esp32dev dependencies, but it seems to have gone into infinite loop somewhere:

Resolving esp32dev dependencies…
Platform Manager: Installing https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip
Downloading 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
Unpacking 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%

Nothing was happening for about 30 minutes, so I terminated the process.
I had to remove the pioarduino extension and reinstall the VS Code…
For now I will stick to the old Espressif32 platform.

Cheers,
Ben

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-bluetooth-low-energy-ble-arduino-ide/#comment-1032630 Wed, 30 Apr 2025 21:08:33 +0000 http://randomnerdtutorials.com/?p=63505#comment-1032630 In reply to Ben.

Hi.
That is probably because VS Code + PlatformIO uses a deprecated version (version 2) of the ESP32 core.
To use the latest version, you need to use pioarduino (a fork of PlaformIO that supports the latest ESP32 core version).

We’ll publish a tutorial about that subject tomorrow. So, stay tuned.

Regards,
Sara

]]>
By: Ben https://randomnerdtutorials.com/esp32-bluetooth-low-energy-ble-arduino-ide/#comment-1032417 Wed, 30 Apr 2025 06:44:37 +0000 http://randomnerdtutorials.com/?p=63505#comment-1032417 Hi,
The BLE Scanner code compiles and runs ok on Arduino IDE 2.3.6, but gives a compilation error on VS Code:

Compiling .pio\build\esp32dev\libac6\BLE\BLERemoteService.cpp.o
src/main.cpp: In function ‘void loop()’:
src/main.cpp:36:65: error: cannot convert ‘BLEScanResults’ to ‘BLEScanResults*’ in initialization
BLEScanResults *foundDevices = pBLEScan->start(scanTime, false);

Any ideas?

]]>
By: Andrew Pepper https://randomnerdtutorials.com/esp32-bluetooth-low-energy-ble-arduino-ide/#comment-1009851 Fri, 21 Feb 2025 17:31:22 +0000 http://randomnerdtutorials.com/?p=63505#comment-1009851 very useful tutorial. Unfortunately, I couldn’t get the example server code to work – I’ve tried a few devices and on Bluetooth LE Explorer, the connection works but the GATT interrogation always returns “unreachable”.

]]>
By: Guido https://randomnerdtutorials.com/esp32-bluetooth-low-energy-ble-arduino-ide/#comment-936747 Fri, 12 Jul 2024 20:15:56 +0000 http://randomnerdtutorials.com/?p=63505#comment-936747 Hi!

Great tutorial, worked fine first try with Android!

That said, what is the methodology to add/change(?) the messages that are sent to a phone?

I have a LoRa GPS tracking system that will send coordinates to a base station and when I press a button on the base station, I’d like to send that coordinate to the phone, either changing the current BLE characteristic (text, like: “46.0594760,-073.6241978”), or creating a new one.

Ideas?

]]>
By: Sara Santos https://randomnerdtutorials.com/esp32-bluetooth-low-energy-ble-arduino-ide/#comment-928457 Thu, 20 Jun 2024 14:35:34 +0000 http://randomnerdtutorials.com/?p=63505#comment-928457 In reply to Adriaan.

Hi.
ADC2 pins cannot be used when Wi-Fi is used. So, if you’re using Wi-Fi and you’re having trouble getting the value from an ADC2 GPIO, you may consider using an ADC1 GPIO instead. That should solve your problem.
So, instead of GPIO 27, you can try using GPIO 32, for example.

Regards,
Sara

]]>
By: Adriaan https://randomnerdtutorials.com/esp32-bluetooth-low-energy-ble-arduino-ide/#comment-928188 Wed, 19 Jun 2024 20:07:52 +0000 http://randomnerdtutorials.com/?p=63505#comment-928188 In reply to Enrrique Iturry.

I’m having the same problem. Can you a bit more specific on your solution?

]]>
By: Hanf https://randomnerdtutorials.com/esp32-bluetooth-low-energy-ble-arduino-ide/#comment-897033 Fri, 08 Mar 2024 06:47:04 +0000 http://randomnerdtutorials.com/?p=63505#comment-897033 In reply to Dinesh.

Got any reference? I also need this

]]>
By: Gregg https://randomnerdtutorials.com/esp32-bluetooth-low-energy-ble-arduino-ide/#comment-889354 Fri, 09 Feb 2024 03:58:22 +0000 http://randomnerdtutorials.com/?p=63505#comment-889354 What ESP32 pins does this require? For example, using any WiFi requires GPIO pins 2,12-15.

Can you show how to code a speed test, especially one that uses the max data size allowed by BLE?

What happens if the connection is lost? How does the BLE client or server know that the connection was lost, and how does they know which packets were received OK (IOW, is there an ACK signal?)

]]>