RGB LCD displays gibberish sometimes (Solved)

I have an Uno that I've turned into a water-heating solar controller. I've had the system running for months, and usually the LCD displays what it should. But sometimes, it produces gibberish on the LCD screen, and there's no way to read what really should be there.

Here are the components of the controller:
Major Components:
1 Arduino Uno R3 (made by Inland) purchased from MicroCenter. (Inland Uno R3 MainBoard Arduino Compatible; ATmega328 Microcontroller; 16MHz Clock Rate; 32KB Flash Memory - Micro Center)
2 DS18B20 OneWire Temperature sensors (three of them) from Elkner
(https://www.amazon.com/ELENKER-Waterproof-Temperature-Thermometer-Resistance/dp/B01DQQPR2A/ref=pd_lpo_vtph_107_bs_t_1?_encoding=UTF8&psc=1&refRID=BE0DNSM4R0YRXN4BKPPX)
3 RGB LCD and button-press shield from Adafruit (RGB LCD Shield Kit w/ 16x2 Character Display - Only 2 pins used! [POSITIVE DISPLAY] : ID 716 : $23.95 : Adafruit Industries, Unique & fun DIY electronics and kits)
4 12v DC 1 Amp 12 Watt Regulated Switching Wall Adapter (https://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?catalogId=10001&freeText=2232825&langId=-1&storeId=10001&productId=2232825&krypto=H4nGAL3YNNsQkxAqrBIoZaZ%2FulrzibxYk%2F7I1FKD7NdslShPqq%2FyeLW2n6HXvKL82LsDMvBUWLLBu1lGsppXGfLs1NmYAVflBBlpahNHNsE%3D&ddkey=https%3AStoreCatalogDrillDownView)

Either a button-press reset of the Uno, or else unplugging it then reconnecting its power, will stop the gibberish, at least for a while. What can I do to permanently get rid of this irritating "feature"?

UPDATE: I removed the PDF and ZIP files, replacing them with more generic .TXT and .JPG files.
UPDATE 2: I inserted some images to the post; 4 shots of normal screens, 6 shots of gibberish progression extracted from a video.

I've attached my full sketch (.TXT), a schematic diagram of the Uno system (.JPG), and some other JPGs showing
(A) screen shots of how the displays should look (normal functioning), followed by
(B) a selection of consecutive screen shots from a video where the gibberish started, and some of what it looks like as it progresses.

Any help you can suggest will be very much appreciated.

Here are 4 shots of normal screens:
00-Normal 1st screen.jpg

00-Normal 2nd screen.jpg

00-Normal 3rd screen.jpg

00-Normal 4th screen.jpg

Here are shots of some progressive gibberish:
01Jibberish.jpg

02Jibberish.jpg

03Jibberish.jpg

04Jibberish.jpg

05Jibberish.jpg

06Jibberish.jpg

ugfrog

00-Normal 1st screen.jpg

00-Normal 2nd screen.jpg

00-Normal 3rd screen.jpg

00-Normal 4th screen.jpg

01Jibberish.jpg

02Jibberish.jpg

03Jibberish.jpg

04Jibberish.jpg

05Jibberish.jpg

06Jibberish.jpg

Solar Controller - Full Sketch.txt (34.3 KB)

Delta_G, I'm not sure how to do that. I tried pasting the contents of the document inline, but only the text showed up. There's an icon to link to a URL, but I don't have anyplace on the web where I can post the contents. How do I paste (many) pictures inline? The screen shots show the progression of the gibberish over time.
ugfrog

Delta_G, Thanks. I tried editing my post, placing the attachment's URL into the image URL field. But when I looked at the preview, the link wasn't there. It's a link to a zipped file, too - that's the only way I could shrink what I need to show to fit the 1M limit for the post.
When I click on the attachment link, I get an option to open the file using windows explorer, or to save the file. I don't know how to get the thing to actually display in my post.

OK I updated my original post, removing the .PDF and .ZIP files. Now there are .JPGs and .TXT files. I couldn't include all the information I had in the removed files, but I hope what I've selected will be useful in getting this resolved. Sorry about the poor choices I made originally.
ugfrog

Your original post does not mention the motor or the relay that show up on your schematic wiring diagram. These are most likely the cause of your problem.

Try running your code with a simple LED indicator replacing the relay/motor combination and see if your problems go away.

Don

Hi, Don -
With respect to the recirculator pump, it's a Taco (pronounced TAKE-oh) cartridge pump, 115vAC, 0.8A. The pump was on the system when we bought the house 30 years ago. The pump was rebuilt once as normal maintenance about 10 years ago, but that's all I know about it. The relay is a 12vdc coil SPDT relay with 30A contacts, a duplicate of which exists on another Uno TEST setup I have for this solar controller system. Both work well.
Wouldn't the same model relay cause the gibberish problems in the TEST system, too? I've run the TEST system along with the real system for weeks at a time, and the real system gets the gibberish while the TEST system has never had the problem. Oh - the TEST system has a Negative LCD while the real system has a Positive LCD.

Wouldn't the same model relay cause the gibberish problems in the TEST system, too?

Maybe. Is everything else identical (power supply, wiring layout etc)? Are there two motors? Are the motor(s) and the power supplies fed from the same AC circuit? There's a lot that you aren't telling us.

Don

Floresta,
Good questions.
TEST system has been run on the same AC outlet as the real system, side-by-side at the same time, using identical 12vdc wall warts.
Wiring was not completely identical - TEST had 390 feet of telephone inside wiring COLL bus (opposed to the real system's 51 feet of cat5e cable).
There are not two motors - just one, but the relays are identical. Plus, the gibberish happens on the real system both when the motor is ON (closed contacts on the relay and recirculator motor running) and when the motor is OFF (open contacts on the relay and recirculator motor at rest). Again, I haven't seen gibberish on the TEST system.
Yes, both the motor and the power supply(ies) are powered by the same AC outlet.
I'm really not keeping info from you on purpose. I just don't know what you need to know. Let me know if there is anything else I can supply, and thanks for responding.
ugfrog

All,
I have been doing a lot of reading about this, and found a few places on the web that suggested using capacitors across the +5 and GND pins on the LCD display. From what I read, I chose a 0.1µF ceramic, and a 10µF electrolytic (correct polarity on the 10µF was observed) in parallel. I had high hopes for this solution. But after an hour and 35 minutes of running, gibberish once again covered the display screens.
ugfrog

Delta_G,
That's a really great idea! I'll write a small sketch that just writes 3 or 4 screens (with background color changes and delay() commands just like the real problem), and let the Uno chew on that in the real (not my TEST area) setup. I'll let you know what happens. Thanks!
ugfrog

Delta_G,
Well that was quick! I wrote the program. The variable "timesThroughLoop" is an int, initialized to zero. Here's the sketch:

/*
  Gibberish Test Sketch
#include <avr/wdt.h>  // For WatchdogTimer

// For Adafruit LCD shield
#include <Wire.h>
#include <Adafruit_RGBLCDShield.h>
#include <utility/Adafruit_MCP23017.h>

// Initialize LCD
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
// These #defines make it easy to set the backlight color
#define OFF    0x0  // In use for 150º or greater warning
#define RED    0x1  // In use
#define YELLOW 0x3  // In use
#define GREEN  0x2  // In use
#define TEAL   0x6  // In use for POSITIVE display (Dark Characters)
#define BLUE   0x4
#define VIOLET 0x5  // Hist - Now in use
#define WHITE  0x7  // In use for NEGATIVE display (Light Characters)

int timesThroughLoop = 0;

void setup() {
  cli();
  WDTCSR |= B00011000;
  WDTCSR = B00101001;
  sei();

  wdt_reset();
  pinMode(13, OUTPUT);      // sets the digital pin as output
  digitalWrite(13, LOW);    // sets the LED off
  
  lcd.begin(16, 2);
  lcd.setBacklight(YELLOW);
  lcd.setCursor(0, 0);
  lcd.print("This is a YELLOW");
  lcd.setCursor(0, 1);
  lcd.print("SETUP SCREEN.   ");
  lcd.print(timesThroughLoop);
  delay(5000);  // Leaves message showing for 5 seconds.
  wdt_reset();
}


void loop() {
  wdt_reset();
  
  if (timesThroughLoop > 99950) {
    timesThroughLoop = 1;
  }
  
  lcd.setBacklight(RED);
  lcd.setCursor(0, 0);
  lcd.print("This is a RED   ");
  lcd.setCursor(0, 1);
  lcd.print("SCREEN num      ");
  lcd.setCursor(11, 1);
  lcd.print(timesThroughLoop);
  timesThroughLoop++;
  delay(5000);  // Leaves message showing for 5 seconds.
  wdt_reset();

  lcd.setBacklight(YELLOW);
  lcd.setCursor(0, 0);
  lcd.print("This is a YELLOW");
  lcd.setCursor(0, 1);
  lcd.print("SCREEN num      ");
  lcd.setCursor(11, 1);
  lcd.print(timesThroughLoop);
  timesThroughLoop++;
  delay(5000);  // Leaves message showing for 5 seconds.
  wdt_reset();

  lcd.setBacklight(GREEN);
  lcd.setCursor(0, 0);
  lcd.print("This is a GREEN ");
  lcd.setCursor(0, 1);
  lcd.print("SCREEN num      ");
  lcd.setCursor(11, 1);
  lcd.print(timesThroughLoop);
  timesThroughLoop++;
  delay(5000);  // Leaves message showing for 5 seconds.
  wdt_reset();

  lcd.setBacklight(TEAL);
  lcd.setCursor(0, 0);
  lcd.print("This is a TEAL  ");
  lcd.setCursor(0, 1);
  lcd.print("SCREEN num      ");
  lcd.setCursor(11, 1);
  lcd.print(timesThroughLoop);
  timesThroughLoop++;
  delay(5000);  // Leaves message showing for 5 seconds.
  wdt_reset();

  lcd.setBacklight(BLUE);
  lcd.setCursor(0, 0);
  lcd.print("This is a BLUE  ");
  lcd.setCursor(0, 1);
  lcd.print("SCREEN num      ");
  lcd.setCursor(11, 1);
  lcd.print(timesThroughLoop);
  timesThroughLoop++;
  delay(5000);  // Leaves message showing for 5 seconds.
  wdt_reset();
  
  lcd.setBacklight(VIOLET);
  lcd.setCursor(0, 0);
  lcd.print("This is a VIOLET");
  lcd.setCursor(0, 1);
  lcd.print("SCREEN num      ");
  lcd.setCursor(11, 1);
  lcd.print(timesThroughLoop);
  timesThroughLoop++;
  delay(5000);  // Leaves message showing for 5 seconds.
  wdt_reset();
  
  lcd.setBacklight(WHITE);
  lcd.setCursor(0, 0);
  lcd.print("This is a WHITE ");
  lcd.setCursor(0, 1);
  lcd.print("SCREEN num      ");
  lcd.setCursor(11, 1);
  lcd.print(timesThroughLoop);
  timesThroughLoop++;
  delay(5000);  // Leaves message showing for 5 seconds.
  wdt_reset();

}

I just happened to be watching, and 159 was the last one to print normally. 160's first line was OK, but the second line was gibberish. Of course, the numbering was gibberish, but the first line froze on, "This is a WHITE" and the gibberish kept persisted, changing every 5 seconds as described below, in the second line. Screen colors were changing in the proper order through all this.

If it means anything (and I'll describe the first character as ONE, not ZERO), the 2nd line's 2nd, 5th, 6th, 8th, and 9th gibberish characters stay the same. They are as follows (with *** between the characters):
F


2


.....

.....

.....
.
.....
.


2


.....

.....

.....
.
.....
.

The characters in the 3rd, 4th, 7th, and 10th positions stay blank (space). The others (1 and 11 through 16) get all sorts of odd characters, changing every 5 seconds (delay() time), along with the colors.

Does this mean my RGB LCD is bad, my Uno is sending messed-up signals, does it mean something else, or can you tell?
ugfrog

Read reply #11 again and then do what it says. The "Hello World" example would be a good place to start.

Don

All,
The test program I wrote has now caused gibberish with only the LCD hooked to the Uno, as well as with the LCD and the solar connections in place on the Uno (of course, no code in the test sketch supported the solar connections). I don't know if that's important, but in any case, gibberish happens with both setups.

Floresta,
The reason I wrote the sketch as I did, was to mimic the displays generated by the solar program. I think the sketch is doing what post #11 suggested.

Maybe just the time from millis or something. Then you can see if it still messes up.

I took that to mean a changing display, written to the LCD on a periodic basis.

Are you saying I should just display one screen once - and let it sit forever to see if it gets corrupted? I'm not trying to be a pain here, but I'm not sure why you're saying what I did isn't what Delta_G suggested. I'm sorry.

Are you saying I should just display one screen once - and let it sit forever to see if it gets corrupted?

Surely you have at least looked at the Hello World example.

When you are trying to get an LCD working for the first time it is a good idea to use a 'static' program, one that displays a message in setup() and does nothing in loop(). For that purpose I believe that the "Hello World" program is a horrible example.

On the other hand, once you have your display running and you want to observe phenomena that occur after it runs for a while then the same "Hello World" program is a good choice since you want the simplest possible program that is not 'static'.

Once the simple program is running satisfactorily you can start adding your additional features, one a time. If the corruption appears you can then determine where the problem is being introduced.

Don

Floresta,
Thanks for breaking that down for me. Sometimes I can be a tad dense. I was beyond that step in my own thinking, and needed to be brought back to square 1.

Thank you, everyone. I believe I found the problem, and things are working perfectly now. No gibberish in 10 days of running 24x7. It turns out that the 12v regulated switching wall warts I was using (I tried two different ones) provided just too much juice for the Uno (or else their output was too noisy).

I've changed to a 12v battery with a step-down regulator set at 7.5 volts. No more gibberish in 10 days. That's a tremendous improvement.

Again, thanks for all your suggestions and help.

ugfrog