Controlling HC-05 from a sketch Hi I am making a sketch and circuit with a HC-05 BT receiver to upload sketches via Bluetooth to my Uno.  This requires giving AT commands from the sketch.  I would like to see the response from the HC-05 but so far I haven't got it to work.  I want to view the response via the standard serial connection and serial monitor.  The commands from the sketch are not being recognized by the HC-05 and I would like to see the HC-05 response to troubleshoot it.

If you have a minute would you mind giving me a tip?  I would greatly appreciate it.  See the ArdProgramModeOn() and Off functions at the end.

Thanks


int ATModePin = 2; &nbsp;// pin for HC-05 AT comand mode
int HC05powerPin = 3; &nbsp;// pin for powering HC-05 when high
char btserialrx; &nbsp;// data through from bt connection
char myChar; // data through serial port connection
#define rxPin 8 // HC-05 bt serial pin
#define txPin 9 // HC-05 bt serial pin

#include &lt;SoftwareSerial.h&gt;
SoftwareSerial btSerial(rxPin, txPin); // RX, TX

void setup() {
 &nbsp;pinMode(ATModePin, OUTPUT);
 &nbsp;pinMode(HC05powerPin, OUTPUT);
 &nbsp;pinMode(5, OUTPUT);
 &nbsp;Serial.begin(9600); &nbsp;&nbsp;
 &nbsp;btSerial.begin(115200); 
 &nbsp;
 &nbsp;digitalWrite(HC05powerPin, HIGH);
 &nbsp;delay(2000);
 &nbsp;}

void loop() {

 &nbsp;while (btSerial.available()) {
 &nbsp;&nbsp;&nbsp;btserialrx = btSerial.read();
 &nbsp;}

 &nbsp;if(btserialrx == '1'){ &nbsp;// change to upload / reset mode
 &nbsp;&nbsp;&nbsp;Serial.println("switching to upload mode");
 &nbsp;&nbsp;&nbsp;ATModeOn();
 &nbsp;&nbsp;&nbsp;ArdProgramModeOn();
 &nbsp;&nbsp;&nbsp;ATModeOff();
 &nbsp;&nbsp;&nbsp;btserialrx = '0';
 &nbsp;}
 &nbsp;else if (btserialrx == '2'){ &nbsp;// change to normal mode
 &nbsp;&nbsp;&nbsp;Serial.println("switching to normal mode");
 &nbsp;&nbsp;&nbsp;ATModeOn();
 &nbsp;&nbsp;&nbsp;ArdProgramModeOn();
 &nbsp;&nbsp;&nbsp;ATModeOff();
 &nbsp;&nbsp;&nbsp;btserialrx = '0';
 &nbsp;}
}


void ATModeOn(){ &nbsp;// reset HC-05 and change HC-05 to AT Command Mode
 &nbsp;digitalWrite(5, HIGH);
 &nbsp;digitalWrite(ATModePin, HIGH); // AT command mode on upon reset
 &nbsp;delay(2000);
 &nbsp;digitalWrite(HC05powerPin, LOW); // hc-05 off
 &nbsp;delay(2000);
 &nbsp;digitalWrite(HC05powerPin, HIGH); // hc-05 on
 &nbsp;delay(2000);
} 

void ATModeOff(){ &nbsp;// reset HC-05 and return HC-05 to std. operation 
 &nbsp;digitalWrite(5, LOW);
 &nbsp;digitalWrite(ATModePin, LOW); // AT command mode off upon reset
 &nbsp;delay(2000);
 &nbsp;digitalWrite(HC05powerPin, LOW); // hc-05 off
 &nbsp;delay(2000);
 &nbsp;digitalWrite(HC05powerPin, HIGH); // hc-05 on
 &nbsp;delay(2000);
}

void ArdProgramModeOn(){
 &nbsp;btSerial.println("AT");
 &nbsp;delay(1000);
 &nbsp;btSerial.println("AT+POLAR=1,0"); &nbsp;// Arduino reset mode upon HC-05 connection for programming
 &nbsp;delay(1000);
 &nbsp;btSerial.println("AT+POLAR?"); &nbsp;// Arduino reset mode upon HC-05 connection for programming
 &nbsp;delay(2000);
 &nbsp;while (btSerial.available()) { &nbsp;// Show responses from HC-05
 &nbsp;&nbsp;&nbsp;myChar = btSerial.read();
 &nbsp;&nbsp;&nbsp;Serial.print(myChar);
 &nbsp;}
 &nbsp;delay(4000);
}

void ArdProgramModeOff(){
 &nbsp;btSerial.println("AT");
 &nbsp;delay(1000);
 &nbsp;btSerial.println("AT+POLAR=1,1"); &nbsp;// Arduino normal mode no reset upon HC-05 conection
 &nbsp;delay(1000);
 &nbsp;btSerial.println("AT+POLAR?"); &nbsp;// Arduino reset mode upon HC-05 connection for programming
 &nbsp;delay(2000);
 &nbsp;while (btSerial.available()) { &nbsp;// Show responses from HC-05
 &nbsp;&nbsp;&nbsp;myChar = btSerial.read();
 &nbsp;&nbsp;&nbsp;Serial.print(myChar);
 &nbsp;}
 &nbsp;delay(4000);
}
Unless you've manually set the btSerial speed, you need to be at the default for AT commands which is 38400 -> btSerial.begin(38400);

If you want to read regular Serial communication, you'll need to monitor 9600 -> btSerial.begin(9600);

If you are unable to to send commands, I feel as if you wouldn't have changed the default speeds.

I used this link as a reference with my project: Modify The HC-05 Bluetooth Module Defaults Using AT Commands

Lastly, you didn't mention whether or not you soldered a jumper wire to PIN 32 for your ArdProgramOff/On. Another reference for you as well: DIY Arduino Bluetooth Programming Shield

Hope my answer helps! Good luck!