I am keen to get a simple and reliable connection between an esp32 and android device via BLE. I followed the instructions and on a couple of occasions I did get some data as listed in green using the nRF Connect app for Android. The esp32 is running the code, but most of the time it doesn’t connect or fails to show the data or seems to freeze, then the esp32 drops off and I have to re-pair. I’m not sure where the issue is. I tried a different app and it said “Connection failed: read failed, socket might closed or timeout, read ret:-1”. Any suggestions?
Update: I viewed the youtube video here: https://www.youtube.com/watch?v=RStncO3zb8g. I could reliably connect and send messages, so the question is now what is different with the other instruction?
What sketches did you test?
What projects exactly did you follow?
I had a problem with this sketch from the esp32 book (p 268):
and the one that worked was the Arduino SerialToSerialBT Example per the video above or your article here:
That is a completely different tutorial.
Those are two different versions of Bluetooth. One is Bluetooth Low Energy and the other is Bluetooth Classic (also called Bluetooth serial).
Can you provide me with more details about the issues with the other sketch? Did you get any error messages on the Serial Monitor? Which board model were you using?
As noted in my initial question, the first sketch (from p. 286) was working a few times, then often would disconnect or show the error: “Connection failed: read failed, socket might closed or timeout, read ret:-1”, when testing with my Pixel 6 Android phone and the Serial Bluetooth app.
I am trying this on a DEVKIT v1 as per the instruction book, but I am also keen to use it with the ePulse feather.
My project involves creating the solar-based sensor station (Project 4), but instead of using LoRa I am transmitting the data via MQTT to a Raspberry Pi. Since it is in the IP95 box, I am also wondering if I can see some of the data using BT from my phone. Can BT be used coincident with the esp32 WiFi in the loop transmission? Also, I am uncertain whether to use BT or BLE, though the latter is preferable since it uses less power. But my transmissions are only on twice a day, so it might not matter. Please let me know if there is other information needed to understand my question.
Since you’re using Wi-Fi, have you considered using a web server to check the readings?
Where are you sending your readings via MQTT? Node-RED? Maybe you can use MQTT to check the current data too. For example, when you publish on a certain topic, the ESP32 sends the latest readings?
I don’t know your specific details, but if your boards are in deep sleep mode, you won’t be able to connect via Bluetooth, unless you wake up your boards manually like via a pushbutton.
I haven’t tried using Bluetooth at the same time as Wi-Fi. It’s probably possible to do that, but I’m not sure if there are any “tricks” to make both compatible and working smoothly simultaneously.