Serial Bluetooth and receiving/ storing strings

Hello,
I use SerialtoSerialBT example of Arduino IDE (hereunder).
I need to put following strings in my ESP32 'PowerOn, PowerOff, Rec, Stop'. These strings are issued from a Smartphone linked thru Bluetooth.
All is working... , but I need them to be stored inside ESP32. Each trial to put 'char' strings in the loop gave weird additional characters or loss of characters. Any idea/ help to store in buffers instead of just printing in Serial Monitor ? Thanks for help and advice.


BluetoothSerial SerialBT;

void setup() {
  Serial.begin(115200);
  
void loop() {
  if (Serial.available()) {
    SerialBT.write(Serial.read());
  }
  if (SerialBT.available()) {
    Serial.write(SerialBT.read());
  }
  delay(1);
}

Hi bernhard,

serial.read() read a single byte.
read the Serial input basics by Robin2

best regards Stefan
Be the change you want to see in the world

This notion of be the change you want to see in the world does 3 powerful things when we adopt it:
It stops us from judging others;
It replaces complaining about others with reflection on self;
It stirs us into taking action within the only thing in the world over which we have any control: ourselves.

2 Likes

+1 for serial input basics.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.