Skip to main content
Included explanation regarding documentation.
Source Link

The issue is fixed.

Note: This is the version includes Serial1 rather than SoftwareSerial. The rest is the same.

Serial.read()

Returns the first byte of incoming serial data available.

So, when I send AT command from terminal, it does send "A" and then "T" rather than "AT" as a string which Bluetooth expects. as stated in the product's documentation:

AT Command format: Uppercase AT command format. string format, without any other symbol. (e.g. \r or \n).

Hence, I have added the following function:

String SerialString() {   // Function to generate string from chars sent via Serial Monitor
  
  String inputString = "";  // to hold the string
  
  while (Serial.available()) {
    
    char inputChar = (char)Serial.read(); // get the new byte:
    inputString += inputChar;             // add it to the inputString:
    }
    
    return inputString;     // returns completed string 
}

Then inside void loop():

String WholeCommand = ""; 
if(Serial.available() > 0){
    WholeCommand = SerialString();
    Serial1.print(WholeCommand);
  }

Now, when I send AT from Serial Monitor, I can get OK from Bluetooth.

The issue is fixed.

Note: This is the version includes Serial1 rather than SoftwareSerial. The rest is the same.

Serial.read()

Returns the first byte of incoming serial data available.

So, when I send AT command from terminal, it does send "A" and then "T" rather than "AT" as a string which Bluetooth expects. Hence, I have added the following function:

String SerialString() {   // Function to generate string from chars sent via Serial Monitor
  
  String inputString = "";  // to hold the string
  
  while (Serial.available()) {
    
    char inputChar = (char)Serial.read(); // get the new byte:
    inputString += inputChar;             // add it to the inputString:
    }
    
    return inputString;     // returns completed string 
}

Then inside void loop():

String WholeCommand = ""; 
if(Serial.available() > 0){
    WholeCommand = SerialString();
    Serial1.print(WholeCommand);
  }

Now, when I send AT from Serial Monitor, I can get OK from Bluetooth.

The issue is fixed.

Note: This is the version includes Serial1 rather than SoftwareSerial. The rest is the same.

Serial.read()

Returns the first byte of incoming serial data available.

So, when I send AT command from terminal, it does send "A" and then "T" rather than "AT" as a string which Bluetooth expects as stated in the product's documentation:

AT Command format: Uppercase AT command format. string format, without any other symbol. (e.g. \r or \n).

Hence, I have added the following function:

String SerialString() {   // Function to generate string from chars sent via Serial Monitor
  
  String inputString = "";  // to hold the string
  
  while (Serial.available()) {
    
    char inputChar = (char)Serial.read(); // get the new byte:
    inputString += inputChar;             // add it to the inputString:
    }
    
    return inputString;     // returns completed string 
}

Then inside void loop():

String WholeCommand = ""; 
if(Serial.available() > 0){
    WholeCommand = SerialString();
    Serial1.print(WholeCommand);
  }

Now, when I send AT from Serial Monitor, I can get OK from Bluetooth.

Source Link

The issue is fixed.

Note: This is the version includes Serial1 rather than SoftwareSerial. The rest is the same.

Serial.read()

Returns the first byte of incoming serial data available.

So, when I send AT command from terminal, it does send "A" and then "T" rather than "AT" as a string which Bluetooth expects. Hence, I have added the following function:

String SerialString() {   // Function to generate string from chars sent via Serial Monitor
  
  String inputString = "";  // to hold the string
  
  while (Serial.available()) {
    
    char inputChar = (char)Serial.read(); // get the new byte:
    inputString += inputChar;             // add it to the inputString:
    }
    
    return inputString;     // returns completed string 
}

Then inside void loop():

String WholeCommand = ""; 
if(Serial.available() > 0){
    WholeCommand = SerialString();
    Serial1.print(WholeCommand);
  }

Now, when I send AT from Serial Monitor, I can get OK from Bluetooth.