LCD Goes blank after about 24 hours

I am a fairly new user of the arduino and I need some input from more advanced arduino users.

The code listed below compiles and runs fine. It prints out the two correct temperature readings on the lcd as designed. However, after about 24 hours the displays goes blank and I assume the arduino has locked up, crashed or run out of memory. I can reset the arduino and it will start back up and display the two temperatures as normal.

I don’t understand why the code does not continue to run. If anyone knows what is causing the problem and how to correct the problem I would very much appreciate you sharing your knowledge.

Thank you,

Robert

code

//************************** PROGRAM INFORMATION *****************************

// FILE NAME - DS18B20_TEST_READ_V3 09-19-2018
// Read 2 one wire sensors and display on LCD
// This Arduino sketch reads DS18B20 “1-Wire” digital temperature sensors

//**************************** INCLUDED LIBRARIES *****************************

#include <OneWire.h> //One Wire Communication Driver
#include <DallasTemperature.h> //Dallas One Wire DS1820 SENSOR Library
#include <LiquidCrystal.h>

//*************************** GLOBAL VARIABLES *********************************

LiquidCrystal lcd (4,5,6,7,8,9);

//*********************** ONE WIRE STUFF **********************************

// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3 // from 3 to 8 WORKS

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// Assign the addresses of your 1-Wire temp sensors.
DeviceAddress In_Temp = { 0x28, 0x1A, 0x03, 0x26, 0x06, 0x0, 0x00, 0x6C };
DeviceAddress Out_Temp = { 0x28, 0x35, 0x6A6D, 0x27, 0x06, 0x00, 0x00, 0xC2 };

//****************************************************************************
//**************************** SETUP SECTION BEGINS *************************
//****************************************************************************
void setup(void){

// start serial port
Serial.begin(9600);
lcd.begin(16,2);
lcd.clear();
lcd.setCursor(0,0);

//************************** ONE WIRE ***********************************

// Start up the library
sensors.begin();
// set the resolution to 10 bit
sensors.setResolution(In_Temp, 10);
sensors.setResolution(Out_Temp, 10);

}

//*********************** STRING DEVELOPMENT FUNCTION *******************

String printTemperature(DeviceAddress deviceAddress) {
String outString = “”; //creates empty string
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
outString += “Error getting temperature”;
} else {
outString += DallasTemperature::toFahrenheit(tempC);
//outString += “\n\r”;
}
return outString;
}

//*************************************************************************
//************************ LOOP SECTION BEGINS *************************
//*************************************************************************

void loop(void){

String tempString;

sensors.requestTemperatures();
tempString = printTemperature(In_Temp);
lcd.print("H2O T In: ");
lcd.print(tempString);
tempString = printTemperature(Out_Temp);
lcd.setCursor(0,1);
lcd.print("H2O T Out: ");
lcd.print(tempString);
lcd.setCursor(0,0);
delay(9000);
}

/code

If you use [code] instead of code and [/code] instead of /code, you will have your code tags right :wink:

Code wise, use of String (capital S) might be a possible cause of your problem. Use of nul-terminated character arrays will eliminate that as a cause.

To make it easy for people to help you please modify your post and use the code button </>

so your code looks like this

and is easy to copy to a text editor. See How to use the Forum

It is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. This can happen after the program has been running perfectly for some time. Just use cstrings - char arrays terminated with ‘\0’ (NULL).

The problem you describe could be due to the use of the String class.

…R

Please edit your post and include code tags to make it readable.

Eliminate the use of the String class in your complete code. It fragments the memory and sooner or later you run out of it which results in any unexpected behavior.