Open Ciullox opened 10 months ago
The loop above is not using the library correctly, it should be like this:
void loop()
{
myELM327.queryPID("2218E4");
if (myELM327.nb_rx_state == ELM_SUCCESS)
{
read_rawdata();
//BATTv = ((convertToInt(dataFrame2, 4, 5)<<8) + convertToInt(dataFrame2, 6, 7))/10;
int A=convertToInt(dataFrame2, 4, 5);
int B=convertToInt(dataFrame2, 6, 7);
BATTv =((A*256)+B)*(1000/65535);
Serial.print("intasamento: ");
Serial.println(BATTv);
Serial.print(" % ");
delay(1000);
clearData();
}
else if (myELM327.nb_rx_state != ELM_GETTING_MSG)
{
myELM327.printError();
}
}
And this code should go into setup():
myELM327.sendCommand("AT SH DA10F1"); // Set Header BMS
thanks for the advice, I updated as you said and after sending the command in the setup I put a Serial.print but nothing is printed in the serial monitor, in my opinion it stops in that function
OK, I didn't look closely at that code before, but I don't see anywhere that myELM327.begin() is called. It should probably be in the setup() method. Can you link to the original code?
what I wrote is exactly the same as the original, I just changed the pids and the header pids giulia.zip
Hmm, I can't see how that could have ever worked.... Try adding this code in setup() before the sendCommand() instruction:
if (!myELM327.begin(mySerial, true))
{
Serial.println(F("Couldn't connect to OBD scanner - Phase 2"));
while (1)
;
}
Also, have you verified that the pin numbers specified for mySerial() are correct for your hardware?
I added this line of code but the program stops at that if you made me add and I don't understand why. the OBD I use has a reception LED that lights up when it receives a command and lights up when I ask for the pin, however in the doubt it gives me the sending message and then clears the buffer without even entering the if that confirms reception
I saw that someone solved the querypids infinite click bug with processpid so is this correct?
myELM327.processPID("ATSH DA10F1","2218E4",8);
why does it give this error Compilation error: no matching function for call to 'ELM327::processPID(const char [12], const char [7], int)'
You can't submit commands using processPID()
, only real PID queries. For this, you need the service, pid, and other pieces of context data:
You can use these functions to send commands:
And this code should go into setup(): myELM327.sendCommand("AT SH DA10F1"); // Set Header BMS
Hello. How to include headers in a loop (myELM327.sendCommand)
I found this program on the net and I'm trying to modify it to receive from Arduino the clogging of the dpf of my car which is requested via a header "ATSH DA10F1" AND FROM A PIDS 2218E4 ONLY THAT THE program arrives " myELM327.sendCommand("AT SH DA10F1");" and it stops, it no longer goes forward and it doesn't print anything via serial