5

I currently try to connect an Arduino Micro/Leonardo/32u4 to an ELM327 Bluetooth dongle using a HC-05 Bluetooth shield from iTeadStudio. I also have similar problems trying to connect to a bluetooth dongle (with added serial connection) on my PC.

The basic AT-command communication works, but I haven't found out yet why AT+PAIR or AT+LINK are failing and what should be done to avoid this (I've done dozens of Serial Monitor command iterations). Until now I haven't found a command sequence that reliably connects. What I've tried so far (from different documentation and example codes):

Check general AT command set:

AT
> OK

Reset to default values:

AT+ORGL
> OK

Set master mode and check it:

AT+ROLE=1
> OK
AT+ROLE?
> +ROLE:1
> OK

Connect only to the specified bluetooth address:

AT+CMODE=0
> OK

Reset and initialize:

AT+RESET
> OK
AT+INIT
> OK

Configure inquiring mode:

AT+INQM=1,9,48
> OK

Inquire:

AT+INQ
> +INQ:12:34:567890:1F1F,7FFF
> OK
AT+STATE?
> +STATE:INQUIRING

Try to stop inquiring:

AT+INQC
> OK
AT+STATE?
> +STATE:INQUIRING
> OK

Reset and initialize again (otherwise we can't leave the inquiring state):

AT+RESET
> OK
AT+INIT
> OK
AT+STATE?
> +STATE:INITIALIZED
> OK

Try to pair with the found device (my PC asks for the 1234-password and creates a serial port):

AT+PAIR=12,34,567890,20
> OK
AT+STATE?
> +STATE:PAIRED

Try to connect

AT+BIND=12,34,567890
> OK
AT+LINK=12,34,567890
> FAIL
...

Does someone have some hints for finding the right sequence?

3
  • I am using a "BIND" between the Pair and Link: AT+PAIR=98D3,31,FC2D54,5 AT+BIND=98D3,31,FC2D54 AT+LINK=98D3,31,FC2D54 Commented Mar 23, 2016 at 1:19
  • I can't even pair... I'm trying to connect a ds4 with a hc-05. It seems the password is used to pair, but the ds4 doesn't have any. Any idea? Commented Aug 8, 2016 at 22:49
  • I had same problem and searched for several helps to make it, however a couple of solution I found in the net could not directly solve the problem. Now I finally found the real solution ,thank to GOd!
    – Jun Murata
    Commented Nov 26, 2018 at 15:40

2 Answers 2

2

I am using a "BIND" between the PAIR and LINK:

AT+PAIR=98D3,31,FC2D54,5
AT+BIND=98D3,31,FC2D54
AT+LINK=98D3,31,FC2D54

That seems to work for me.

See the docs here:

ftp://imall.iteadstudio.com/Modules/IM120723009/DS_IM120723009.pdf

1

It looks like I now have a slight understanding of what happens and how to get the HC-05 working.

Be sure to have the CMD-DAT-switch set to CMD before turning on the HC-05.

Command mode (configuration)

Check general AT command set:

AT
> OK

Reset to default values (sets, among others, ROLE=0 and CMODE=1):

AT+ORGL
> OK

Set master mode and check it:

AT+ROLE=1
> OK
AT+ROLE?
> +ROLE:1
> OK

Reset and initialize (reset aborts, e.g. the inquiring state - quickly flashing LED; without initializing you would get ERROR(16)):

AT+RESET
> OK
AT+INIT
> OK

Now the LED should slowly flash. Optionally: set password of the target device:

AT+PSWD=1234
> OK

Show count of all authenticated devices in pair list:

AT+ADCN?
> +ADCN:7
> OK

If the value is larger than 0, delete all authenticated devices in pair list:

AT+RMAAD
> OK

Now pair with the desired device (the last 20 mean 20s):

AT+PAIR=12,34,567890,20
> OK

The LED starts flashing one time with a longer pause. Set the desired device:

AT+BIND=12,34,567890
> OK

Now link (e.g. when connecting to the ELM327; the PC will create another new port after having requested the password from the user):

AT+LINK=12,34,567890
> OK

The LED starts flashing two times with a longer pause. After linking, it might be that either the HC-05 switches to data-mode or continues in command-mode (haven't found out when it does one or the other).

Command mode (auto connect)

Now switch off the HC-05 and keep the CMD-DAT-switch to CMD. Switch it on again. It should automatically connect to the previously connected device. To switch to the data mode, first disconnect...

AT+DISC
> +DISC:SUCCESS
> OK

... and reconnect.

AT+LINK=12,34,567890
> OK

Now the connection seems to have switched to data mode.

Data Mode

Now switch off the HC-05 and move the CMD-DAT-switch to DAT. Turn on the HC-05. It automatically will try to connect to the previously connected device - the LED should flash two times with longer pause - and you don't have to mess with HC-05-AT commands any more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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