Good morning folks!
I was trying to create a little program to use Arduino as a bluetooth remote controller for a second Arduino and was planning using the HM-10 BLE module. I would like to configure the HM-10 automatically with the sketch in the setup but the module seems not receiving the AT-commands. I used the following sketch:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
mySerial.println("Hello, world?");
mySerial.write("AT"); //PING
if (mySerial.available()) {
Serial.println(mySerial.read());
}
}
void loop() { // run over and over
while(flag){
Serial.println("Loop");
flag=0;
}
if (mySerial.available()) {
Serial.write(mySerial.read());
}
if (Serial.available()) {
mySerial.write(Serial.read());
}
}
As you can see this is the SoftwareSerial example where I simply put something to send AT commands and receive the answer from BT module.
Why is not working?
If I send the commands manually through the serial all is good, but nothingn happens when I put them in the sketch. The HM-10 is "out of the box", so standard configured.
Again, I would like to configure it automatically as Master or Slave, change the baud rate, change the module name or else.
Any suggestion?
Thank you guys!!