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);
}
}
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.
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
available
returns count of characters available to read.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)