Skip to content

Commit

Permalink
Update ELMduino_Test.ino
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerBroker2 authored May 13, 2019
1 parent b78eb28 commit e21bd33
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions examples/ELMduino_Test/ELMduino_Test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,41 @@

ELM327 myELM327;

float speed;
float rpm;
uint64_t currentTime = millis();
uint64_t previousTime = currentTime;
uint16_t samplePeriod = 200;
uint16_t samplePeriod = 80;

void setup()
{
Serial.begin(115200);
Serial1.begin(115200);
Serial3.begin(115200);

delay(2000);

if(!myELM327.begin(Serial1))
if(!myELM327.begin(Serial3))
Serial.println("Couldn't connect to ELM327");

if(!myELM327.querySpeed(speed))
if(!myELM327.queryRPM(rpm))
{
//Serial.println("\tTimeout");
Serial.println("\tTimeout");
}
else
Serial.println(speed);
Serial.print("RPM: "); Serial.println(rpm);
}

void loop()
{
currentTime = millis();
if((currentTime - previousTime) >= samplePeriod)
{
if(!myELM327.querySpeed(speed))
previousTime = currentTime;

if(!myELM327.queryRPM(rpm))
{
//Serial.println("\tTimeout");
Serial.println("\tTimeout");
}
else
Serial.println(speed);
Serial.print("RPM: "); Serial.println(rpm);
}
}

0 comments on commit e21bd33

Please sign in to comment.