HM10's 'AT+NAME<name>' adds extra empty character at the end of the name

I have two HM10 modules with the difference being, their versions got from AT+VERSION & the names written behind the modules

Module A:
Name on board: JDY-09
Version from AT comm: MLT-BT05-V4.45

Module B:
Name: ZS-040
Version from AT comm: v5.3

AT-commands

Using an Arduino Uno with jumper cables for I/O of AT commands with HM10.
Code:

#include<SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);

void setup() {
  Serial.begin(9600);
  while (!Serial)
  {
    ;
  }
  Serial.println("Start");

  mySerial.begin(9600);
  mySerial.print("AT+NAMEDemo\r\n");  //Line endings to be used else ERROR or no response
}

void loop() {
  if (mySerial.available())
  {
    Serial.print(mySerial.readString());
  }
}

Module A successfully changes name to "Demo"
Module B changes name to "Demo ". Notice the empty character at the end

Output in Serial monitor:

Module A:

Start
+NAME=Demo
OK

Module B:

Start
+NAME=Demo

OK

Notice the empty line after the first AT command response.

Also the names when connected to the modules with an app
Module A
Module B

So why would this be happening?

some modules require only an \r or an \n to validate the AT command but may be not both. Some ignore the \r but not always. Some would actually work without entering CR/LF

I'd be tempted to say \n is your command line validator and the \r was kept as part of the name
try just
mySerial.print("AT+NAMEDemo\n");

The name on the board is just the name of the board and not relevant. They could be the other way round, There seems to be little variations in the AT commands. I don't think they cause any grief. It doesn't in your case does it?

they would if OP were to depend on the module's name for something.
Module B's name probably includes the '\r' and so would fail a

if (! strcmp(moduleName, "Demo")) {
  ... // do something if this is the right module
}

So for having just the '\r' or '\n' or no line endings at all after AT comm gives these responses:
Module A: No response
Module B: 'ERROR'

Yes, you're right, I'm having issues connecting to the module since our app connects to a specific module name say 'Demo', and won't be able to connect to it if its 'Demo '
Will try flashing the original HM10 firmware on the Module B to see if that helps.
Thanks

I thought it was usual to use the module's address, thereby making the name irrelevant.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.