Car Heads Up Display

In order to make interfacing with the OBD scanner as easy as possible, I wrote a library for it: ELMduino GitHub

Here is an example sketch I ran today with my own hardware to get RPM data at ~13Hz:

#include <ELMduino.h>

ELM327 myELM327;

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

void setup()
{
  Serial.begin(115200);
  Serial3.begin(115200);
  
  delay(2000);
  
  if(!myELM327.begin(Serial3))
    Serial.println("Couldn't connect to ELM327");

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

void loop()
{
  currentTime = millis();
  if((currentTime - previousTime) >= samplePeriod)
  {
    previousTime = currentTime;
    
    if(!myELM327.queryRPM(rpm))
    {
      Serial.println("\tTimeout");
    }
    else
      Serial.print("RPM: "); Serial.println(rpm);
  }
}

NOTE: This will only work if you have already paired your HC bluetooth board with the OBD scanner. Otherwise, it works like a charm!

Next I'm going to add queries in the test sketch for vehicle speed in addition to the already existing queries for RPM.

1 Like