HM-10 Beacon Detector - issues with detecting beacons

Hello,
I’d like to ask for you guidance in my project. My goal is to detect iBeacons (or beacons in general). My setup is:

  • Arduino UNO R3 board
  • HM-10 bluetooth module (true HM-10)

I managed to wire above correctly so that beacons are detected however I have some issues with the data that i receive from HM-10 dongle. The connection is done via Software Serial and the issue is that it seems that the messages that i get are somehow cut - like transmission is interrupted. Here is the code that I use:

#include <SPI.h>
#include <SoftwareSerial.h>

String inputTXT;

SoftwareSerial mySerial(5, 6); // RX, TX  


void setup() {  
  Serial.begin(9600);

  mySerial.begin(9600);

  //setup
  mySerial.write("AT");
  delay(100);
  mySerial.write("AT+ROLE1");
  delay(100);
  mySerial.write("AT+IMME1");
  delay(100);
  mySerial.write("AT+RESET");
  delay(50);

}

void loop() {  

  delay(3000);

  
  mySerial.write("AT+DISI?");
  
  if (mySerial.available()) {
    inputTXT = mySerial.readString();
  
    Serial.println(inputTXT);
  
    inputTXT = ""; 
  }
}

Normally the response is:

OK+DISISOK+DISC:4C000215:E9780B60F7194ADAA0BE5A98BAA5C976:04D2162EBF:685FCA5B1F45:-057OK+DISCE

However sometimes the code is cut and shows:

OK+DISISOK+DISC:4C000215:B9407F30F5F8466EAFF925556B57FE6D:40243065A5:FB

The situation is getting worse when I have more than 3 beacons around. If I have 6-7 sometimes the data received from HM-10 is totally scrambled and there is no response… My project requires to handle multiple number of beacons changing quickly in time so reliable info on discovered beacons is a key.

I appreciate any ideas and/or best practices here :slight_smile:

Thanks,
Robert

SoftwareSerial is hard to use. I'd recommend you a Mega instead of the Uno, which has 4 real Serial devies.

Thanks. When I tried it seems that there is no real reason for it to act weird. Sometimes it reads full data without issues, sometimes its stuck and throws some garbage. Especially when there is 5+ beacons around.

I think I'll order Mega but in a meantime any idea how to solve that is appreciated!

Regards,
Robert

Untried - but you might take a look at NeoSWSerial as a replacement for the vanilla SoftwareSerial.

Will have a look at it over the weekend. Thanks!