I got the ble module to work fine following online guide. However when i changed the baud rate: AT+BAUD1 which changed to 19200 however ever since i was not able to get at commands to work.
tried: arduino nano, FTDI programmer, software serial, normal tx, rx
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(8,9); //RX|TX
void setup(){
Serial.begin(9600);
BTSerial.begin(9600); // default baud rate
while(!Serial); //if it is an Arduino Micro
Serial.println("AT commands: ");
}
void loop(){
//read from the HM-10 and print in the Serial
if(BTSerial.available())
Serial.write(BTSerial.read());
//read from the Serial and print to the HM-10
if(Serial.available())
BTSerial.write(Serial.read());
}
-
1If you set it to 19200, why are you using 9600?gre_gor– gre_gor2017年12月10日 04:01:03 +00:00Commented Dec 10, 2017 at 4:01
1 Answer 1
You changed the baud rate that the Bluetooth module uses to communicate with your Arduino but you forgot to change the baud rate that the Arduino uses to communicate with the Bluetooth module. These must match. From consulting the SoftwareSerial library's reference page, you can see that is set by this line of your code:
BTSerial.begin(9600)
That sets the software serial communication rate at 9600 baud. You need to change it to this:
BTSerial.begin(19200)