From e21bd33608bb908960453a8d80dd67a680264e5c Mon Sep 17 00:00:00 2001 From: PB2 Date: Mon, 13 May 2019 16:51:26 -0400 Subject: [PATCH] Update ELMduino_Test.ino --- examples/ELMduino_Test/ELMduino_Test.ino | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/examples/ELMduino_Test/ELMduino_Test.ino b/examples/ELMduino_Test/ELMduino_Test.ino index 1b1c9da..c3b8d37 100644 --- a/examples/ELMduino_Test/ELMduino_Test.ino +++ b/examples/ELMduino_Test/ELMduino_Test.ino @@ -2,27 +2,27 @@ 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() @@ -30,11 +30,13 @@ 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); } }