Skip to content
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

Timeout Issue #41

Closed
martindo72050 opened this issue Aug 7, 2020 · 11 comments
Closed

Timeout Issue #41

martindo72050 opened this issue Aug 7, 2020 · 11 comments
Assignees

Comments

@martindo72050
Copy link

martindo72050 commented Aug 7, 2020

Hello. I'm sorry to open another issue on this topic, I've been trying to figure this out for a few days now and can't. Probably my inexperience. Anyway my hardware is:

  • Arduino Mega
  • HC05
  • Bafx ELM327

I'm able to connect and retrieve data using AT commands, but I get timeout errors after connecting using the example code. Any ideas?

@PowerBroker2
Copy link
Owner

I've had timeouts occur, but only rarely. Are you able to get any data at all with the example before getting timeouts? What happens if you edit the CPP file to follow this configuration?

@PowerBroker2 PowerBroker2 self-assigned this Aug 8, 2020
@martindo72050
Copy link
Author

martindo72050 commented Aug 9, 2020

No data before timeouts. I'll try that and let you know.

Edit: Sorry for the dumb question (I'm very new to this stuff), where in the file do I enter that configuration? Do I replace the commands in the initialize function like this:

    sendCommand("AT Z");
    delay(100);

sendCommand("AT E0");
delay(100);

sendCommand("AT S0");
delay(100);

sendCommand("AT SP0");
delay(100);

@PowerBroker2
Copy link
Owner

You can use the macros from the header file, but I think you can do what you posted instead

@martindo72050
Copy link
Author

Tried it and still get the same issue

@PowerBroker2
Copy link
Owner

You said you can get data using AT commands. Can you provide that list of AT commands and their responses?

@martindo72050
Copy link
Author

martindo72050 commented Aug 9, 2020

Yes. I actually only used the AT commands for setting up the HC05, then got it out of AT mode and started simply typing the PIDs. Here I repeatedly typed 010C (rpm) and got this response:
Untitled drawing (7)

@PowerBroker2
Copy link
Owner

In that case, try getting rid of all AT commands in the begin() method and see if that fixes it

@martindo72050
Copy link
Author

martindo72050 commented Aug 10, 2020

Same result. Here is my current Arduino code:

#include "ELMduino.h"



#define ELM_PORT Serial1


ELM327 myELM327;


uint32_t rpm = 0;


void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);

  Serial.begin(38400);
  ELM_PORT.begin(38400);

  Serial.println("Attempting to connect to ELM327...");

  if (!myELM327.begin(ELM_PORT))
  {
    Serial.println("Couldn't connect to OBD scanner");
    while (1);
  }

  Serial.println("Connected to ELM327");
}


void loop()
{
  float tempRPM = myELM327.rpm();

  if (myELM327.status == ELM_SUCCESS)
  {
    rpm = (uint32_t)tempRPM;
    Serial.print("RPM: "); Serial.println(rpm);
  }
  else
  {
    Serial.print(F("\tERROR: "));
    Serial.println(myELM327.status);
    delay(100);
  }  
  delay(1000);
}

@brainfoolong
Copy link

brainfoolong commented Nov 29, 2020

Hi, i also have the same problem. If looked into the elmduino code and i found something that i can't explain. Currently it is so: After successfull initialization, once you get a ELM_TIMEOUT or ELM_UNABLE_TO_CONNECT after any command, you are stuck in that status and can't send any other commands.

It's because in current code, the connected flag is set to false on the begin of every sendCommand ->

connected = false;

This flag is only updated to true when you have received any success request (no timeout or unable to connect) ->

connected = true;

And the problem with this is, every call to queryPID, which you basically use for every data you want, require a connected = true ->

if (connected)

But this connected will never be true again, by only using a queryPID command. You have to call sendCommand to properly send a command, doesn't matter what connected status you have.

I've created a pull request, maybe this is helpful for someone and maybe this will be merged by the maintainer.

#47

@PowerBroker2
Copy link
Owner

Oh dang, good catch! I'll take a look at the PR. I've had trouble with many users (including myself, actually) having this timeout error issue, but could never figure it out - I hope this bug is the root of the issue.

@PowerBroker2
Copy link
Owner

This should be resolved with release 2.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants