HC-05 bluetooth module not working with Nano 33 BLE

Hello,

When HC-05 is connected to RX and TX pins of Nano 33 BLE, Serial1 sends data to PC, but transmitting to Arduino does not work . The same code works well in Arduino Uno using SoftwareSerial as well as hardware Serial. What's wrong with Nano 33 BLE?

br, EHi

// #include <SoftwareSerial.h>
// SoftwareSerial mySerial(10, 11);    // RX, TX

boolean newData = false;  
const byte numChars = 32;
char receivedCmd[numChars];
unsigned long t1 = millis();

void setup() {
  Serial1.begin(9600);         // Nano 33 BLE (RX, TX)
  //  Serial.begin(9600);      // Uno hardware serial (RX, TX)
  // mySerial.begin(9600);     // Uno software serial
}

void loop() {
  // put your main code here, to run repeatedly:
  readCommandData();
  delay(1000);
  if (newData == true) {            // new command string
    String cmdStr = String(receivedCmd);
    Serial1.print("Reveived command: ");
    // Serial.print("Reveived command: ");
    // mySerial.print("Reveived command: ");
    Serial1.println(cmdStr);  
    // Serial.print("Reveived command: ");
    // mySerial.println(cmdStr);  
    newData = false;
  } 
  //---
  if (millis() - t1 >  5000) {
    Serial1.println("Still alive...");
    // Serial.println("Still alive...");
    // mySerial.println("Still alive...");  
    t1 = millis();
  }
}

void readCommandData() {
    static boolean recvInProgress = false;
    static byte ndx = 0;
    char startMarker = '<';
    char endMarker = '>';
    char rc;
    while (Serial1.available() > 0 && newData == false) { 
    // while (Serial.available() > 0 && newData == false) { 
    // while (mySerial.available() > 0 && newData == false) {
        rc = Serial1.read(); 
        // rc = Serial.read();
        // rc = mySerial.read();
        if (recvInProgress == true) {
            if (rc != endMarker) {
                receivedCmd[ndx] = rc;
                ndx++;
                if (ndx >= numChars) {
                    ndx = numChars - 1;
                }
            }
            else {
                receivedCmd[ndx] = '\0'; // terminate the string
                recvInProgress = false;
                ndx = 0;
                Serial1.flush();
                // Serial.flush();
                // mySerial.flush();
                newData = true;
            }
        }
        else if (rc == startMarker) {
            recvInProgress = true;
        }
    }
}

Hello EskoO,

The short answer to your question is that the HC-05 and Nano 33 BLE are two slightly different times of Bluetooth. If you look at the Arduino BLE library: ArduinoBLE - Arduino Reference you will see that the process is completely different.

I have had some success with a HM-10 which uses the same style of Bluetooth as the BLE (see here: Problems with connecting BLE to AT-09/HM-10 board - #2 by matt_lee_smith - Nano 33 BLE Sense - Arduino Forum) but that is all I know.

Getting the new nano's to do full Bluetooth is also being discussed: Can the NANO IOT 33 run Full Bluetooth (NOT BLE)? - Nano 33 IoT - Arduino Forum

Hope that starts you off somewhere.
Matt

matt_lee_smith:
Hello EskoO,

The short answer to your question is that the HC-05 and Nano 33 BLE are two slightly different times of Bluetooth.
Matt

@Matt , you miss the point, @EskoO is using HC-05 module connected to hardware serial of Nano BLE , but nothing with BLE itself (just the board name). There is no reason why Nono BLE cannot control HC-05.
Possible issue:

  1. Baud rate is not the same (even it is set to the same value) -
  2. Serial 1 - try to loop NanoBLe - send something- and you should receive the same - monitor it via Serial.print via USB.
  3. Loop HC05 - you should receive what you send
  4. Remove 'newdata' flag from your code - for test purpose