user31781: I bought an HM-10 Bluetooth module (BLE 4.0) to use in my school project. Every command that I send to it, it always returns "OK". Can you guys help me?
Here's the code that I am using in my Arduino Uno.
#include <SoftwareSerial.h>

SoftwareSerial BT(10, 11); // RX, TX
String command = ""; // Stores response of bluetooth device

void setup() {
  BT.begin(9600); // HC-06's usual default baud-rate
  Serial.begin(9600);
  Serial.println("Type AT commands!"); 
}

void loop() {
  if (BT.available()) {
    // Read device output if available.
    while(BT.available()) {
      // While there is more to be read, keep reading.
      delay(10); //Delay added to make thing stable
      char c = BT.read(); //Conduct a serial read
      command += c; //build the string.
    }
    Serial.println(command);
    command = ""; // No repeats
  }
  if (Serial.available()) {
    delay(10);
    BT.write(Serial.read());
  }
}


user31542: On the command write you read only one character to send to bluetooth.
Make same than for bluetooth to serial part above:
void loop()
{
if (BT.available()) // Read device output if available.
{
  while(BT.available()) // While there is more to be read, keep reading.
 {
   delay(10); //Delay added to make thing stable 
   char c = BT.read(); //Conduct a serial read
   command += c; //build the string.
  } 
  Serial.println(command);
  command = ""; // No repeats
} 

if (Serial.available())
{
  while(Serial.available())
  {
     delay(10);
     char d = Serial.read(); //Conduct a serial read
     command += d; //build the string.
  } 
  BT.write(command);
  command = "";
 }
}


31781: <p>I bought an HM-10 Bluetooth module (BLE 4.0) to use in my school project. Every command that I send to it, it always returns "OK". Can you guys help me?</p>

<p>Here's the code that I am using in my Arduino Uno.</p>

<pre><code>#include &lt;SoftwareSerial.h&gt;

SoftwareSerial BT(10, 11); // RX, TX
String command = ""; // Stores response of bluetooth device

void setup() {
  BT.begin(9600); // HC-06's usual default baud-rate
  Serial.begin(9600);
  Serial.println("Type AT commands!"); 
}

void loop() {
  if (BT.available()) {
    // Read device output if available.
    while(BT.available()) {
      // While there is more to be read, keep reading.
      delay(10); //Delay added to make thing stable
      char c = BT.read(); //Conduct a serial read
      command += c; //build the string.
    }
    Serial.println(command);
    command = ""; // No repeats
  }
  if (Serial.available()) {
    delay(10);
    BT.write(Serial.read());
  }
}
</code></pre>
 31542: <p>On the command write you read only one character to send to bluetooth.</p>

<p>Make same than for bluetooth to serial part above:</p>

<pre><code>void loop()
{
if (BT.available()) // Read device output if available.
{
  while(BT.available()) // While there is more to be read, keep reading.
 {
   delay(10); //Delay added to make thing stable 
   char c = BT.read(); //Conduct a serial read
   command += c; //build the string.
  } 
  Serial.println(command);
  command = ""; // No repeats
} 

if (Serial.available())
{
  while(Serial.available())
  {
     delay(10);
     char d = Serial.read(); //Conduct a serial read
     command += d; //build the string.
  } 
  BT.write(command);
  command = "";
 }
}
</code></pre>
