Cannot receive data from HC-06 with mac

Hi all

I'm trying to receive data from an Arduino with an HC-06 module but somehow cannot get the connection and data flow established.

I'm using an Arduino Uno R3 with the HC-06 as follows:
HC-06 Module with:
VCC -> Arduino 5V
GND -> Arduino GND
TXD -> Pin 8
RXD -> Pin 9 (reduced to 3V with a voltage divider)

The following code should just send back some timestamp to validate the data flow:

#include <SoftwareSerial.h>

//HC-06 TXD -> Arduino Pin 8
//HC-06 RXD -> Arduino Pin 9
SoftwareSerial btSerial(9, 8); // New RX, TX pins

const long interval = 1000; // Interval for sending the time (in milliseconds)
unsigned long previousMillis = 0; // Variable to store the last time the message was sent

void setup(){
   btSerial.begin(9600);
  // Send an initial message
  btSerial.println("Arduino is ready. Sending time since start...");
}

void loop() {
  // Get the current time in milliseconds since the Arduino started
  unsigned long currentMillis = millis();

  // Check if the interval has passed
  if (currentMillis - previousMillis >= interval) {
    // Save the last time the message was sent
    previousMillis = currentMillis;

    // Send the current time in milliseconds through the serial connection
    Serial.print("Time since start: ");
    Serial.print(currentMillis);
    Serial.println(" ms");
  }
}

Connecting with my Mac, the module appears in the bluetooth list and it appears to pair. In terminal I see the device with ls /dev/tty.* appear. However:

  • The LED continues blinking (I think it should turn red when paired?)
  • Trying to connect with terminal using "screen /dev/tty.HC-06 9600" returns "resource is busy".

Any ideas?

SoftwareSerial btSerial(9, 8); // New RX, TX pins

Pin 9 of the Uno is Rx

RXD -> Pin 9 (reduced to 3V with a voltage divider)

You appear to have it connected to the Rx pin of the HC-06. If so then you have Rx connected to Rx, which is wrong. Rx on one end should connect to Tx on the other and vice versa

So just to be extra clear:

Arduino Pin 9 (voltage divided to 3V) --> HC-06 RXD

should therefore be considered as follows?

My original post:
SoftwareSerial btSerial(9, 8); // New RX, TX pins

Your suggested correction:
SoftwareSerial btSerial(8, 9); // New RX, TX pins

That looks better

It does not matter which end of the connection you change as long as they are Rx-Tx and Tx-Rx

I have used an HC=06 with a Uno and no voltage divider on the HC-06 Rx end but it is not to be recommended

This did the trick. Thanks a lot for helping me identify this incredible oversight! :slight_smile:

I am glad that I was able to help

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.