I have used the App Inventor + IoT: Basic Bluetooth Connection Setup demo. I have checked my blocks several times and they are the same as the demo instructions. I have no errors, and the app runs OK.... I can Scan, a list of devices appears, I can Stop Scanning.
But when I select my ESP32 device from the list and try and Connect, it hangs for a timeout period of about 10 secs, and then the status box changes from "Connecting" to "Disconnecting". I cannot achieve a connection.
I know the ESP32 is OK as I can connect to it using several laptops, and my phone (using Serial Terminal). I am using the same phone for App Inventor.
I have read a thread here about adding Permissions blocks. The ESP32 device is running a simple BLE demo using Micropython, and just sends two sensor values once connected to a device. This works OK to Serial Terminal on the phone.
I cannot see anything obvious, but is there something (like the Permissions blocks) that I need to add to connect the IoT Bluetooth Connection Setup demo to a simple ESP32 BLE ?
Check that you are using the latest BLE .aix
I downloaded it yesterday, so I expect that answer is 'yes'
edu.mit.appinventor.ble-20230728
Unless you need the BLE for your specific requirements, and since the ESP32 features also the "classic BT", I strongly suggest you to use the classic BT (no need for extensions). In the Arduino IDE just load the BluetoothSerial library (honestly I don't know whether the Micropython requires the same).
i.e.
At initialization:
#include "BluetoothSerial.h" // loads the library
BluetoothSerial SerialBT; // creates the port
Within the code:
SerialBT.print(current data); // transmits data to BT
SerialBT.println(); // required to advise AI2 that the frame has been completely transmitted
On AI2 side set the delimiter character to 0x0A (linefeed) and wait until the number of received characters is = -1.
Best wishes.
Thanks, but I am using Micropython and it currently only supports BLE.
Sorry,
I've been sick for a while therefore I see right now that your system can work only with BLE.
I guess (hope) that in the meanwhile, you have already solved on your own, or with the hints of @ABG, otherwise you can find another example here:
http://kio4.com/arduino/160i_Wemos_ESP32_BLE.htm
You'll see that Juan Antonio ( ) provides in his web site a huge amount of tutorials.
Cheers.
Thank you