Passing a Variable Over BLE

Continuing the discussion from Pass a variable over ESP32 BLE:

The above code runs on my esp32-cam, and I can connect to it with the BLE Scanner app on my phone, but I don't see "Hello World says Neil" anywhere on the app. Any idea why not?

to test my BLE on phone I use the nRF connect app (android).
when the arduino device is connected (not paired!) I have to enter the tab, then look for the service provided (usually the first you can see is generated by the BLE library and contains minimal prerequisite for BLE connexion).

So look for your 4fafc201-1fb5-459e-8fcc-c5c9c331914b service, scroll its different value, then click on the single arrow, or in the menu "display all the values" (top right of the screen if I remember well).

One thing is sure: it needs a manual operation on the phone app to actually display the value of one of your BLE characteristic.
You can also select the characteristic and enable notifications (double arrowes) so the data must be updated (if they are designed to change with time).

Hope it will help!

EDIT: making you a screenshot

what I wanted to show you: no value visible for characteristics, until I click on the single arrow (one shot) or enable notifications (multiple arrows) If the characteristic is designed for notifications.

All looks correct in Light Blue/

I looked again, but I could not see "Hello World says Neil" even though I punched all the buttons, and even wrote to one of the characteristics on my phone. I know I connected to the correct device because I saw "Long name works now" in one of the fields.

No matter :). What I really want to do is connect to a specific BLE device and write data to it. Any idea how to modify this code so that it recognizes a particular BLE device and writes only to it?

example on BLE library: here
there is a way to scan for BLE device around then select only one with the desired service.

alow me a sec, I find you what I done with my remote control (wich is only able to connect to the "FOURWHEELS" service you can see in my screenshot.

a quick copy/paste, I just cleaned specific function linked to my screen (debug). Hope it will be clear enough.
Get the example in library for a "true" example

first:

BLEDevice peripheral = BLE.available();

  if (peripheral) {
    // discovered a peripheral
     // stop scanning
    BLE.stopScan();
    connect_to_BLE(peripheral);  // inclut boucle while (connected)
    // peripheral déconnecté : while = 0 dans boucle connect_to_BLE
    BLE.scanForUuid("c4569a8d-9c8f-4e37-8dee-89a0fd4e1376"); // the service you're looking for
}

then (I just put some code in a separate function, in example the code is "in-line")

void connect_to_BLE(BLEDevice &peripheral) {
  // gère la boucle while (connected)

  // fais la connexion et recherche les caractéristiques
  // connect to the peripheral
  if (peripheral.connect()) {
    } else {
    return;
  }
  // discover peripheral attributes
  if (peripheral.discoverAttributes()) {
  } else {
    peripheral.disconnect();
    return;
  }
}

Thanks, guys. I found what I was looking for here: BLE server and BLE client. I tried using a Nano BLE 33 which I had saved in my drawer, but it wouldn't compile for some reason, so I put it back in my drawer and used an Esp32 instead and it works perfectly.

thanks for posting here your solution.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.