LCD Display Issue

I have a "multi-gauge" that I made for my car which basically is an UNO attached to a pressure sensor, MAX6675 Thermocouple, and an LCD screen that displays the information. The screen has 3 pages: One for boost (current pressure-atm pressure), one for the thermocouple readings, and one for my water/meth system. I have a momentary switch that when pushed cycles through all of the pages.
The Issue: Sometimes when I start the car (turn on the arduino) the contrast will mess up and I won't be able to see anything except for the light of the backlight. Also after a period of time or after hitting boost the LCD screen will sometimes show random characters like "A@#$*(@#%(" and continues too even if you change to the next page.

I can't seem to figure out why this is happening but I have a feeling it's the way I am storing my values or talking to the LCD. Any ideas?

Thank you!

Here is the code sorry about that:

//Car Multi-Gauge Project
//Version: 1.0.0
//Author: Ryan St. John

#include <LiquidCrystal.h>
#include <LcdBarGraph.h>
#include "max6675.h"


//Menu and Display Settings
int select   = 1;                      //The number of the page that should be visible
int maxPages = 3;                      //The max number of pages
int Contrast = 90,                     //The brightness and contrast of the LCD display
    bg       = 55;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //Initialize the LCD library with the correct interface pins


//Boost Settings and Declarations
int boostSensorPin = A5;               //The pin that is connected with the boost sensor
double atmPressure = 0.0;              //Where the measure atmospheric pressure will be stored
double boostPeak   = 0.0;              //Where the max measured boost (in PSI) will be stored

//Exhaust Gas Temperature Settings
int thermoDO = 13;
int thermoCS = 10;
int thermoCLK = 9;
int vccPin = 8;                        //The power pin for the max chip
double tempPeak    = 0.0;              //Where the max recorded temperature will be stored
double tempAverage = 0.0;              //Where the average temperature will be stored
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);

//Meth Injection Settings
int relayPin = A0;                     //The pin that is connected to the meth relay
int switchPressure = 4;                //The PSI required to turn on the meth injection

//Interrupt Settings
int nextPagePin = A2;                   //The pin used to control which page is displayed
int nextPageSupplyPin = A1;             //The pin supplying the high voltage


//Custom LCD display characters
byte thermometerChar[8]    = { B00100, B01010, B01010, B01110, B01110, B11111, B11111, B01110 };
byte degreeChar[8]         = { B01100, B10010, B10010, B01100, B00000, B00000, B00000, B00000 };
byte thermometerAvgChar[8] = { B11111, B00000, B00100, B01010, B01010, B01110, B11111, B01110 };




void setup() 
{
  pinMode(13,OUTPUT);
  pinMode(relayPin, OUTPUT);
  pinMode(nextPagePin,INPUT);
  pinMode(nextPageSupplyPin,OUTPUT);
  digitalWrite(nextPageSupplyPin, 100);
  pinMode(vccPin, OUTPUT); 
  digitalWrite(vccPin, HIGH);
  
  //Set Final Contrast and BG Level 
  analogWrite(6,Contrast);
  analogWrite(9,bg);
  
  while(atmPressure == 0.00)
    calibrateAtmosphericPressure();
    
  //Show the welcome message  
  welcomeDisplay();
  
  //If atmospheric pressure didn't calibrate right set it to the average atmospheric pressure
  if((atmPressure > 14.50) && (atmPressure < 15.10))
  {
    lcd.setCursor(0, 0);
    lcd.print("---Calibrated---");
    lcd.setCursor(4, 1);
    lcd.print(atmPressure);
    lcd.setCursor(9, 1);
    lcd.print("psi");
  }else{
    atmPressure = 14.6959;
    lcd.setCursor(0, 0);
    lcd.print("---Defaulting---");
    lcd.setCursor(4, 1);
    lcd.print(atmPressure);
    lcd.setCursor(9, 1);
    lcd.print("psi");
  }
  
  delay(1000);
  
  lcd.setCursor(0, 0);
  lcd.clear();
}



void loop() 
{

  //Check and see if next page button is pressed
  if(analogRead(nextPagePin) > 1000){
    delay(300);
    
    lcd.clear();
    select++;
  }

  if((select > maxPages))
  {
    //Trying to go to a page that doesn't exist so loop back through the pages starting at 1
    select = 1;
  }
    
    //Boost page selected
    if(select == 1)
    {
      double boost = readBoost();
  
      if(boost > boostPeak)
      {
        boostPeak = boost;
      }
      
      if(boost > 0){
        if(boost > 8) { boost = 8; }
        String bar = "";
         for (double i = 0; i < boost; i = i + 0.5)
         {
           bar = bar + "|";
         }
         lcd.print(bar);
      }
      
      if(boost < 0){
        lcd.setCursor(0,0);
        lcd.print(boost);
        lcd.setCursor(4,0);
        lcd.print("vac");
      }else{
        lcd.setCursor(0,0);
        lcd.print(" ");
        lcd.setCursor(1,0);
        lcd.print(boost);
        lcd.setCursor(4,0);
        lcd.print("psi");
      }
      
      lcd.setCursor(8,0);
      lcd.print("Peak:");
      lcd.setCursor(13,0);
      lcd.print(boostPeak);
      
     
    //Exhaust Temperature Selected
    }else if(select == 2){
      
      //Create the custom characters
      lcd.createChar(0, thermometerChar);
      lcd.createChar(1, degreeChar);
      lcd.createChar(2, thermometerAvgChar);
      
      int temp = readExhaustGasTemperature();
      
      lcd.setCursor(0,0);
      lcd.write(byte(0));
      lcd.setCursor(1,0);
      lcd.print(temp);
      lcd.setCursor(5,0);
      lcd.write(byte(1));
      lcd.setCursor(6,0);
      lcd.print("F");
      
      lcd.setCursor(8,0);
      lcd.write(byte(2));
      lcd.setCursor(9,0);
      lcd.print(tempAverage);
      lcd.setCursor(13,0);
      lcd.write(byte(1));
      lcd.setCursor(14,0);
      lcd.print("F");
      
      lcd.setCursor(0,1);
      lcd.write(byte(0));
      lcd.setCursor(1,1);
      lcd.print("max");
      lcd.setCursor(5,1);
      lcd.print(tempPeak);
      lcd.setCursor(9,1);
      lcd.write(byte(1));
      lcd.setCursor(10,1);
      lcd.print("F");
      
      
    //Meth Injection Selected 
    }else if(select == 3){
      
     double boost = readBoost();
        
      if(boost < 0){
        lcd.setCursor(0,0);
        lcd.print(boost);
        lcd.setCursor(4,0);
        lcd.print("vac");
      }else{
        lcd.setCursor(0,0);
        lcd.print(" ");
        lcd.setCursor(1,0);
        lcd.print(boost);
        lcd.setCursor(4,0);
        lcd.print("psi");
      }
      
      lcd.setCursor(8,0);
      lcd.print(" Set:");
      lcd.setCursor(13,0);
      lcd.print(switchPressure);
      
      if(boost >= switchPressure)
      {
        digitalWrite(relayPin, HIGH);
        lcd.setCursor(0,1);
        lcd.print("Injecting Meth!");
      }else{
        digitalWrite(relayPin, LOW);
        lcd.setCursor(0,1);
        lcd.print("Meth System Idle");
      }
      
    }
    delay(300);
    lcd.clear();
}

void calibrateAtmosphericPressure()
{
  //Set the sensor pin to input 
  pinMode(boostSensorPin, INPUT);
  
  //Read the raw value of the pressure sensor
  int rawValue = analogRead(boostSensorPin);
   
  double change, last;
  
  //Take a reading a wait
  last = analogRead(boostSensorPin);
  delay(250);
  
  //Wait for sensor to stabalize 
  do
  {
    double readSens = analogRead(boostSensorPin);
    
    change = readSens - last;
    last = readSens;
    delay(50);
  }while(change != 0);
  
  //Convert the raw data of the atmospheric pressure to PSI
  atmPressure = (last*(.00488)/(.022)+20) * 0.14503773773020923;
  
  //Debugging
  //Serial.print("Atmospheric Pressure: ");
  //Serial.println(atmPressure);
}

void welcomeDisplay()
{
  //Set up the number of lines and columns on the LCD
  lcd.begin(16, 2);
  
  //Move the cursor to the middle of the first line
  lcd.setCursor(4, 0);
  
  //Display the message
  lcd.print("Welcome");
  
  //Set the contrast to max so we can fade in
  int cont = 255;
  
  //Fade BG and Contrast in
  for(int i = 0; i <115; i++)
  {
    if(cont > 115){
      cont = cont - 8;
    }
    analogWrite(6, cont); 
    analogWrite(9,i);
    delay(15);
  }
  
  //Set Normal Contrast and BG Level 
  analogWrite(6,Contrast);
  analogWrite(9,115);
  delay(500);
  
  //Set the contrast to fade out from
  cont = Contrast;
  
  //Fade BG and Contrast out
  for(int i = 115; i > 55; i--)
  {
    if(cont < 255)
    {
      cont = cont + 1;
    }
    analogWrite(9,i);
    analogWrite(6, cont); 
    delay(30);
  }
  
  //Clear the welcome message
  lcd.setCursor(4, 0);
  lcd.print("       ");
  
  //Set Final Contrast and BG Level 
  analogWrite(6,Contrast);
  analogWrite(9,bg);
}

double readBoost()
{
  //Define our return holder
  double boost = 0.0;
  
  //Read the raw data from the pressure sensor
  int raw = analogRead(boostSensorPin);
  
  //Convert the raw data into PSI and then subtract it from the atmospheric pressure
  boost = ((raw*(.00488)/(.022)+20) * 0.14503773773020923) - atmPressure;
  
  return boost;
}

int readExhaustGasTemperature()
{
  //Define our return holder
  int tmp = 0;
  
  //Read the raw data from the temperature sensor
  tmp = thermocouple.readFahrenheit();
  
  //Keep a record of the average temperature
  if(tmp > 0)
  {
    tempAverage = ((tempAverage + tmp)/2);
  }
  
  //Keep a record of the max temperature reached
  if(tmp > tempPeak)
  {
    tempPeak = tmp;
  }
  
  return tmp;
}

I can't really get any pics of the wiring because everything is ran in my dashboard and behind my vents. I actually just opened up the arduino and re-soldered all of the headers on and put some liquid electrical tape all over things just to make sure there no shorts or anything. I will report back if it was a wiring problem or if I am still running into the same thing.

Thank You.

I have a nasty suspicion that your LCD display module of undisclosed ancestry is not mounted immediately adjacent to your Arduino module as it needs to be. I suggest for a start, wiring a 47 µF capacitor across pins 1 and 2 of the LCD module.

Speaking of spider wiring, note that all power and sensor wiring must be paired.

Upon further examination I found that one of the wires on the back of the LCD broke off and was hanging loosely around the contact area. That explains why it would work sometimes and stop working on bumps and when accelerating hard. I fixed it and it looks to be working fine again.

I will keep an eye on it for the next couple days and see if that was the only issue.

Thank you guys for your help!

Quick Question: If my arduino is powered from the car battery and grounded with the frame I don't need to run grounds to my sensors because I can just ground to the frame next to the sensors correct? The grounds seem to be good as I am measuring very low (0) resistance between the battery ground and the frame.

The danger here is twofold; that currents flowing in appliances (such as the ignition) and returning trough the ground wire will produce voltages and impulses across sections of the body which will be added to your sensor voltages; secondly that having the sensor wire separated from the ground will result in "loops" picking up inductive voltages from electromagnetic fields within the car.

You must therefore provide all such inputs with surge arrestors - as well as impulse filtering.