LCD Issues

Hey guys,

I have an LCD hooked up to my Uno R3 and I'm trying to display the temperature of the water on it. The LCD will work ok for a little while but the a few things may happen. One, it will start showing odd symbols. Or two, the screen will be blank. I would like to be able to display the LCD all the time. Any advice is appreciated.

Post your code using the code tags (# button in message editor)

Pretty sure you're not properly updating the screen in your code by the sounds of it.

Alrighty, Here is the code. Im also doing some stuff with float switches and stuff and all that works fine. The main problem i am having is with the LCD. The LCD portion of the code is at the bottom. I would like to be able to have the LCD running correctly all the time so i can check up on the tank parameters at a glance. I also have a few other projects that i would like to do that involve displaying data on an LCD. I am here to learn so have at it. Thanks guys!

// FISH TANK MANAGEMENT SYSTEM

    #include <LiquidCrystal.h>
    #include <OneWire.h>
    
    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

    const int WaterLevelSensor = 6;                                                           // water level sensor           (float switch)     
    const int WaterValve = 9;                                                                 // water valve                  (12v solinoid valve)
    const int FillIndication = 13;                                                            // fill water indication        (Green LED)  
    const int OverFlowSensor = 7;                                                             // over flow sensor             (float switch)
    const int OverFlowWARNING = 8; 

    OneWire ds(10);    
      int HighByte, LowByte, TReading, SignBit, Tc_100, Whole, Fract;
      byte i;
      byte present = 0;
      byte data[12];
      byte addr[8];      

  void setup()
  {
     Serial.begin(9600);
     lcd.begin(16, 2);
     lcd.clear();
     pinMode(WaterLevelSensor, INPUT);                                                         // water level switch
     pinMode(WaterValve, OUTPUT);                                                              // water valve
     pinMode(FillIndication, OUTPUT);                                                          // fill water indication
     pinMode(OverFlowSensor, INPUT);                                                           // overflow protection
     pinMode(OverFlowWARNING, OUTPUT);                                                         // overflow indication

  }
  
  void loop()
  {
     if (digitalRead(WaterLevelSensor) == HIGH && digitalRead(OverFlowSensor) == LOW)          // read water level sensor and over flow sensor
  {
     delay(500);                                                                              // delay 1.00 sec
     digitalWrite(WaterValve, HIGH);                                                           // open water valve, low = valve open
     digitalWrite(FillIndication, HIGH);                                                       // fill water indication (green)
     digitalWrite(OverFlowWARNING, LOW);                                                       // overflow indication LED off
     Serial.println("H2o Levl = LOW");                                                           // display "Filling Tank"
     lcd.setCursor(0,0);
     lcd.print("Auto Fill   ");   
     
} 
     if (digitalRead(WaterLevelSensor) == LOW && digitalRead(OverFlowSensor) == LOW)           // read water level sensor and over flow sensor
  {                            
     delay(500);    
     digitalWrite(WaterValve, LOW);                                                            // close water valve, high = valve closed
     digitalWrite(FillIndication, LOW);                                                        // fill indication LED off
     digitalWrite(OverFlowWARNING, LOW);                                                       // overflow indication LED off
     Serial.println("H2o Levl = OK   ");
     lcd.setCursor(0,0);
     lcd.print("H2o L = OK    ");    
}
     if (digitalRead(WaterLevelSensor) == HIGH && digitalRead(OverFlowSensor) == HIGH)         // read water level sensor and over flow sensor
  {
    delay(25);                                                                                 // delay 0.25 sec
    digitalWrite(WaterValve, HIGH);                                                            // close water valve, high = closed 
    digitalWrite(OverFlowWARNING, HIGH);                                                       // overflow warning indication (red)
    digitalWrite(FillIndication, LOW);                                                         // fill indication LED off
    Serial.println("H2o Levl = OK");
    lcd.setCursor(0,0);
    lcd.print("H2o L = OP"); 
  }
     if (digitalRead(WaterLevelSensor) == LOW && digitalRead(OverFlowSensor) == HIGH)          // read water level sensor and over flow sensor
  {
    delay(25);                                                                                 // delay 0.25 sec
    digitalWrite(WaterValve, HIGH);                                                            // close water valve, high = closed
    digitalWrite(OverFlowWARNING, HIGH);                                                       // overflow warning indication (red)
    digitalWrite(FillIndication, LOW);                                                         // fill indication LED off
    Serial.println("H2o Levl = OVERFLOW");
    lcd.setCursor(0,0);
    lcd.print("H2o L = Warning");                                                               // display "OVERFLOW WARNING!!
  }
  
    if ( !ds.search(addr)) {                                                                   // temp probe
      ds.reset_search();
      return;
  }
    for( i = 0; i < 8; i++) {
  }
    if ( OneWire::crc8( addr, 7) != addr[7]) {
      return;
  }
    if ( addr[0] == 0x10) {
  }
    else if ( addr[0] == 0x28) {
  }
    else {
      Serial.println(addr[0],HEX);
      return;
  }
    ds.reset();
    ds.select(addr);
    ds.write(0x44,1);
    delay(5);
    present = ds.reset();
    ds.select(addr);    
    ds.write(0xBE); 
    for ( i = 0; i < 9; i++) {
    data[i] = ds.read();
  }
    LowByte = data[0];
    HighByte = data[1];
    TReading = (HighByte << 8) + LowByte;
    SignBit = TReading & 0x8000;
    if (SignBit)
  {
    TReading = (TReading ^ 0xffff) + 1;
  }
    Tc_100 = (6 * TReading) + TReading / 4;
    Whole = Tc_100 / 100;
    Fract = Tc_100 % 100;
  if (SignBit)
  {
    Serial.print("-");
  }
    lcd.setCursor(0, 1);
    lcd.print("H2o T = ");    
    lcd.print(Whole);
    lcd.print(".");
    lcd.print(Fract);
    lcd.print("C");
  }

Alrighty, Here is the code. Im also doing some stuff with float switches and stuff and all that works fine.

Let me take a wild guess ... the 'stuff' includes a valve, a pump, or some other electromagnetic device.

Don

i currently have no pumps or valves hooked up...

How are you hooking up the wires, on the arduino end AND on the lcd end? Bread board? Jumper wires? soldered wires? Did you solder on the lcd?

I have pins soldered to the LCD panel and plugged into a solderless bread board. Then useing jumpers from the bread board to the arduino to the pins shown in the code. Could I have damaged parts?

Dustyboy007: I have pins soldered to the LCD panel and plugged into a solderless bread board. Then useing jumpers from the bread board to the arduino to the pins shown in the code. Could I have damaged parts?

That sounds good. Are you using a resistor to limit current on the back light LED?

I have had similar problems with an lcd display printing gibberish or going blank in an electromagnetically noisy environment.

If underlying program works fine, and the display works fine until it goes wrong at random times, try and determine if it is after a switch closure or opening. I would focus first on the inputs since you don't have the fill valve yet and the other outputs are leds.

First, are you using pull up or pull down resistors on the two float switches? I would set the input pins to input pullup and take advantage of that functionality in the Uno.

Second, I would recommend both software and hardware debouncing the two float switches. I had an input which was reading perfectly with software debounce but it required a cap and resistor to pull noise spikes off the input lines and stabilize the lcd. Mr Google and the Arduino tutorials will get you going in the right direction.

If your input wires are long, there is a potential for problems. You may need to wrap them around some choke ferrites.

If all else fails, throw in an lcd.begin() , but it will be masking the actual problem, and it is better to get to the root cause.

Good luck.

liudr: That sounds good. Are you using a resistor to limit current on the back light LED?

Rarely necessary. Generally on a 5V module you will find R8 to be "101" = 100 ohm, and R9 - if present - to be 0.

Put a 10µF capacitor across pins 1 and 2 on the LCD unit.

Dustyboy007: I currently have no pumps or valves hooked up...

Relays perchance?

A note of caution... in my experience wiring to float switches is subject to noise and leakage. In some severe cases designing pump controllers inputpullups of 470 - 1000 ohms were successful in dealing with those issues and I remember one that required opto- isolators for galvanic isolation.

Doc

On mine it says "000" so no resistance. Running that on a 5V supply drags down the supply and has 150mA of current draw. It all depends on the manufacturer and you should measure current to make sure.

liudr: On mine it says "000" so no resistance. Running that on a 5V supply drags down the supply and has 150mA of current draw. It all depends on the manufacturer and you should measure current to make sure.

Unusual (for eBay/ DXtreme/ Newfrog ones, at least) - what is the source of these displays?

It isn't by chance, a 3.3V module?

Paul__B:

liudr: On mine it says "000" so no resistance. Running that on a 5V supply drags down the supply and has 150mA of current draw. It all depends on the manufacturer and you should measure current to make sure.

Unusual (for eBay/ DXtreme/ Newfrog ones, at least) - what is the source of these displays?

It isn't by chance, a 3.3V module?

Ebay sellers, various. I have purchased hundreds of displays over the past years. They vary a lot. You shouldn't make assumptions. Ebay sellers don't always have spec sheets so I do some measurements myself.