Hi there, here is the code I use to get the HC05 in AT mode. it works on my arduino UNO, I hope it'll help you.
//Caution: Tx of the module is to connec twithpin 10 of the arduino and RX with pin 11
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // TX | RX
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.begin(115200);
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())
//Take the string returned by the module and print it
Serial.println(BTSerial.readString());
// Keep reading from Arduino Serial Monitor and send to HC-05
if (Serial.available())
BTSerial.println(Serial.readString());
}