Go Down

Topic: HC-05 Bluetooth module ignores zeros in bind address (Read 1 time) previous topic - next topic

kmarts

Hi all,

I'm trying to get an HC-05 module to pair with a bluetooth OBD2 reader unsucessfully.

After troubleshooting last night i think I've realized what the problem is, but I can't find anything online where someone has had the same problem...

The issue appears to be that when I have the HC-05 in AT mode and give it the bind command it only takes the non-zero characters of the OBD2 readers address.

For example:
Code: [Select]
AT+BIND=001D,A5,000002
OK
AT+BIND?
+BIND:1d:a5:2


Initially I was using an arduino mega, Serial and Serial1 to do this with the following code:
Code: [Select]
void setup() {
  Serial.begin(38400);
  Serial1.begin(38400);

}

void loop() {
  if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.write(byte(inByte));
  }

if (Serial.available()) {
  int inByte = Serial.read();
  Serial1.write(byte(inByte));
}

}


I thought it was maybe the arduino ignoring the zero as a null character (hence byte(inByte) in Serial.write)

I then hooked the HC-05 up to a serial port on my computer and used Tera-Term but am having the exact same problem.

Can anyone offer any insight as to what's going on here?

Thanks

kmarts

For anyone who cares it appears discarding the zeros is normal and wasn't my problem.

My real problem was that the address wasn't correct, but i was using the MAC address my phone had listed for this particular device so I'm not sure what happened there.


What follows may be useful to someone else so I'll just put it out there.

Originally i tried using the AT+INQ command on the HC-05 to discover the deivce i wanted to pair to but never got any output. what I found was that despite setting the 'link' pin high on the HC-05 it wasn't in Full AT mode.

I didn't understand that there's different levels of AT mode for the HC-05. If you power it up while holding the button, that still isn't full blown AT mode. You won't get responses from certain AT commands (i.e. AT+INQ, AT+STATE?, etc...)

If your HC-05 behaves like mine and the link pin isn't working as it's supposed to, you have to physically hold the button on when you issue those certain AT commands.

After i figured that out, it's working as it should.

lDragonAzul

Hello friend, I have the same problem and the same with obd2
I would like to know how it was that you were able to obtain the true MAC address of elm327 and not the one that the phone provided you?

kmarts

The Answer is in the second last sentence of my last post.

lDragonAzul

The Answer is in the second last sentence of my last post.
You would be so kind to share your code please, because I still can not solve the error, what I want to do is connect ELM327 with HC-05 and get the DTCs (Error codes).

Thank you.

kmarts

You would be so kind to share your code please, because I still can not solve the error, what I want to do is connect ELM327 with HC-05 and get the DTCs (Error codes).

Thank you.
My problem was pairing the two devices and didn't require any arduino code, it was initial setup of the HC-05. My HC-05 wasn't in full AT mode unless I held the button while issuing the command to pair it with the ELM.

If you get them paired there's plenty of arduino OBD2 examples out there. I used the OBD2UART library once I got them connected:

https://github.com/stanleyhuangyc/ArduinoOBD/tree/master/libraries

Sorry, I'm not trying to be obscure here but I was using it for live data, not DTC's.


Go Up