LCD displaying garbled text when loop runs for the second time.Please Help

Code for my project:Runs perfectly,but LCD shows garbled text when the loop runs second time onwards…is it the relay? Install DHT library when running the code…Is it because of Relay switching?Please Help.Thank You

Code Attached below:

HYDRO_with_LCD.ino (10.7 KB)

Hi and welcome.

You seem to know the answer already.
Remove the relay, and test again.

If that doesn’t answer your question, show some more of your setup.
That means take pictures of it and show them, it doesn’t mean point to other pictures telling “i built it like that”.

I don't think this type of problem has ever come up before, except maybe yesterday, or the day before, or last week, or last month, or all of the above. Have you looked through any of the previous posts?

Try a search (in the upper right corner of the page) for topics that include LCD along with garbled, weird, strange etc.

Don

@MAS3 and @floresta:

Thanks for replying,The LCD(16X2 1602A) works fine without relay.The problem is i need to use the relay board(8 in 1,5V powered) as 2 AC fountain pumps are connected to it.As the first pump(1.6m height,400L/hr) is used to pump water to reservoir and back from reservoir to tank using second pump(slightly smaller 0.8m Height,200L/hr) both controlled via float switch.

Earlier while trying to interface LCD(J162A),They(Arduino LCD example comments) asked me to use a resistor and a potentiometer which didnt solve the problem,then i used 1602A LCD without pot and resistor works fine now.So i tried a 5k ohm pot. to rectify the garbling problem,It didnt solve the problem.
I am attaching the photos as MAS3 had asked.Help required.
Thanks.

@floresta:

I did search the forums they are asking me to use capacitor at relay and others are suggesting snubber(resistor and capacitor in series),which i dont have right now(n have no guarantee if it will work).Is there any way we can troubleshoot the code itself in order to eliminate garbling?

Thanks

Project:Automation of hydroponics

2

Hi.

Where is your display?
Didn't find it in those pictures.
The last 2 pictures are the same.

Take a look at your 2nd. picture.

To receive signals, you need an antenna.
The 2nd. picture shows a whole bunch of antennae.
These receive all kinds of signals, most unwanted ones.

So first thing to do, is to tidy up that wire mess.
Keep the AC wires from the relays as far away as possible from the other wires (what's up with that yellow wire ?).
Do not use longer wires than they need to be.
Do not bundle wires with different types of signal together.
If they need to cross each other, make sure that crossing is reduced to the smallest surface possible, meaning they should cross under an angle of 90 degrees.

No capacitor or snubber network is going to help if you do not tidy up first.

@MAS3: Hi.
I read about that solution here (Debugging a 16x2 LCD Display on an Arduino - Electrical Engineering Stack Exchange),but that person couldn't solve the problem by moving the relay away,that's why I didn't bother trying.I will try it once.And the yellow wire is nothing special had ran short of dark coloured wires.
Thanks.

Will put up more pictures in sometime.

Did you get this message ? :

Clean up the wire mess.

I am puzzled. Those plants do not seem to have the usual serrated leaves. :roll_eyes:

As floresta points out, this question appears again and again (and again). In this case, we actually have pictures to illustrate the point which is unusual.

"Newbies" do not understand the concept of "lead dress" - keeping cables bundled and separated according to category - signal, low voltage, high voltage, really high voltage. Those of us who have spent a lifetime in electronics just do this by habit, having always just understood why and often do not countenance that others would not do it.

You need to bundle the wires (most of use would actually use the "ribbon" version and separate out just enough of a ribbon from the stock) for each interconnection. I am not sure that the perpendicular crossing of signal and power wires is so relevant - they should simply not be near each other in the first place.

Next it is important that if you use an opto-isolated relay board (as apparently you are not), that the ground not be common between the input of the opto-isolators and the relay coil supply. Most of those available (and notably on eBay) have a common positive for the opto inputs, which must go to the Arduino Vcc but the ground should not be connected. Yours is not isolated, but is at least buffered by that IC; you should put a 100µF capacitor directly across the Vcc and ground terminals of the relay board.

I would be surprised if properly tidying the lead dress did not actually solve your problem. Do not forget to use "figure 8" cable for the power connections form the relays (and leave no loops where they connect to the pumps).