How to Use Bluetooth Modules

Sam just shared a new tutorial: "How to Use Bluetooth Modules"



So we’ve taken a look at what Bluetooth is in our Introduction to Bluetooth tutorial, and hopefully, you’ve found our Choosing a Bluetooth Module For Your Project tutorial useful in deciding which Bluetooth module is right for your p…

Read more

Hi there,

I’m having issues with getting the AT commands working.
I have added a button to the module and it enters AT mode as expected. Since I’m using an Arduino Due I don’t need to use SoftwareSerial, but can instead use Serial1. The tutorial doesn’t explain how to wire the module to the Arduino, but I have connected RXD to TX1, TXD to RX1, Vcc to 5V, and GND to GND. I get ERROR:(0) everytime I enter AT to the serial monitor.
I am also confused by which baud rates I should be using (the first code in the tutorial uses two different rates).

This is my code, taking into account Serial1 instead of SoftwareSerial

void setup()
{
  Serial.begin(9600);
  Serial1.begin(38400);
  pinMode(22, OUTPUT);
  digitalWrite (22, HIGH);
}

void loop()
{
  if (Serial1.available())
  {
    Serial.write(Serial1.read());
  }
  if (Serial.available())
  {
    Serial1.write(Serial.read());
  }
}
``````````````````````````````````

There has been a development!

Typing ‘AT’ into the serial monitor gives ‘ERROR:(0)’. But if I type ‘AT+VERSION?’ it successfully supplies the version and also replies ‘OK’. If after that I type ‘AT’, it replies ‘OK’. So essentially it works to ask for another AT command before asking ‘AT’ directly.

I’m not sure why this is the case. I think the code above might be useful for others trying to use the Due with HC-05, so is good to keep up there. My wiring is correct also. In relation to Baud rate: using serial monitor 2900 and Bluetooth 38400 works, but so does using 38400 for both.

1 Like

If the device is doing automatic baud rate detection (which your comment about working OK with different baud rates implies) then the first few characters of any session will be lost as the device tries to detect the correct baud raqte to use. So perhaps it’s not the ‘AT’ that doesn’t work, but the first few characters whatever they are.

1 Like

Michael Parker was nice enough to reach out with some specific changes he made to this guide to get it working with the Arduino Nano platform.

Specifically changing the RX and TX ports used from (0, 1) to (11, 10) and following this wiring diagram resulted in the expected communication between the HC 05 module and the Serial Monitor.

Wiring diagram and advice passed on to us through Michael Parker from this Arduino forum thread about a similar issue.

Hopefully, someone working with the HC-05 and an Arduino Nano can find this information useful!

1 Like