Arduino UNO doesn't answer to AT commands

#include <SoftwareSerial.h> 
 
SoftwareSerial mySerial(2, 3); 
 
void setup(){

  Serial.begin(9600);
  Serial.println("Enter AT commands:");
  mySerial.begin(38400);

}
 
void loop(){

  if (mySerial.available())
    Serial.write(mySerial.read());
  
  if (Serial.available())
    mySerial.write(Serial.read());

}

Trying to configure a HC-05, the "Enter AT commands:" appears fine but when i enter "AT" at the serial monitor nothing happens.

What baud rate is the HC05 expecting?

9600 baud, and the serial monitor ir already put on 9600

If the HC05 is expecting 9600 then why are you setting the interface that it uses to 38400 baud ?

According to this page:

Key/EN: It is used to bring Bluetooth module in AT commands mode. If Key/EN pin is set to high, then this module will work in command mode. Otherwise by default it is in data mode. The default baud rate of HC-05 in command mode is 38400bps and 9600 in data mode.

So maybe 38400 is right.

@thezeus have you connected the key/EN pin? Has the HC05 previously been set to another baud rate?

The Key/EN pin is disconnected and the HC05 has been used in another project but the baud rate was not changed

Problem solved.

Then i just need to connect the EN pin to the arduino and set it to HIGH?

See post #5

Still doesn't seem to work. I put the pin on EN set to HIGH (according to the post, setting it to command mode) and now the "begin's" are at 38400.

If you have se Serial.begin() to 38400 have you also adjusted the baud rate of the Serial monitor ?

Yes, the serial monitor is also at 38400 baud

Try all the baud rates in case it was previously changed

Baud rates: 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, and 460800

Although I don't think Software Serial will go beyond 115200 on Uno (which is what I guess you are using, you forgot to say).

I tried every baud value until 57600 and 38400 and beyond just appears a lot of blank squares. I think the value is 9600, but for some reason it still doesn't work.

I can't think of anything else to try right now. Maybe your HC05 has gone faulty.

I don't think because someone used it right before me. But thanks for trying to help

Did you and "someone" use a voltage divider to connect UNO TX to HC05 RX ?

All this talk about baud rates is utter nonsense. Your code is correct, and all you need do is ensure that the serial monitor is set to 9600, which it probably was all along, and, if you clearly see
Enter AT commands:
on it, that confirms it - even though seeing it has nothing to do with configuring Bluetooth.

If you want to configure an HC-05 you set the serial connected to it at 38400 - no ifs, buts, or maybes, no exceptions, and irrespective of what's gone on before. That's right, 38400 on mySerial, even though Serial is 9600.

Your problem may be down to wiring. Check that Bluetooth is connected Rx>Tx and Tx>Rx, i.e Uno pin 2 Rx to Bluetooth TX. Also, in the light of recent events around here, you may not actually have a kosher HC-05. Post a picture here, along with any other details you may have to hand from the seller.

1 Like

What do you have your "line ending" set to?
Modem-like devices can be fussy about what they want, and the Arduino default (?) of "none" is not going to make anything happy.

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