0

i have problem with accessing at-command in module Bluetooh HC-05.

i just follow all tutorial to activate at-command like this, http://www.martyncurrey.com/arduino-with-hc-05-bluetooth-module-in-slave-mode/

or in this video https://www.youtube.com/watch?v=Vr4cdpsoVEo&t=31s

and just read some explanation and implemented to my problem HC-05 Bluetooth AT+INQ command not working

but i just still get same error. i cant use AT+INQ command, always get ERROR(1F). AT+INIT get ERROR(17).

i have module HC-05 with version 3.0-20170601

This is my code i use it.

#include <SoftwareSerial.h>
SoftwareSerial BTserial(8, 9); // RX | TX`

const long baudRate = 38400; 
char c=' ';
boolean NL = true;

void setup() 

{
   Serial.begin(9600);
   Serial.print("Sketch:   ");   Serial.println(__FILE__);
   Serial.print("Uploaded: ");   Serial.println(__DATE__);
   Serial.println(" ");

BTserial.begin(baudRate);  
Serial.print("BTserial started at "); Serial.println(baudRate);
Serial.println(" ");
}

void loop()

{

// Read from the Bluetooth module and send to the Arduino Serial Monitor
if (BTserial.available())
   {
       c = BTserial.read();
       Serial.write(c);
   }


   // Read from the Serial Monitor and send to the Bluetooth module
if (Serial.available())
   {
       c = Serial.read();
       BTserial.write(c);   

    // Echo the user input to the main window. The ">" character indicates 
    the user entered text.
    if (NL) { Serial.print(">");  NL = false; }
    Serial.write(c);
    if (c==10) { NL = true; }
   }

}

migrated from electronics.stackexchange.com Mar 20 '18 at 17:17

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

  • check this out ... stackoverflow.com/questions/23221336/… – jsotola Mar 20 '18 at 21:43
  • Ty for comment sir. I just read and implemented your guide But my problem still not solve. I wondering my firmware. Because I have Bluetooth version is 3.0. and other tutorial have version is 2.0 – Muhammad Sabirin Hadis Mar 20 '18 at 22:30
  • Do other AT commands work? what arduino are you using? – mystery Mar 22 '18 at 17:01
  • Yap i just use all AT-COMMAND. Just AT+INQ get error. I use Arduino uno. – Muhammad Sabirin Hadis Mar 22 '18 at 23:47
  • thank you for this wonderful post Presidenten ,but i am having issue, "AT+STATE" shows inquiring ..if i power up my bluetooth device (not hc05) it doesnt show any address...what am i missing..please help... – Keerthiprakash Sachin Oct 20 '18 at 6:54
1

I have two modules:

(A) HC-05 with firmware version 3.0-20170601

(B) HC-05 with firmware version 2.0-20100601 (ok)

I have the same problem: when the AT command "AT+INQ" is sent on (A) module, the response is always "ERROR:(1F)". This error code seems not be reported in any document or specification available on internet. This BT module have firmware version (AT+VERSION) 3.0-20170601. Also I have noticed that command AT+INIT on (A) module returns always ERROR:(17), this error normally can be ignored if the command has been sent already (Initiate SPP lib), but the first time should be return "OK" as on (B) module.

The (B) module with firmware version 2.0-20100601 works ok with the following commands (set PIN34 high at power-up, or press button on module and keep pressed during commands):

AT+RMAAD -> delete all paired devices list

AT+ROLE=1 -> Set master mode

AT+RESET -> reset module to enter into master mode

AT+CMODE=1 -> Permit connection with any device

AT+INQM=0,5,9 -> Set Search parameters(Query mode standard, 5 devices, 9secs)

AT+INIT --> Init SPP profile mode (first time response: "OK")

AT+INQ --> Start search devices (return device list after some seconds)

The differences between two modules are:

On AT+INIT the (A) module return always ERROR:(17), the (B) module return "OK" first time and ERROR:(17) if the command is sent twice. On (A) module the command AT+INQ return always ERROR:(1F), the (B) module return the list of the BT devices.

Also the (A) and (B) modules are physically different. The (B) module have some components (resistors/capacitors) between the two big black chips, the (A) module no.

Also I noticed that on (A) module the AT+CLASS? return "1f00" value (default?). The correct value should be "0" as (B) module ? Anyway setting AT+CLASS=0 on (A) module the result is always the same.

In slave mode (AT+ROLE=0) both modules works fine.

With (A) module I'm unable to use it as "MASTER" and connect it to any other slave BT modules because did not perform devices search. (INQ fails).

I think that in 3.0 firmware is needed to set other(s) parameter(s) in order to start SPP profile correctly (INIT) and then avoid ERROR:(1F) in INQ command (search).

Someone already solved the problem ?

  • So the conclusion about my problem is the firmware on HC-05. Firmware with 3.0 make AT+INQ will be not work. Ty very much for your answer. This is problem make me Stack on a month. Your answer very useful to me. – Muhammad Sabirin Hadis Mar 25 '18 at 9:34
  • So your HC-05 with firmware 2.0 have push button or not? – Muhammad Sabirin Hadis Mar 25 '18 at 12:03
  • Yes, it have the push button. The HC-05 is soldered on ZS-040 board that have the push button connected to PIN34. If you press the button at power-up, the module will enter in AT-COMMAND mode (38400bps, CR+LF) and it is possible to setup and view configuration of the module as MASTER o SLAVE by using AT commands. Some similar modules (HC-06) doesn't have the button because they are SLAVE only. – Atomix Mar 25 '18 at 14:33
  • Okay. Ty very much brother. – Muhammad Sabirin Hadis Mar 25 '18 at 14:35
  • Sir, can I buy your HC 05 with Firmware 2.0? – Muhammad Sabirin Hadis Apr 3 '18 at 9:21
1

I have a HC-05 with 3.0-20170601 that I managed to bind to a slave last night. It turns out that the v3 has two AT-modes.

The first is when you hold the button while you connect power. The led will blink slowly and you can connect at 38400 baud. But this is like a configuration mode, where AT+INQ is not available.

In this mode I did these commands:

AT
AT+UART
AT+RMAAD
AT+ROLE=1

(Press and hold the button)

AT+RESET

(Release the button after device restarts and led is slowly blinking)

AT+CMODE=1
AT+INQM=0,5,5
AT+PSWD="9999"

AT should give OK as answer to know connection is working

AT+UART will show configured baudrate. Default is 9600.

AT+RMAAD clears all saved connections

AT+ROLE=1 sets it as master

AT+RESET restarts the device to change to master

AT+CMODE=1 accepts all kinds of devices

AT+INQM=0,5,5 inquires in standard mode, with 5 max connections or 5 secs

AT+PSWD="9999" sets the pin code 9999, change to the pin you need

After this it is time to update the arudino code. In your case you should update line 4 from

const long baudRate = 38400;

to

const long baudRate = 9600;

...or what ever value you might have set the baud rate to. Then reflash your arduino.

Now enter the very irritating second AT command mode.

Power up without holding the button. You will get the fast blink speed. When its powered up, press and hold the button. The led will continue blinking fast, but while the button is pressed you can now connect to the device on the configured baud rate. So open the serial monitor and type AT to verify. Remember that the mode is only active while the button is pressed. So keep it pressed. I had a small clamp I put on there.

Then I entered these commands:

AT+STATE

AT+STATE will show current state, should be inquiring

Then power up the slave device and the adress should start popping up. It will be something like xyz:xy:xyzw,931F00,7FFF

The first part is the address you want (xyz:xy:xyzw)

Change : to , and get xyz,xy,xyzw

Check that you connecting to the correct device

AT+RNAME?xyz,xy,xyzw

Then bind

AT+PAIR=xyz,xy,xyzw,5
AT+BIND=xyz,xy,xyzw
AT+LINK=xyz,xy,xyzw

The AT+LINK command gave me FAIL as output. But it did not matter. I restarted and did not press any button before or after. Just normal start.

After 5-10s serial data showed up in my serial monitor.

Modules are bound. And will automatically connect at power up. If not you might have the wrong pincode. Make sure to change 9999 above to 0000 or 1234 or what ever it may be. When I hade the wrong pin I still got OK from the AT+PAIR and AT+BIND commands... It didnt work for me until I entered the correct pin.

Sorry for long post, but I wanted to be thorough since info about HC-05 v3 is very scarce on the internet right now.

A reference to all commands can be found here: http://www.electronicaestudio.com/docs/istd016A.pdf (Link valid 2018-08-13)

0

Extending the Presidenten's answer, the easiest way to program HC-05 is to sonnect a wire to EN on the chip and set the UART console to 9600.

Then pull the EN high, send commands, wait for OK (after each one), and drive EN down.

You now have a chip in data state.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.