Go Down

Topic: Hm-10 bluetooth module only returns OK after any AT commands (Read 1 time) previous topic - next topic


I bought a Hm-10 bluetooth module (BLE 4.0) to use in my school project. So, every command that i send to it, it returns always an "OK". Do you guys can help me ?

Code: [Select]
#include <SoftwareSerial.h>
SoftwareSerial BT(10, 11); // RX, TX
String command = ""; // Stores response of bluetooth device
void setup()
  Serial.println("Type AT commands!");
  BT.begin(9600); // HC-06 usually default baud-rate

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.
    command = ""; // No repeats
  if (Serial.available())
    delay(10); // The DELAY! ********** VERY IMPORTANT *******

And it's my bluetooth module (I guess it isn't the CC41 one....)



I just ran into the same issue.

Seems there's a 'guard time' around entering AT commands after the initial first two characters, and you won't be able to type it fast enough.  Had a similar issue with the radio modem on my Android a couple of years  ago.  The-10 just responds OK before I can even get the '+' char entered.  You've basically just got to send it as an entire block, or do it via script / data transfer / whatever.  Typing is too slow.

Saw a script called "atinout" that does this, only Linux though.

Just tried it with 'minicom' and it works fine.   Compose your AT commands in TextEdit or whatever simple tool, then copy & paste in minicom.  Has the added benefit of keeping your config history and letting you double check before applying.

Good luck

Go Up