BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

ESP32 with BLE: the Android app doesn't find the esp32 device

esp32
#1

I’m trying to implement the example BLE application on ESP32 DEVKIT V1.

I can compile and run successfully the example Arduino program as found in Examples, in fact, I can see the following on the console:

 Waiting for connections...
[17] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on ESP32

Moreover, I can see the ESP32 announce itself over BT using the scan function of my laptop.

I even created an app on my Android phone (Samsung A5 2017 SM-A420F) running Android 8.0.0.
The app contains a single button and is targeted to ESP32 / Bluetooth.
However, when I start it a red dot is shown on the title bar and it saying

“wasn’t online yet”

Note that the phone is for sure able to work with BLE as I developed several apps using AppInventor2 and its BLE library, that works fine with the same ESP32 DEVKIT module, so the hardware is definitively capable to process BLE.

So, I’m stuck there, any chance to make it work?
Is it feasible to achieve a direct connection between the app running on Android and the ESP32 running Bylnk library ?

0 Likes

#2

Yes…ish… Things keep changing with ESP32, so hard to say the current state of this topic…

And you probably need to use the Beta version of the App for better BT/BLE support.

As with anything curent with Blynk and BT/BLE, the App still needs connectivity to the Server (typically via WiFi/cell), and some Server linked Widgets do not work via the App link alone. thus with an ESP32 already having WiFi, it almost becomes a case of “Because it can…ish” rather than a need to use BLE

0 Likes

#3

I switched to Blynk beta test app.

Finally, I understood that a BLE object has to be added to my Android App.
I did so and attempted to pair the phone to the ESP32, but no joy, as the connection fails anyway:

Waiting for connections...
[18] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on ESP32

[8419] BLE connect
[19754] BLE disconnect
[19754] Disconnected
[73443] BLE connect
[84778] BLE disconnect
[84778] Disconnected
[105393] BLE connect
[116728] BLE disconnect
[116728] Disconnected
[142742] BLE connect
[154077] BLE disconnect
[154077] Disconnected
[220277] BLE connect
[231611] BLE disconnect
[231612] Disconnected
[261496] BLE connect
[272846] BLE disconnect
[272846] Disconnected
0 Likes

#4

Do you have same token in the BLE sketch as the device that is used by BLE widget?

0 Likes

#5

Make sure you have also connected your widget to the device…

And are running latest ESP32 core…

This works on my ESP32 with current (as of this post) Local Server and Library…

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define BLYNK_USE_DIRECT_CONNECT
#include <BlynkSimpleEsp32_BLE.h>
#include <BLEDevice.h>
#include <BLEServer.h>

char auth[] = "xxxxxxxxxx";

BlynkTimer timer;


void setup()
{
  Serial.begin(115200);
  Blynk.begin(auth);
  
  // Timed Lambda Function - UpTime counter
  timer.setInterval(1000L, []() {  // Run every second
    Blynk.virtualWrite(V0, millis() / 1000);  // Display the UpTime in Seconds to Display Widget.
    Serial.println(millis() / 1000);
  });  // END Timer Function
}



void loop()
{
  Blynk.run();
  timer.run();
}

image

1 Like

#6

Many thanks to all provided suggestions; in the end I managed to workout my setup and now it works, more or less as expected.

It remains that a connection to the cloud is due, even when BLE is specified, at least the first time. So, Blynk could be not the ideal solution in order to manage an ESP32 via smartphone app using BLE or even wifi (not considering here the local server).

0 Likes

#7

Actually the App needs the server all the time… that is how Blynk becomes an INTERNET of Things process, not just a GUI.

0 Likes

#8

Actually the App needs the server all the time

The server, indeed, not necessarily an Internet connection (as, in my understanding, the server could be local so to enable isolated plants).
In this picture is not clear to me why direct Bluetooth connection between a phone App and the physical node(s) was added at all.

0 Likes

#9

Correct… although that standalone networking use of a Local Server is in of itself a bit more complex as now it’s hardware (typically a RPi) needs to integrate a WiFi Access Point and preferably be battery powered, since assuming you are in the middle of nowhere without any form of internet (GSM, Phone hotspot, etc.)… you probably have no AC outlet either :stuck_out_tongue_winking_eye:

I don’t think it was added, so much as part of Blynk’s beginning, and soon surpassed by the new WiFi capable MCUs like ESP8266.

Personally, I think it is still being developed a bit due to the abundance of BT devices (and homage to Blynk’s beginnings?)… but with such limited range and reliability issues, it seems more like a niche side of Blynk.

0 Likes