Go Down

Topic: 16 x 2 lcd garbled (Read 32722 times) previous topic - next topic


Feb 19, 2014, 08:08 pm Last Edit: Feb 19, 2014, 08:20 pm by adalarasu Reason: 1
Hi everyone,
Iam trying to come out with a water totalizer, dispenser with preset quantity levels measured in literes, using arduino uno r3 board.
I have a standard 16x2 LCD display, hooked to an Arduino Uno using 4 data pins, as described here,
In short, RW is wired to ground, and RS, Enable, and Data4-7 are connected to Arduino pins, while Data 0-3 are floating.

I have other things (water flow sensor, an optoisolated 5vRelay module, a mains (220v AC) solenoid valve connected to the relay module and some momentary switches) connected to the pins on the Arduino as given below.
1            GND
2            +5V
3            TO GND THROUGH 10K POT
4            PIN 9
5            GND
6            PIN 8
11            PIN 7
12            PIN 6
13            PIN 5
14            PIN 4
15            +5V THROUGH 330OHM RESISTOR
16            GND

I have connected the sensor to arduino pin 2 and the relay module's line to pin 3 and three momentary switches to pins 10, 11, 12.
The code I use writes text to the lcd display, the flow rate, total flow and preset quantity, and normally, the display works perfectly.
However, sometimes the LCD becomes garbled. It remains garbled usually after a few more cycles of open/close to reset. The garbling always starts and stops at the same time as the relay either opens or closes.
By "garbled", I mean that every time I write to it following it becoming garbled, rather than writing english characters, I get a string of characters, that I usually cannot identify in the datasheet. This string of garbled characters tends to move left along the screen.
I am confident it's not the Arduino itself getting confused, as I write the same text to the Serial monitor at the same time, and it is not garbled and the code loop works finely even when the lcd remains garbled.
I've since experimented with wiring the RW pin to an Arduino output, and Data0-3 to ground, but this doesn't help. I've powered the whole device with a 9V battery or with USB, and it doesn't help. I've replaced the battery... no change.
I tried to take the load (the solenoid valve) connected to the relay away from the whole setup…no change,
I even tried after disconnecting the load (the solenoid valve) from the relay (but the 220vAC mains remained connected to the relay contacts, without any load)…no change
I can confirm that, the electro magnetic interference caused by the solenoid valve is not the reason for this garbling.
The only thing that seems to work fine is when, I disconnect the 220vAC mains from the relay contacts, but that defeats the purpose :-),
I am confident that the relay is not making any disturbances to the lcd but the 220v AC mains when connected to the relay even without any load, garbles the lcd.
I mean the lcd only, not the arduino.
I don't have a signal analyser or anything more sophisticated than a multimeter, a laptop and an arduino... Does anyone have any hints for helping me debug this?
Kindly help me…
I have attached the image of garbled text:
i have posted the same in the general lcd forum also.


What is impedance of 5V Relay?


Hi Saravanan, sorry for the delay,
I am unable to find anything regarding impedance on the relay,
I am attaching the image of the relay board. as I have said earlier,
I am confident that the relay board, or the relay is not the reason for this garbling,
because, if I isolate the load along with the 220v ac power source, every thing is working fine,
if I just connect the 220v ac source to the relay switch even without any load, then the lcd garbles.
Still I am unable to find any solution.


i want to clarify something with you guys,
when i went through a site regarding this problem,
someone answered that " using a shielded wire will solve this garbling problem as this is due to emi generated by solenoid",
is it true?, if so, where i have to connect the shied of the wire, i mean, to the gnd of arduino are the earthe of the 220v ac mains
kindly help me,


That happens very often.You must put a polyester capacitor 100nF  in parallel with the relay coil to suppress the noise caused by the relay when it switches.
Post the results
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B


The only thing that seems to work fine is when, I disconnect the 220vAC mains from the relay contacts, but that defeats the purpose :-),
I am confident that the relay is not making any disturbances to the lcd but the 220v AC mains when connected to the relay even without any load, garbles the lcd.
I mean the lcd only, not the arduino.

hi, as I have stated before, if the relay module alone connected to the arduino without the 220v ac mains connected to it , works fine ant not creating lcd garbling. when I connect the 220v ac mains even without the load (solenoid valve) connected to it, garbles the lcd,
this problem is not yet solved,
Iam awaiting for the forum help...  :*


Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B


thanks, i will try this, :)


I had a similar problem with a 16x4 LCD display when the Arduino was also controlling a SainSmart opto-isolated relay board, http://www.sainsmart.com/arduino-pro-mini.html. Everything worked fine with the relay contacts unconnected. But when the relay switched an inductive load (a 24 VAC power relay), the display garbled. No amount of power isolation and filter capacitors helped.

What solved the problem was a snubber (capacitor and resistor in series) across the SainSmart relay contacts. I used an expensive prepackaged Cornell Dubilier EMI/RFI filter (http://www.digikey.com/product-search/en?x=0&y=0&lang=en&site=us&keywords=338-2580-ND) for neatness, but a garden-variety 0.1 ufd capacitor in series with a 47-ohm resistor would probably work just as well.


hi, thank you very much. sorry for the delay. i was frustrated trying all sort of ideas available, ended-up in vein. so, i decided to have a break and start again and I am on now in this new year. i will try this type of filter. kindly clarify me, where to place the filter exactly!. if possible with a diagram, which will help me to understand better.
thanks & regards,


You need to put the snubber between from "-" to "+" on the relay coil. Problem will definitely solved.

Visit : Techjeeva Technologies Pvt. Ltd.


Hello, I am experiencing the same issue, I'm currently working with an arduino + 4 relay module that activates 3 electro-pneumatic valves, the lcd shows weird characters when a relay opens. This post is very rich content, thought i tried the solutions exposed above, i even made a snubber filter and put it across the valves connections points, i couldn't fix it. can somebody provide some support please?.

Thank you.


Jul 22, 2016, 07:05 pm Last Edit: Jul 22, 2016, 07:18 pm by hoblab
had the same problem, the display went bananas after 2 seconds (serial output OK). The cause was a 1 meter long 1-wire cable with a temperature sensor at the end (a vital part of the system so I couldn't get rid of it). That shoudn't be a problem, but it was.
Tried everything - short wires, shielded 1-wire cable, all power and GND lines hooked at the same spot, capacitors here and there, alternative LiquidCrystal library, and then I just gave up.

SOLUTION (or workaround, to be precise):
My program outputs data to the display once every 1 second. I put the init command lcd.begin(16, 2) just before the lcd.print() block in loop(), and... solved! Not a neat solution probably, but it does the job - no problems in 2 weeks so far.

DRAWBACK - the LCD flickers slightly during the execution of the lcd.begin command, but it's barely visible (may vary depending on your display model), and the whole device is hidden in a closet, checked like once a week, so I really don't care, and it's surely far better than garbage on the screen.

FYI, my LCD is not a "true" 16x2, it's a big 16x1 but organized as 8x2, but the controller is standard, so this solution should help.
System config: Arduino nano, RTC, 1-wire temp sensor, 4 relay module, LCD, rotary encoder, 9V power supply.


this problem happen if your circuit contain relay or any inductive load. because the inductive store energy then discharge in direction opposite the source it this generate noise . to eleminate this phenomenon must use Free wheeling diode or Rc circuit in parallel with relay coil or inductance .
Assistant Engineer Hamza Mohammed..
Regrad ..


To all that have weird characters on LCD screen when you run 117 Volts from a relay using the Arduino!
This is what I found.  Put a 470 uf electrolytic capacitor across the SIGNAL pin on the relay and ground. That fixed all the issues for me.
I driving the relay with a separate power supply, which didn't work which led me to believe It could be the signal pin and sure enough it was. Hope this works for everyone else having the same issue.

Go Up