I'm working on a project where I'll need to establish a connection between two HC-05 modules, each connected to an Arduino, but for now I'm just trying to get one to work and connect to my phone, but I'm not sure if I'm doing anything right...

I'm not able to give AT-Commands, and as a result the device is not able to pair with my phone. My setup looks something like this:

enter image description here

With minor differences being that I'm using an Uno board instead of a Mega, the RX and TX pins are connected to...well, I tried a lot of different pins, from the default RX/TX pins to specifying other pins like the ones in the code, as well as reversing the connections (RX to TX, TX to RX), also this schematic neglected to mention the 'ENABLE' pin, which I connected to my Arduino's 3,3V pin.

I tried a lot of different code samples, the latest one I tried is the following:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.println("Enter AT commands:"); // a prompt in Serial Monitor
  // Deleted while loop, unnecessary


void loop() { // run over and over
  //if (Serial3.available()) { // we don't use Serial3 any more
  if (mySerial.available()) {
  if (Serial.available()) {

Which I blatantly ripped-off from this answer, with minor changes.

So, I connect my Arduino to my PC, upload the code, connect my module, set the serial monitor's baud rate to 38400 and...a bunch of gibberish appear on screen, just an alternating sequence of the characters 'x' and '?', to my understanding that's actually the message "Enter AT commands:" written in my code...

Now, with this exact setup, I'm now actually receiving a response to my commands, except the response is also gibberish, this is as far as I've gotten.

EDIT: By following some of the comments and setting the Serial baud rate to 38400, I managed to get other Reponses to my commands, but it's just a new type of gibberish and it's still not actually responding to my commands.

The thing is, all of the tutorials I've seen online are contradicting each other, some connect the RX and TX pins in reverse to the Arduino, some don't, some specify other pins on the board, some don't bother with the ENABLE pin entirely, some don't use a voltage divider, some connect VCC pin to the 3,3V instead of the 5V, some even skip the AT-Command setup entirely!

One last detail I feel like I should mention, there's a red light that blinks on and off every two seconds, I believe that means the module is read to receive commands but I've seen contradicting information about this as well so I'm not sure.

I want to know what I'm doing wrong, and what's the right way to do this?

  • I spent hours trying to figure this out too. So many pitfalls, RX vs TX, software serial vs pins 1/0, baud rates, NL & CR settings in the serial monitor, having to press the button while powering on the module.
    – Thomas
    Commented Feb 15, 2022 at 3:01
  • It's been a year since I made this post and I sadly don't remember the setup I did to solve the problem, I think it might have been not using and resistors and just directly connecting the HC module to the Arduino, sorry but I'm not sure.
    – The Riser
    Commented Feb 15, 2022 at 13:08

1 Answer 1


You have seen contradictory statements, because there are many variables here, that might be different for each of the tutorials.

some connect the RX and TX pins in reverse to the Arduino, some don't, some specify other pins on the board

There are basically 2 ways to communicate between the Serial Monitor and the HC-05:

  • You can connect the HC-05 directly to the USB Serial chip on the Arduino board, thus you would communicate directly with the HC-05. In that case the TX and RX pins are used, since they are connected to the USB Serial chip. But the labels TX and RX are referring to the Arduinos chip (Atmega328p at the Arduino Uno). Since serial connections need to be connected alternating (RX to TX and TX to RX), the pin labeled TX leads to the RX pin of the USB Serial chip and vice versa.

    Thus you would connect TX of HC-05 to the TX pin on the Arduino and RX of HC-05 (through the voltage divider) to the RX pin on the Arduino. Also you should program the Arduino with an empty sketch before doing that, so that the Arduino does not interfere in the Serial communication with its own Serial usage.

  • Or you can use a SoftwareSerial interface and let the Arduino code translate between the devices. The Arduino received from the PC and sends the data to the HC-05. Also it receives from the HC-05 and sends that data to the PC. This is what you were trying. But you absolutely need to specify a different set of pins for the SoftwareSerial interface, than 0 and 1. These pins are doing the hardware Serial interface, which is connected to the PC. So change these pin numbers (for example to 2 and 3).

    In fact: Whenever you see a code for Uno, Nano or Mega using SoftwareSerial on pins 0 and 1, you can be sure, that it is garbage.

I connect my Arduino to my PC, upload the code, connect my module, set the serial monitor's baud rate to 38400 and...a bunch of gibberish appear on screen

Even when you change the pins as described above, your code still uses 9600 baud for the connection to the PC. When you set the Serial Monitor to 38400 while the code uses 9600 baud for that interface, you will get just gibberish. Either change your Serial Monitor to 9600 baud or change your code to Serial.begin(38400). The last option is better, since that makes sure, that you are using the same baudrate for both interfaces.

some don't bother with the ENABLE pin entirely

The ENABLE pin seems to have a pulldown resistor on the HC-05 board, which pulls it to ground, when nothing is connected. Ground means data mode, HIGH command mode. So when they don't connect anything, they want to stay in data mode. Though this also depends on if the specific HC-05 board has a pulldown or pullup resistor there. Pulldown is more likely, but since there is no one single producer of these modules, you cannot be sure. Since you want to get into AT mode, you should use command mode and connect it to 3.3V. For normal operation it would go to ground. Though you can also connect it to a digital output pin of the Arduino and let the code decide in which mode the module should be.

some don't use a voltage divider

The chip on the HC-05 board is a 3.3V device. The actual breakout boards, that can be bought everywhere, mostly only add a voltage regulator from 5V to 3.3V, an LED for status display and break out the necessary pins. The data pins are mostly directly connected to the chip. There are many resources, that claim the HC-05 to be 5V tolerant, but also many that antagonize that. To be sure not to destroy the HC-05, you should also use a voltage divider.

some connect VCC pin to the 3,3V instead of the 5V

This is only done, when the used board does not have a 5V to 3.3V voltage regulator. Depends on the exact board, that you own.

some even skip the AT-Command setup entirely!

When they don't need to configure the HC-05 in a special way, why would they go into command mode. That might be different for you.

  • Voting yours up. Seems to say everything mine says and more. I'm guessing based on the length and detail you started before I did as well.
    – timemage
    Commented Mar 15, 2021 at 13:39
  • Ok, I changed the code to Serial.begin(38400), the "Enter AT commands:" message does appear as normal now, and the command responses are...less gibberish now, seem to be a mixture of '?'s and whatever command I typed, but it's definitely still not receiving the commands, I tried changing the device's name and it still appears as "HC-05" (The default name)on my phone, after that I switched the RX and TX pins to 2 and 3 respectively, and now it's not even responding to my commands.
    – The Riser
    Commented Mar 15, 2021 at 14:00
  • Have you switched the physical connections of the HC-05 to the new pins and also changed the pin numbers in the code? and connected HC-05 TX to the RX of your SoftwareSerial interface?
    – chrisl
    Commented Mar 15, 2021 at 14:19
  • Btw: Where exactly are you failing to establish the connection? When it appears on your phone, I assume, that the pairing would work. The real connection is then established by a fitting app. The Android bluetooth setting page (where you can pair devices) does not do the real connection.
    – chrisl
    Commented Mar 15, 2021 at 14:20
  • @chrisl Yes, I have switched the physical pins to the new positions, and tried both combinations (RX to RX & TX to TX, and then RX to TX and TX to RX), still no response, as for how I'm trying to connect, I thought I was supposed to connect through setting page first, that's where I was failing, but I did try using a fitting app I already had installed (Bluetooth Terminal), but no luck, can't connect through that one either.
    – The Riser
    Commented Mar 15, 2021 at 14:30

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.