HC-05 with At mega 1280

Hey everyone

I recently bought this bluetooth module off ebay and I have been trying to make it work with my arduino mega but this stupid thing just wont communicate :~ with my arduino.


This is the code I been trying to use with my arduino
Pin 19 is RX and 18 is TX on the mega in communications area
Pin 2 is for the AT mode the KEY pin, and is connected to the PWM slot 2 on the mega.

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(19, 18); // RX | TX

void setup()
  pinMode(2, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
  digitalWrite(2, 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())

Things I made sure are suppose to be standard procedure:

  1. RX on the module goes in the TX on the arduino
    TX on the module goes in the RX on the arduino
  2. The module is connected to 5V on the arduino since it wont even turn on the 3.3V
  3. To put it in the AT mode i remove the 5V cable > turn on my arduino let it boot > upload sketch > connect 5V cable to the module without turning off arduino.

couple of things I have had problems with:

  1. when I connect my PC BT to the BT module, it does get connected with the PIN "1234" showing me HC-05 but then after like 5 minutes it will disconnect itself.
  2. I tried to use putty on the BT COM port but it was unable to communicate with it

now what else am i missing, cause this thing is just slowing down the project I been working on. I been to so many forums searching for answers on this.... is my module faulty?

I just tried again using this video and its still not working, somehow i get the feeling the module is broken =( =( =( =(

it does get connected with the PIN "1234" showing me HC-05..........

. is my module faulty?

Probably not. But your code might be.

I submit the first thing you might do is ask yourself what on earth could possess you to use software serial on a Mega, when there are four hardware serial ports available to you. If you can come to terms with using hardware serial on the standard D0,D1 pins, even if only for the purposes of the exercise, you might find some help here:


wherein is some very simple bare bones code that will enable you to check that your module, and code, is kosher. The notes were written for Android but were developed with a laptop.