HC05 not working properly & not responding to AT commands

Thread Starter

quique123

Joined May 15, 2015
389
I originally tried to send data from an android phone to the bluetooth module-connected arduino uno.

Wiring:

5V UNO ------- Vcc HC-05
G UNO -------- GND HC-05
11 UNO ------- Tx on HC-05
10 UNO ------- Rx on HC-05

and I uploaded this sketch:

Code:
#include <Servo.h>
#include <SoftwareSerial.h>
SoftwareSerial bluetooth(11,10); //Rx, Tx method signature
Servo myServo;

void setup() {
 delay(1500); // wait for bluetooth module to start
 bluetooth.begin(9600); 
 Serial.begin(9600);
 myServo.attach(7);
 Serial.println("Ready");
}

void loop() {
 // put your main code here, to run repeatedly:
 if(bluetooth.available()>0) {
   Serial.println("Waiting for data");
   int c = bluetooth.read();
   bluetooth.println(c);
   if(c=='1'){
     bluetooth.println("Open Wide");
     Serial.println("1");
     myServo.write(1000);
   } else if(c=='2'){
     bluetooth.println("Close");
     Serial.println("2");
     myServo.write(2000);
   }
 }  
}
Yes I did have a servo connected to pin7 but that never ran upon sending 1 to the arduino via Serial Bluetooth Terminal app on Android. Im able to connect to the hc05 but when I send the commands nothing is received either in the serial monitor or on the android app terminal or on the servo pin 7.

So I decided to check the at commands and I uploaded this sketch to the arduino:

Code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(11,10); // RX, TX
void setup() {
 Serial.begin(9600);
 pinMode(9,OUTPUT); 
 digitalWrite(9,HIGH);
 Serial.println("Enter AT commands:");
 mySerial.begin(38400);
}

void loop(){
 if (mySerial.available())
 Serial.write(mySerial.read());
 if (Serial.available())
 mySerial.write(Serial.read());
}
I tried with a wire from pin 9 to the enable pin of the hc05, nothing. I also just noticed that I can connect to it from a serial bt android app and when I send commands from the phone to the hc05 I get nothing in the SM but when I send from the SM to the app at least I get junk.


I tried without the wire to pin 9 but holding the button on the hc05 while powering up, nothing.

By nothing I mean, i get the "Enter AT commands" in the serial monitor but when I enter AT or AT+NAME, I get nothing back.

Here is a picture of the module:

It has a BCM417 chip i see:
IMG-2278.JPG

IMG-2279.JPG
 

Wolframore

Joined Jan 21, 2019
1,665
Usually HC05 are pretty tolerant with 5v logic but you may need a resistor divider on the Receive pin to lower the level to 3.3v. Use 1k and 2k resistors. Is it possible you changed the baud rate on that module previously?

The “enter AT command” is not coming from your BT module, only from your code. Check all your connections. It’s been a while since I’ve messed with these. They are not bulletproof but pretty tolerant. You need to get into AT mode. When you activate it the LED indicator color change.. I recall red.... You might have to cut the plastic cover to activate button correctly.
 

Thread Starter

quique123

Joined May 15, 2015
389
i cant remember how but i got it working. I think i had the comm lines confused at one point and then I ended up making it work without the voltage divider.
 

djsfantasi

Joined Apr 11, 2010
6,196
The HC05 Enable pin (pin 1, just before Vcc) must be held high to process AT commands. In normal use (transferring data) it needs to be low.

If it’s floating or low, AT commands won’t work.
 
Top