Go Down

Topic: Car Heads Up Display (Read 1 time) previous topic - next topic

Power_Broker

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:
Code: [Select]

#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.

"The desire that guides me in all I do is the desire to harness the forces of nature to the service of mankind."
   - Nikola Tesla

Power_Broker

Got speed and rpm data working together with some updates to the library and the test sketch. Here's the sketch:

Code: [Select]

#include <ELMduino.h>




ELM327 myELM327;

enum fsm{
  get_speed,
  get_rpm};
fsm state = get_rpm;

float rpm;
float speed_kmph;
float speed_mph;
uint64_t currentTime = millis();
uint64_t previousTime = currentTime;
uint16_t samplePeriod = 100;




void setup()
{
  Serial.begin(115200);
  Serial3.begin(115200);
 
  delay(2000);

  myELM327.begin(Serial3);
}




void loop()
{
  currentTime = millis();
  if((currentTime - previousTime) >= samplePeriod)
  {
    previousTime = currentTime;

    switch(state)
    {
      case get_rpm:
        if(myELM327.queryRPM(rpm))
        {
          updateLEDs();
        }
        else
          Serial.println("\tTimeout");
        state = get_speed;
        break;
       
      case get_speed:
        if(myELM327.querySpeed(speed_kmph))
        {
          speed_mph = speed_kmph * 0.621371;
          updateLEDs();
        }
        else
          Serial.println("\tTimeout");
        state = get_rpm;
        break;
    }
  }
}




void updateLEDs()
{
  Serial.print(rpm); Serial.print(" "); Serial.println(speed_mph);
 
  return;
}


Next step is to get this all working with the LED display.
"The desire that guides me in all I do is the desire to harness the forces of nature to the service of mankind."
   - Nikola Tesla

Power_Broker

#17
May 30, 2019, 11:14 pm Last Edit: May 31, 2019, 01:44 am by Power_Broker
I designed a PCB for the project!

I'll be using a Teensy 3.5, HC-05, 75 ohm LED current limiting resistors, 2 7-segment LED displays, and a 10-segment LED display.

Here are some pics of the design (gerber files are attached):


"The desire that guides me in all I do is the desire to harness the forces of nature to the service of mankind."
   - Nikola Tesla

Power_Broker

@sandracarmona

Unfortunately, I'm not fluent in Spanish. Google translate has your message as:
Quote
In the high range, more and more smartphones have opted for OLED technology for their screens. We have clear examples in the LG V30, the Galaxy Note 8, the Pixel 2 XL and more recently, the iPhone X, the last one to join this list.

Having an OLED screen allows for more striking designs where the screen is clear protagonist. But are they all advantages? We talk about what we earn but we also lose with OLED screens in our phones
Is this correct?

If so, I'm not sure what your point is. I'm not currently interested in using an OLED display for the HUD. This is because I'll be able to make the LED display brighter than an OLED one. Also, I'm trying to keep this project, so a few 7/10-segment displays are all I need.

Using an OLED display might be a next step development once the initial prototype is complete...maybe.

Did you have any specific questions about this project?
"The desire that guides me in all I do is the desire to harness the forces of nature to the service of mankind."
   - Nikola Tesla

Go Up