Unable to see ESP32-WROOM-32 with BLE extension

I made an app on Mit app inventor with the BLE extension and when i want to connect my phone or tablet to ESP32 BLE. I don't find the device on the app but others devices while i use classic bluetooth i got it. I authorized fine location and i can just allow it when the app is working. I have an other question, can I work with classic Bluetooth and BLE to use the advantages of both?
My Bluetooth id is : 94:B9:7E:EA:6C:8A.

I work with Arduino IDE for the ESP32.

Basic questions Emma - smartphone Make/Model/Android Version/Bluetooth Version?

Can we see your Blocks?
Right-mouse in the Blocks work area and select "Download Blocks as image"

Can you upload your Sketch/Script for us to study?

It's commonplace to use Classic BT to check that Bluetooth is on, and BLE for the main communications.

Are you using the most recent version of the Extension?

Is the local environment free of BLE obstacles?

https://www.professorcad.co.uk/appinventortips#BluetoothFailure

Is the Arduino Serial Monitor working with your ESP32?

I found out the problem was my Arduino Sketch that was writing for Classic Bluetooth. My tablet is a samsung A7 tab on Android 10 and my phone is a samsung A10 on Android 11. How do you use both ? I use the most recent version of the extension 2023 smth.
Capture

// http://kio4.com/arduino/160_Wemos_ESP32_BLE.htm

#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>


#define SERVICE_UUID        "7c323a32-38eb-4741-8175-41f178e3d783"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"
#define PIN_BTN_GAUCHE  13

BLECharacteristic *pCharacteristic;
int lastState = HIGH;  // Initial state of the button


void setup() {
  Serial.begin(115200);
  BLEDevice::init("Here_ESP32");
  pinMode(PIN_BTN_GAUCHE, INPUT_PULLUP);
  BLEServer *pServer = BLEDevice::createServer();
  BLEService *pService = pServer->createService(SERVICE_UUID);
  BLECharacteristic *pCharacteristic = pService->createCharacteristic(
                                         CHARACTERISTIC_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );

  pCharacteristic->setValue("Connected.");
  pService->start();

  BLEAdvertising *pAdvertising = pServer->getAdvertising();
  pAdvertising->start();
}

void loop() {

  int currentState = digitalRead(PIN_BTN_GAUCHE);  // Read the current state of the button

  if (currentState != lastState) {  // Check if the button state has changed
    if (currentState == LOW) {  // Button is pressed
      pCharacteristic->setValue("Button Pressed");
      pCharacteristic->notify();  // Notify the client
      Serial.println("SwitchScreen");
    }
    lastState = currentState;  // Update the last state
  }

  delay(100);  // Small delay for debouncing

}

Absolutely

There may be differences in the Google Android permissions required for 10 and 11 but other than that both should work.

Where did you get the Sketch from?

I get from RedOhm site about mit app inventor and Arduino.

I think it's one of Neil Kolban's example Sketches.

Well, much depends on what you want to do - what do you want your project to do exactly?

Right-mouse in the Blocks work area and select "Download Blocks as image" cannot read the image you have posted :upside_down_face:

I want to use an action made on element (button ) link to the esp32 to juste move from one virtual screen to another. And also, when a question is answered correctly on the app for example a LED takes a color.

Capture

OK, is the button already working - can you make it send a value to the Serial Monitor?

I think the Sketch you have is largely OK for the button task, but we would want to send a value (signal) to the App, not a Notify().

For the App to control an LED, we need to change the Sketch (As it is, it works like a Server, not required).

I still can't see your Blocks!
Right-mouse in the Blocks work area and select "Download Blocks as image"
download blocks


Actually, i do not know how to do it.
I need the ESP32 to do both button and LED thing, so i will need to have 2 ESP32 with two differents sketchs then.

You only need one ESP32, a breadboard and one Sketch (and one App).

We can use a Clock to give the App a bit of extra time to scan for devices. Your ESP32 should be found if it is switched on and running an appropriate Sketch. As I mentioned before, there may be obstacles in the local environment that can make the Bluetooth signal fail, so make sure your environment is perfect. Also make sure your power supply for the ESP32 is perfect.

1 Like

Here is a Tutorial from my fellow power user Juan Antonio:

He also has other related tutorials.

1 Like

Dear @Emma_FUSELIER,
everything that @Chris has already said is absolutely valid, also making a reference to @juan_antonio's web site, but since I've recently tackled the BLE's dark dungeons, I attach to this post some hints, and a couple of codes, that brought me out of the darkness. It isn't a real tutorial, but just a share of how I've approached a super simple BLE interface between ESP32 and AI2.
The pdf file is a detailed description of both codes. Hoping it can help you.
BLE_Test.pdf (462.4 KB)
BLE_Test.aia (248.8 KB)
BLETestAI2_uart.ino (5.9 KB)
Bonne chance !

PS if your AI2 blocks are only those you have attached, the reference to the BLE UUID's is missing

2 Likes

Thank both of you for your answer. Now, my time is limited so i decided to move on to Serial Connection.

It's your choice, but please be aware that the serial line (the HW one, on pins 15 Rx,16Tx) is the same that is used to download the SW from the PC to the ESP, via USB. Therefore whenever you downoad a new code on the ESP, you shall disconnect any other serial link on those pins, otherwise the additional load will impede the correct download. Moreover, take care that during the normal working, any sending to the Serial Monitor will also go to the app, and this can deceive the SW of the app, that will receive unknow and unexpected messages.
To overcome this problem, I suggest you to take a look here:

Bonne chance !

1 Like