Receiving String from Bluetooth Module

I'm using an Arduino uno board. When I send an instruction "LLL" to my bluelink bluetooth module , the module sends a reply "OK". I want to receive this reply as a string. At present I'm able to receive the letter "O" in one line and the letter "K" separately. In the same way for other instructions I get a very long return message from the module (The Device address and stuff), I need to receive those long replies too as a string. Kindly guide me how this can be done. TIA

At present I'm able to receive the letter "O" in one line and the letter "K" separately

That happens because the transmission happens bit by bit , to make a string out of them use a array to receive and store value from buffer and then print them into full statements, but note the transmission will still happen bit by bit.

check out Virtual Library that is used for radio transmitters i have used it and it incorporates the same methodology to deal with bit's.

I figured out a way from the forum to receive a string.

String readString;

void setup() {
  Serial.begin(9600);
  Serial.println("serial-delimit-21"); // so I can keep track of what is loaded
}

void loop() {

  //expect a string like wer,qwe rty,123 456,hyre kjhg,
  //or like hello world,who are you?,bye!,
  while (Serial.available()) {
    delay(10);  //small delay to allow input buffer to fill

    char c = Serial.read();  //gets one byte from serial buffer
    if (c == ',') {
      break;
    }  //breaks out of capture loop to print readstring
    readString += c; 
  } //makes the string readString  

  if (readString.length() >0) {
    Serial.println(readString); //prints string to serial port out

    readString=""; //clears variable for new input
  }
}

But now I got another problem.. For a certain command I get a reply from the Bluetooth module that exceeds the size of the buffer. So only a portion of the received string gets displayed (i suppose its 83 characters). How to increase the size of the buffer to say 1000 characters??

1 Like

When dealing with lot of text utilize the string array not the String object that you are doing here, try it!