1

I am trying to send and receive messages between my mac and esp32 board. I am currently using the Bluetooth classic interface. After a successful connection. I however have observed that there is no data being received on my Macbook.

#include "BluetoothSerial.h"
 
BluetoothSerial SerialBT;
  
void setup()
{
  Serial.begin(9600);
  SerialBT.begin("ESP32test");
  Serial.println("Setup initalised");
  delay(1000);
}

void loop()
{
  String inputFromOtherSide;
  Serial.println("Loop has started");
  if (SerialBT.available()) 
  {
    Serial.println("SerialBT is available");
    inputFromOtherSide = SerialBT.readString();
    SerialBT.println("You had entered: ");
    SerialBT.println(inputFromOtherSide);
  }
}

enter image description here enter image description here enter image description here

The above-attached images show the output that I currently receive. After some debugging, I noticed that

SerialBT.available() returns false. I am not sure how to proceed from here.

I do know that this above code should work as I have tested this on windows and it works.

enter image description here

I however need to replicate this on the MacBook any guidance on the reason why this fails here would be appreciated. Or is there a way for me to create a Bluetooth serial link on a mac

3
  • 1
    available returns count of characters available to read.
    – Juraj
    Feb 7 at 20:38
  • Does this mean that if I type something in the serial then it would later fill the buffer for me to read from? which then gets printed again? Feb 8 at 22:45
  • SerialBT.available() will be more than zero only if something is received over SerialBT (which I guess is not connected to Serial Monitor). in this version of the sketch you have no reason to condition printing to SerialBT. (I saw your post om Arduino forum with a different version of the sketch, which first reads the received cata)
    – Juraj
    Feb 9 at 5:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.