This is what happens, I have an HC-05 connected to a ELM327 V2.1 but whenever I send a command to the ELM327 I get this
Comando enviado al ELM327: ATI
15:58:30.447 -> SEARCHING...UNABLE TO CONNECT
This the code I'm using to send the commands to the ELM327 through the HC-05:
#include <HardwareSerial.h>
const uint8_t HC05_RX = 16;
const uint8_t HC05_TX = 17;
// Usamos el puerto Serial2 del ESP32
HardwareSerial SerialHC05(2);
void setup() {
Serial.begin(115200);
SerialHC05.begin(9600, SERIAL_8N1, HC05_RX, HC05_TX);
Serial.println("Connecting to ELM327 OBD2...");
}
void loop() {
if (SerialHC05.available()) {
while (SerialHC05.available()) {
char c = SerialHC05.read();
Serial.write(c);
}
}
if (Serial.available()) {
String command = Serial.readStringUntil('\n');
SerialHC05.println(command);
Serial.print("Command sent to ELM327: ");
Serial.println(command);
}
}
I have been able to send commands to the ELM327 through my phone bluetooth terminal app without any issue, I'm sending them at a baud rate of 9600 which is the only baud rate that gives me response back. I've also tried to connect the OBD2 to another car and same isssue.
Also I've been able to send AT Commands to the HC-05 with no issue and I know for sure that OBD2 and HC-05 are connected/
Why I'm I getting this? SEARCHING...UNABLE TO CONNECT
16 and 17 are marked as RX2 and TX2 on my board and they work
RX is connected to TX and TX to RX, I don't think thats the problem cuz I'm able to send AT commands to the HC-05 with another sketch and they all work.
I've also tried to make a voltage divider to see if it make any difference, but didn't. And if you're asking why I don't use the the native bluetooth of the esp32 for other reasons of this project I can't, but I mean it should work with HC-05.
I just connected the ELM327 on my car port, as I said ik its working cuz I've been able to send commands through an android bluetooth terminal app, but not from here.
I know because I binded it: AT+BIND=AAC5,FF,187F58
And whenever I get close to the ELM327 the blinking of the HC-05 changes, and I'm able to send commands to the ELM327, but it only answers me this: SEARCHING... UNABLE TO CONNECT and when the ELM327 is not there I don't receive any kind of response. Btw if I'm missing something here, tell me and I'll try.
It seems the message "SEARCHING... UNABLE TO CONNECT " indicate the connection issue between the ELM327 and OBD-II system rather than problems with ESP-32 and HC-05 module.
I just found this info on github:
UNABLE TO CONNECT
If you see this message, it means that the ELM327 has tried all of the available protocols, and could not detect a compatible one. This could be because your vehicle uses an unsupported protocol, or could be as simple as forgetting to turn the ignition key on. If you are sure that your vehicle uses an OBDII protocol, then check all of your connections, and the ignition, then try the command again.
Sorry, I don't have enough experience with ELM327.
That's weird, I already made it work on another HC-05, but it was a weird and very faulty chinese 4.0 version that didn't work at all, but gave some responses with the obd2. I'll try to force the use of another protocol on the ELM327, to see If I can make it work, and if not, I'll maybe try to change the HC-05. I already tried the OBD2 on a different car and didn't make a difference