0

I'm developing a project with PIC dsPIC33 connected via serial port to the HM-10 device. I send to the device AT commands but it seems that some of AT commands are not implemented in the HM-10 firmware. In detail:

AT+RESET - > OK+RESET       : it works
AT+RENEW  -> OK+RENEW       : it works
AT+NAME?  -> OK+NAME:HMSoft : it works
AT+VER?   -> no answer      : it doesn't work
AT+VERS   -> no answer      : it doesn't work
AT+NAMEaa -> no answer      : it doesn't work

did you have similar problem ? Thank you very much for your help and cooperation kind regards

Ferrari
  • 75
  • 1
  • 11

2 Answers2

1

Have a look at the datasheet. There are no AT+VER? or AT+VERS commands. They are AT+VERR? and AT+VERS?.

I did some tests with a HC-06 and some commands needed a CR, some did not. Maybe that's your problem, too?

I used this code in an Arduino sketch to set up the BT device name for a HC-06:

// Enter AT command mode
if (enterATCommandMode() == true)
{
    // Set the name. As we don't have an end-of-line mark, we need to wait until the
    // timeout is reached and hope for the best. We also check whether the reply starts
    // with "OK", so have at least some indication things worked.
    hc06.print("AT+NAME" + userInput);
    String reply = hc06.readString();
    if (reply.equals(""))
    {
      Serial.println(F("HC-06 didn't reply in time!"));
    }
    else
    {
      if (reply.length() < 2 || !reply.substring(0,2).equalsIgnoreCase(F("OK")))
        Serial.println("Unexpected answer ('" + reply + "') to AT+NAME command!");
      else  
        Serial.println(F("Name was set successfully."));
    }
}


bool enterATCommandMode()
{
  // This buffer receives at most 2 characters as the reply (plus terminating \0)
  char atReplyBuffer[] = { '\0', '\0', '\0' };

  // Send AT command and receive answer
  hc06.print(F("AT"));
  int bytesRead = hc06.readBytesUntil('\0', atReplyBuffer, 2);
  String reply = String(atReplyBuffer);

  // Timed out or answer wasn't OK? Error.
  if (bytesRead != 2 || !reply.equalsIgnoreCase(F("OK")))
  {
    if (reply.equals(""))
      Serial.println(F("HC-06 didn't reply in time!"));
    else
      Serial.println("Unexpected reply ('" + reply + "') to AT command");

    return false;
  }

  // Success
  return true;
}
Thorsten Dittmar
  • 55,956
  • 8
  • 91
  • 139
  • Thank you Thorsten for your info. Maybe I had a wrong and old datasheet. Now the AT+VERS? command works and HM-10 replies with HMsoft V540 string. – Ferrari Jan 10 '17 at 14:47
  • Thank you Thorsten for your info. Maybe I had a wrong and old datasheet. Now the AT+VERS? command works and HM-10 replies with HMsoft V540 string. I also added '\r', '\n' to the end of AT+NAMEaa string but I didn't receive any answer from HM-10 – Ferrari Jan 10 '17 at 14:56
  • @Ferrari Is it necessary to enter AT command mode as in my example? Did you do so? – Thorsten Dittmar Jan 10 '17 at 15:42
  • Yes, I did. I also noticed that after sending AT+NAMEaaa\r\n command HM-10 stops working. It doesn't accept no more commands (ie AT+NAME? or AT+RESET don't respond – Ferrari Jan 10 '17 at 17:15
  • Solved! I fixed the AT+NAME procedure to change the name of HC-06. The error, I think, was that I divided the command in two parts. – Ferrari Sep 20 '18 at 16:01
0

Command must be sent without any pause! (I suppose). If I use the following code: (suppose that send8char *x) is the function that writes to the serial port)

send("AT+NAME");
send("myName"); // id doesn't work

char name[20];     
strcpy(name,"AT+NAME");
strcat(name,"myName");
send(name); // if works!!
Zoe
  • 27,060
  • 21
  • 118
  • 148
Ferrari
  • 75
  • 1
  • 11