I'm trying to simply access my HC_05 bluetooth module and conduct some AT commands through the Serial Monitor. For some reason though, it only seems to be returning Null characters, though it does some to be actually responding to the command in some way (given by the length of Null characters it returns.

enter image description here

So you can clearly see that the command AT and AT+NAMEdevice return different data, but they are both all NUL blocks. I am viewing the monitor in text. Changing the view to Hex or ASCII does not change results.

Code for this simple program is below:

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(10, 11); // RX | TX

void setup()
  pinMode(9, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
  digitalWrite(9, HIGH);
  Serial.println("Enter AT commands:");
  BTSerial.begin(38400);  // HC-05 default speed in AT command more

void loop()

  // Keep reading from HC-05 and send to Arduino Serial Monitor
  if (BTSerial.available())

  // Keep reading from Arduino Serial Monitor and send to HC-05
  if (Serial.available())

Wire Diagram is as here NOTE I have used both a direct connection to the 5V and also used a Voltage Divider. Neither changes the NUL return.

  • A couple of question/suggestions. Have you set the serial monitor baud rate to 9600? Try adding a small delay (5ms) at the end of loop. In the past I have had trouble with SoftwareSerial. It can cause trouble. Try using the hardware serial (pins 0 and 1) and see if you can communicate with it.
    – Stefan Bossbaly
    Mar 8, 2014 at 20:27
  • @StefanBossbaly Yes, all of those things have been tried, and none with any positive results. The error persists throughout all of them.
    – JcKelley
    Mar 8, 2014 at 22:04
  • Are you sure the module is running at 38400 baud?
    – sachleen
    Mar 26, 2014 at 6:10
  • 1
    Shouldn't it be while (BTSerial.available()) and while (Serial.available()) instead of if...?
    – jfpoilpret
    Mar 26, 2014 at 6:40
  • Have you tried to force the Key pin of HC-05 directly to +V, instead of using Arduino pin 9, just to remove one potential issue?
    – jfpoilpret
    Mar 26, 2014 at 22:23

2 Answers 2


First, change all Serial.write to Serial.print I think that might be half your problem.


  pinMode(9, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
  digitalWrite(9, HIGH);

The way you are doing this will probably put the HC-05 into 9600 baud mode. You can fix this one of two ways:

Change BTSerial.begin(38400); to BTSerial.begin(9600);

Or, as jfpoilpret suggested, tie the Key pin directly to VCC. The reason is that in order to go into 38400 baud mode, there must be voltage on Key at the time the module is powered up. By the time the digital write in your code happens, it's too late.

If for some reason you'd like to have digital control over the Key pin rather than directly wiring it to VCC, yet you'd like the module to operate at 38400 baud, you can simply change the default baud rate by issuing the appropriate AT command - I believe it's AT+UART= off the top of my head.

Also, I'm not sure, but jfpoilpret might be right as well about how your serial read/write handling is done within loop() but here is code that I know works:

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(10, 11); // RX | TX
char myChar;

void setup()

void loop() {
  while (BTSerial.available()) {
    myChar = BTSerial.read();

  while (Serial.available()) {
    myChar = Serial.read();
    Serial.print(myChar); //echo

This sounds like baud-rate mismatch. These dongles don't have a reset ability; they remember their most recent settings. See my answer to another user having trouble communicating with one these.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.