I'm trying to connect a OBD2 ELM327 to a HC-05. I'm doing it manually at the moment before trying it on code. i'm using a ESP32, and I know that ESP32 has native bluetooth on it, but for other reasons I need to do it this way.
AT Commands are all responding fine OK.
21:24:36.117 -> Command: AT+CLASS=0
21:24:36.117 ->
21:24:36.157 -> OK
21:24:39.960 -> Command: AT+INQ
21:24:39.960 ->
21:24:40.075 -> +INQ:AAC5:FF:187F58,10091C,FFC8
21:24:40.111 -> OK
21:25:54.819 -> Command: AT+PAIR=AAC5,FF,187F58,120
21:25:54.819 ->
21:25:54.819 -> ERROR:(5)
If I use AT+INQ I can see my device without issues, but when I try to pair it I receive that error instantly, and I don't even know what it means, I could find it on the documentation of the HC-05.
sendATCommand("AT");
sendATCommand("AT+CMODE=0"); específicos
sendATCommand("AT+ROLE=1");
sendATCommand("AT+RESET");
sendATCommand("AT+CLASS=0");
sendATCommand("AT+IAC?");
sendATCommand("AT+INQM=0,5,9");
sendATCommand("AT+INQ");
sendATCommand("AT+INIT");
sendATCommand("AT+PAIR=AAC5,FF,187F58,120");
sendATCommand("AT+BIND=AAC5,FF,187F58");
sendATCommand("AT+LINK=AAC5,FF,187F58");
sendATCommand("AT+RESET");
As I said, all those commands respond with ok, the only one that is not is pair. The ELM327 works fine, I have been able to connect to it from my phone and computer. I've also tried:
21:18:17.718 -> Comando enviado: AT+PSWD?
21:18:17.718 -> +PSWD:1234
but same result, this is the version of my module:
21:45:49.775 -> Comando enviado: AT+VERSION?
21:45:49.775 -> +VERSION:HC-05 V3.0
and my code to send the messages but I don't think that would be an issue:
#include <HardwareSerial.h>
const uint8_t HC05_RX = 16;
const uint8_t HC05_TX = 17;
HardwareSerial SerialHC05(2);
void setup() {
Serial.begin(115200);
SerialHC05.begin(38400, SERIAL_8N1, HC05_RX, HC05_TX);
Serial.println("HC-05 en modo AT listo. Puedes enviar comandos AT ahora.");
}
void loop() {
if (Serial.available()) {
String command = Serial.readString();
SerialHC05.println(command);
Serial.print("Comando enviado: ");
Serial.println(command);
}
if (SerialHC05.available()) {
while (SerialHC05.available()) {
char c = SerialHC05.read();
Serial.write(c);
}
}
}