[solved] HC-06 with SoftwareSerial

I've used HC-05s and HC-06s before for several successful projects, but each time I used a Bluetooth module, it was using a hardware serial port.

Now I'm trying to make an update to my tutorial here to handle the case where people only have an Uno or Nano and don't have access to multiple hardware serial ports to configure their Bluetooth modules. If anyone can help me figure this out I'll give a shutout to you in the tutorial :wink:

The problem:
I have a Nano I'd like to use to put my HC-06 into AT mode. I have wired up my Nano and HC-06 as so:

BT VCC <--> Nano 5V
BT GND <--> Nano GND
BT TX <--> Nano D2 (SW RX)
BT RX <--(voltage divider)--> Nano D3 (SW TX)

I've used the following code from this tutorial.

#include <SoftwareSerial.h>
SoftwareSerial BTSerial(2, 3); // RX | TX
 
void setup() 
{
    Serial.begin(9600);
    Serial.println("Arduino with HC-06 is ready");
 
    // HC-06 default baud rate is 9600
    BTSerial.begin(9600);  
    Serial.println("BTserial started at 9600");
}
 
void loop()
{
 
  // Keep reading from HC-06 and send to Arduino Serial Monitor
  if (BTSerial.available())
    Serial.write(BTSerial.read());
 
  // Keep reading from Arduino Serial Monitor and send to HC-06
  if (Serial.available())
  BTSerial.write(Serial.read());
}

I also made sure that the serial monitor was at 9600 baud with "no line ending" selected.

The issue is that when I run the code and send "AT", I get no response from the HC-06 at all.

This is driving me INSANE cause there is no reason this shouldn't be working - I've even reswapped TX and RX with no luck. Any thoughts?

Ok, I got it to work. Turns out it just takes a long time for the HC-06 to respond sometimes. Quite frustrating, but at least it works

"only having a Uno or Nano" is not an impediment to using hardware serial to config an HC-06, It can be done as a one-shot in setup as a matter of preference, and is all I use even on a Mega with Bluetooth routinely on Serial2.

HC-06 is in AT mode by default, something you might point out in your tutorial.

Nick_Pyner:
"only having a Uno or Nano" is not an impediment to using hardware serial to config an HC-06, It can be done as a one-shot in setup as a matter of preference, and is all I use even on a Mega with Bluetooth routinely on Serial2.

Fair point, but for the functionality I wanted to give to the user, I wouldn't be able to do it with just the one port.

I want users to be able to use 1 circuit (including both modules) and use 1 sketch to pair, bind, and link the modules and to be able to see real-time feedback while it is all happening. Also, user input is required to specify what name is desired for the HC-06. Lastly, all of the code for the tutorial sketch is in setup() as you mentioned.