-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom PIDs #218
Comments
Please post your formatted code and debug printouts. |
#include "BluetoothSerial.h"
#include "ELMduino.h"
BluetoothSerial SerialBT;
ELM327 myELM327;
double var = 1.0;
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA);
SerialBT.begin("ArduHUD", true);
if (!SerialBT.connect("OBDII"))
{
Serial.println(F("Couldn't connect to OBD scanner - Phase 1"));
while (1);
}
if (!myELM327.begin(SerialBT, true, 2000))
{
Serial.println(F("Couldn't connect to OBD scanner - Phase 2"));
while (1);
}
Serial.println(F("Connected to ELM327"));
}
void loop() {
var = myELM327.processPID(34, 82, 1, 1, 100.0/255.0,0);
if (myELM327.nb_rx_state == ELM_SUCCESS) {
Serial.print("Ethanol (%): ");
Serial.println(var);
} else {
Serial.println("Failed to read Transmission Temperature or PID not supported.");
}
delay(200); // Delay between reads
} |
@415Robots Your loop needs to handle the case where the code is still getting the data from the ELM device. Try this in your loop(): if (myELM327.nb_rx_state == ELM_SUCCESS)
{
Serial.print("Ethanol (%): ");
Serial.println(var);
}
else if (myELM327.nb_rx_state != ELM_GETTING_MSG)
{
myELM327.printError();
} That will allow the full response message to be received before being processed. Also, the code shown in your two screenshots are both different than the code you posted, so it's not clear what code is actually running... |
Thanks for the feedback, I'll add the print Error and post the results. I only have limited access to the vehicle, so the testing was a lot of modifying working code to try to get PID 220052 to work, apologies for the confusion.
Sidenote: I definitely will check out the ELMulator, I really could use some kind of bench test for this project. |
You are not doing it wrong, and you should not expect an error. What I see happening now is that you’re getting a CAN “Response Pending” message (7Fxxxx). ELMduino doesn’t currently handle this type of response, and instead it returns zero. See p. 45 of the Elm327 datasheet for info. |
See Issue #44, parsing response data |
@415Robots Can you either post the debug printouts in the text of your comments (formatted please) or post the screenshots different? It's hard for me to read in the screenshots and when I try to download the hires, github comes up with an empty page for some reason... Either way, it looks like the response header for service 2 (or whichever service you're using) doesn't behave like response headers for service 1. |
21:54:08.931 -> Ethanol (%): 0.00 |
I'm not sure if this is a CAN error/warning as mentioned earlier or if this is how a service 32 PID response header is supposed to look like - can you provide more info on this custom PID? Do you have any documentation on it? I'm conflicted on whether I should make a special case for it in the lib or not. |
Hello Powerbroker2, I am in the same situation as @415Robots. The information I have recieved on this PID is from the torque pro app. PID: 220052 When running this pid through the obd2 editor in torque app, I get this response: |
I'm still unsure of how the PID is supposed to work and how to calculate what the response header should be. Is there any actual documentation of the PID or PID response? |
Idk what was going on in the previous set of debug prints, but this particular response looks similar to what I would expect. Notice how the response header's first byte is +4 compared to the query response header's first byte. The library in Lines 2327 to 2335 in 77874c0
I think more detailed debugging will be required to figure out what is going wrong. |
Mode 0x22 response headers always zero-pad the pid to 4 chars, even for a 2-char pid. That confused the header detection and response parsing. This change checks for the mode and pid in findResponse() and adjusts the expected header accordingly.
@StoneIsthisticky Thank you for the interest! I personally don't have experience using custom PIDs, but it shouldn't be too hard to implement if you know the service and PID of the custom query along with the expected output format. I'm also not experienced with Saabs or diesels in general. Do you have links to documentation on the PIDs you want to process? |
I'm confused, are those the PIDs you have working or the ones you need help with? |
Greetings,
I am having trouble pulling a specific PID (220052) . Currently using processPID() to make custom calls, but it only returns 0.0. I've tried the follow:
// example
double var = myELM327.processPID(34, 82, 1, 1, 100.0 / 255.0, 0.0);
My next plan of attack is to use the code in the test.ino to try passing the decimal or hex values over serial to see I can get anything. Is there any specific variables I should watch, that might give me a clue as to what I am doing wrong?
The text was updated successfully, but these errors were encountered: