Hi Guys,
I have been using a HM-10 breakout board with an arduino and it works fine but i need to increase baud rate as the default 9600 isn't fast enough for what i need. To do this i need to send it an AT command, but sending any AT message to it just returns an "ERROR" string.
Here is this code i got that allows you to send messages to the HM-10 using sketches serial terminal.
#include <AltSoftSerial.h>
AltSoftSerial BTserial;
// https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
char c=' ';
boolean NL = true;
void setup()
{
Serial.begin(9600);
Serial.print("Sketch: "); Serial.println(__FILE__);
Serial.print("Uploaded: "); Serial.println(__DATE__);
Serial.println(" ");
BTserial.begin(9600);
Serial.println("BTserial started at 9600");
}
void loop()
{
// Read from the Bluetooth module and send to the Arduino Serial Monitor
if (BTserial.available())
{
c = BTserial.read();
Serial.write(c);
}
// Read from the Serial Monitor and send to the Bluetooth module
if (Serial.available())
{
c = Serial.read();
// do not send line end characters to the HM-10
if (c!=10 & c!=13 )
{
BTserial.write(c);
}
// Echo the user input to the main window.
// If there is a new line print the ">" character.
if (NL) { Serial.print("\r\n>"); NL = false; }
Serial.write(c);
if (c==10) { NL = true; }
}
}
I have searched everywhere on this and i haven't found any mention of the HM-10 breakout board sending back "ERROR" and why it does this.
It works as it came with its default baud rate. I mentioned that to show that it has been wired and otherwise setup correctly. The issue is it doesn't seem to know when i am trying to send it AT commands.
Given the lack of response i can only assume that i haven't made any obvious mistakes and i'm probably just using a crappy clone. Has anyone had one of these running properly with AT commands? If so where can i find one? Cheers
In case this is helpful for anyone with a similar issue..
I got an official hm-10 and it responded fine to AT commands straight away so i think it might have been the firmware on the clone. It was perhaps too old and needed to be manually put into AT mode? I didn't get as far as trying once i got official working one. From what i read, normally a hm-10 will just respond with nothing if it fails to interpret an AT command, not give back "ERROR". I have not seen this type of response mentioned anywhere.
After all that i still had issues even with the official hm-10 as after setting a new baud rate and setting the serial monitor the match it, the device seems to be unresponsive.
I also couldn't get any response to AT commands with BTserial.write() in the sketch code. I wouldn't have thought using something other than the default baud rate would be such a feat! It's been quite frustrating.
Thankfully the latest official hm-10 firmware to date now has 115200 as the default baud rate which is what i was after all along. So i just updated the firmware and now don't have to worry about AT commands. Easy to do on an official hm-10 i'm not so sure about a clone.
In short. If you want 115200 baud on a hm-10 you might be better off taking the time to update the firmware.