How to get new Bluetooth values...?

I have my ESP32 with Arduino. The internal Bluetooth send the serial data to my App inventor app. The problem is that I need to connect manually every time to get new values, I don't need to disconnect. How can I solve this? I use a clock funtion but don't recive new values.
I think easies is to disconnect and then connect to the same bluetooth adress in some interval. How can I do this?

Hi Olaab. I used the following example on a ESP32-WROOM as a basis for a new project I am working on, it helped me get started and works good for me. The example uses Bluetooth light extension, but I think the principle is the same.
ESP32

Dear @Olaab,
in addition to what @Dingo has already said ( :+1:), you can get a lot of hints from @Juan_Antonio's web site "KIO4".
Give it a look and you'll find there surely the help you need.
Cheers.

PS
a bit "off-topic", but please be aware that if your BT stays silent for a long time (for example between new data are available at your ESP32 side), the BT can decide to disconnect on its own. To avoid that, it is better to send periodically a "live" character from the ESP to the phone: In other words, your ESP can send every "n" seconds a character (a '$' for example) that your phone will receive and decide accordingly that the ESP is still operating. If the '$' is not received for an amount > "2*n" your phone can decde to retry a BT connection. Obviously your app can never go to sleep in the meanwhile (i.e. you cannot make it running in background). To make your app stay always alive you can use a @Taifun extension that avoids the screen to go off.
Per aspera ad astra !!!
Best wishes.

Thank you for your reply :slight_smile:
I have now solved it. I didn't need to change my BT code in App Inventor. The problem was that my ESP32 D1 mini crashed and recovered over and over again with my earlier Interrupt code. Therefore no values changed in realtime but they where there so when I started the app again I get the latest values.

1 Like

Ah yes, the ESP series haa a Watchdog that resets the CPU if not retriggered or if not disabled. And care shall be taken when using interrupts. Nice you have solved !
Cheers.