Hi, i am using arduino uno to read ELM327 using serial communication, i am able to send the AT commands an get the required response but i’m also getting some strange characters at the beginning. I can remove these characters from the beginning but i want to know why these strange characters is being printed the response.
Code:
#include <SoftwareSerial.h>
SoftwareSerial ELM(13, 12); // RX, TX
int CmdCount = 1;
byte inData;
char inChar;
String DisplayString = "";
long DisplayValue;
String SentMessage = "";
int ByteCount = 0;
long A;
int B;
int WorkingVal;
String WorkingString = "";
String BuildINString = "";
String message = "";
void setup() {
Serial.begin(9600);
ELM.begin(38400);
}
void loop() {
if (Serial.available()) {
ELM.println("AT DP");
ReadMessage();
}
}
void ReadMessage() {
while (ELM.available() > 0)
{
message = ELM.readString();
}
message.replace(SentMessage, "");
message.replace(">", "");
message.replace("OK", "");
message.replace("STOPPED", "");
message.replace("SEARCHING", "");
message.replace("NO DATA", "");
message.replace("?", "");
message.replace(",", "");
String res = message.substring(0, 5);
//message.remove(0,5);
Serial.println(message);
}
Serial Monitor Output:
Q��eAUTO ISO 15765-4 (CAN 11/500)
Q���kAUTO ISO 15765-4 (CAN 11/500)
Q�#�5AUTO ISO 15765-4 (CAN 11/500)
@A��AUTO ISO 15765-4 (CAN 11/500)
Q��5AUTO ISO 15765-4 (CAN 11/500)
Q�!�kAUTO ISO 15765-4 (CAN 11/500)
-Thanks