• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

esp32 BLE connection issue

Q&A Forum › Category: ESP32 › esp32 BLE connection issue
0 Vote Up Vote Down
Jack Douglas asked 1 year ago

Hello

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?

Question Tags: BLE
5 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 1 year ago

Hi.
What sketches did you test?
What projects exactly did you follow?
Regards,
Sara

0 Vote Up Vote Down
Jack Douglas answered 1 year ago

I had a problem with this sketch from the esp32 book (p 268):
https://github.com/RuiSantosdotme/ESP32-Course/blob/master/code/BLE_Examples/BLE_notify/BLE_notify.ino
and the one that worked was the Arduino SerialToSerialBT Example per the video above or your article here:
https://randomnerdtutorials.com/esp32-bluetooth-classic-arduino-ide/

0 Vote Up Vote Down
Sara Santos Staff answered 1 year ago

Hi.
 
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?
 
Regards,
Sara

0 Vote Up Vote Down
Jack Douglas answered 1 year ago

Hi Sara
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.

0 Vote Up Vote Down
Sara Santos Staff answered 1 year ago

Hi.
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.
 
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.