-1

I'm trying to issue a connection via HM-10 from arduino (rather than my phone). However, I'm unable to start a connection from arduino using both AT+CON and AT+CONNL. When I try AT+CON I get OK+CONNA and when I use AT+CONNL I get OK+CONNE. Here's my code:

#include <SoftwareSerial.h>
SoftwareSerial bluetooth(8,9);


void setup() {
  Serial.begin(115200);
  Serial.setTimeout(50);
  bluetooth.begin(115200); //open BLE connection
  bluetooth.setTimeout(50); //set timeout
  bluetooth.write("AT+ROLE1");
  //bluetooth.write("AT+ROLE0");
  delay(50);
  bluetooth.write("AT+NOTI1");
  delay(50);
  bluetooth.write("AT+CONC40BCB403020");
  delay(50);
  //bluetooth.write("AT+CONNL");
}

void loop() {
    while (bluetooth.available() > 0) {
      String response = bluetooth.readString();
      Serial.println(response);
    }
}

The response that I get is:

OK+Set:1
OK+Set:1
OK+CONNA
  • Can you let us know what is the response to the commands AT+CON and AT+CONN after 10 seconds? – Sumit Panse Jun 7 '18 at 11:46
0

By now you've surely moved past this, but: I found that I had to try connecting multiple times in order to get a connection to complete. Also, your timeout might need to be longer?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.