I am learning about Bluetooth and attempting to use AT+ commands to configure an HM-10 module on Arduino Mega.
Here is the code:
void setup(){
Serial.begin(9600);
Serial1.begin(9600); // default baud rate
pinMode(LED_BUILTIN,OUTPUT);
delay(250);
Serial.println("AT commands: ");
delay(250);
}
void loop(){
//read from the HM-10 and print in the Serial
if(Serial1.available())
Serial.write(Serial1.read());
//read from the Serial and print to the HM-10
if(Serial.available())
Serial1.write(Serial.read());
//use AT+LADDR to read address
}
Here is the result of a module brand new out of the box that works with AT+HELP:
* -----------------------------------------------------------------*
* Note: (M) = The command support master mode only. *
********************************************************************
* Command Description *
* ---------------------------------------------------------------- *
* AT Check if the command terminal work normally *
* AT+RESET Software reboot *
* AT+VERSION Get firmware, bluetooth, HCI and LMP version *
* AT+HELP List all the commands *
* AT+NAME Get/Set local device name *
* AT+PIN Get/Set pin code for pairing *
* AT+BAUD Get/Set baud rate *
* AT+LADDR Get local bluetooth address *
* AT+ADDR Get local bluetooth address *
* AT+DEFAULT Restore factory default *
* AT+RENEW Restore factory default *
* AT+STATE Get current state *
* AT+PWRM Get/Set power on mode(low power) *
* AT+POWE Get/Set RF transmit power *
* AT+SLEEP Sleep mode *
* AT+ROLE Get/Set current role. *
* AT+PARI Get/Set UART parity bit. *
* AT+STOP Get/Set UART stop bit. *
* AT+INQ Search slave model *
* AT+SHOW Show the searched slave model. *
* AT+CONN Connect the index slave model. *
* AT+IMME System wait for command when power on. *
* AT+START System start working. *
* AT+UUID Get/Set system SERVER_UUID . *
* AT+CHAR Get/Set system CHAR_UUID . *
* -----------------------------------------------------------------*
* Note: (M) = The command support master mode only. *
Here is the result of a second module, same supplier, same wiring, that fails when entering AT+HELP after trying to change its baud rate:
f⸮⸮⸮⸮⸮怘⸮
What is wrong with the failed module? The odd characters tell me it's a baud rate issue, but supposedly AT+ mode is locked in at 9600 baud.
EDIT: I was able to replicate this error by entering AT+BAUD3, which bricked the originally working module into behaving the same way. Now both modules don't work.
You have some sort of communication, so this is probably not true.
AT+RESET or AT+RENEW might fix things. i don't know what the differences are - if any.
There is never any point in fartarsing about with baud rates. Arduino only talks to Bluetooth at the rate Bluetooth is configured for, and only to monitor at the rate you have commanded, to which the monitor must match. No exceptions.
Curious about this, I see that AT+RENEW resets to factory spec. RESET is for reboot! I understand this applies to all BLE devices, so this should work for you. Supplier also clearly specifies that this is a CC2541 version. This means it is an HM-10 with a reduced instruction set. It is in effect little more than an HC-05, and I bet intended as that for those with IOS. I believe it is the most common BLE device around, and the problem should be fixable. I do hope you have been successful in using this before you started with AT mode.
Nick_Pyner:
Curious about this, I see that AT+RENEW resets to factory spec. RESET is for reboot! I understand this applies to all BLE devices, so this should work for you. Supplier also clearly specifies that this is a CC2541 version. This means it is an HM-10 with a reduced instruction set. It is in effect little more than an HC-05, and I bet intended as that for those with IOS. I believe it is the most common BLE device around, and the problem should be fixable. I do hope you have been successful in using this before you started with AT mode.
I tried AT+RENEW. The same problem occurs. Must be some other problem.
The Amazon page states the module to be AT-09 (whatever that means), and claims it to be "very similar" and "compatible" with HM-10. Since it appears to be otherwise undocumented, you may be out of luck.
However, if you can find someone with an oscilloscope, determining the current serial Baud rate is trivial.
There are lots of comments on the internet about fake HM-10s and even Jinan Huamao includes information in the data sheets. I do not see the non-HM-10s as fakes, I see them as similar devices with different firmware. To me if they were fakes they would copy the firmware.
I think a lot of the problem comes from how the non-HM-10s are sold, especially on places like ebay and aliexpress. You will often see modules sold as HM-10s when they are in fact not. One of the easiest ways to spot the non-HM-10s was the lack of a crystal, unfortunately you can now buy actual HM-10s without the crystal so the confusion is likely to get worse.