0
\$\begingroup\$

Recently purchased an Hm-11 BLE module, and connected it to a Teensy 3.2.

I can see the BLE module (AnyFlite) on my phone using the MSMBle app.

The following code was used to initialize it:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(7, 8); // RX, TX
void setup()  
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  Serial.println("Goodnight moon!");
  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
} 
void loop() // run over and over
{
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available())
    mySerial.write(Serial.read());
}

When opening the Serial monitor, I see the "Good Morning" text, however when sending AT commands there is no response. There is nothing received on the phone app either. (when connecting all I see is received text: 00

Upon sending commands from my phone to the module, I see garbage values in the serial monitor.

My understanding is that this is caused by a baud rate mismatch.. I have cycled through all the Baud rates and still face the same issue.

I checked the voltage between ground and vcc of the module and it is at 3.3v, which is what is required.

Exhausted all troubleshooting options.

EDIT

Changed to the following code when I was told about UARTS:

#define HWSERIAL Serial3

void setup() {
  Serial.begin(9600);
        HWSERIAL.begin(57600);
}

void loop() {
        int incomingByte;

  if (Serial.available() > 0) {
    incomingByte = Serial.read();
    Serial.print("USB received: ");
    Serial.println(incomingByte, DEC);
                HWSERIAL.print("USB received:");
                HWSERIAL.println(incomingByte, DEC);
                HWSERIAL.write(Serial.read());
  }
  if (HWSERIAL.available() > 0) {
    incomingByte = HWSERIAL.read();
    Serial.print("UART received: ");
    Serial.println(incomingByte, DEC);
                HWSERIAL.print("UART received:");
                HWSERIAL.println(incomingByte, DEC);
                Serial.write(HWSERIAL.read());
  }
}

When I send an AT command from the Serial Monitor, I get the following:

USB received: 65
USB received: 10

When I send a command from my phone (in this case AT+ADDR?), I get the following:

UART received: 12
ÿUART received: 8
ÿUART received: 13
î

Still, garbage is being output.

\$\endgroup\$
  • \$\begingroup\$ What is the expected behavior of the firmware currently loaded into the HM-11, and what is your specific basis for believing that is what is actually in yours? When you say you have changed the baud rates, do you mean in the sketch or on the PC terminal program, or both? Why are you using a wasteful SoftwareSerial instance on a device with plenty of hardware UARTs? \$\endgroup\$ – Chris Stratton Mar 4 '17 at 17:34
  • \$\begingroup\$ Expected Behavior: OK is returned in the serial monitor. Changed the baud rates of mySerial, meaning the baud rate for the software serial port (also tried both). did not know about UARTs, will look it up. \$\endgroup\$ – user2883071 Mar 4 '17 at 18:09
0
\$\begingroup\$

Bad Soldering was the culprit.

\$\endgroup\$

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.