I have a standard 16x2 LCD display (I believe it is Hitachi HD44780 compatible - see summary and specification below), hooked to an Arduino Uno using 4 data pins, as described here, though I've added 2x 220ohm resisters in parallel (ie a 110ohm resistor) on pin 16 (Backlight ground), and replaced the Pot with static resistors to create 4V on Vo.

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 (sensors, a transistor with an optoisolated SSR and a mains relay, some buttons) connected to different pins on the Arduino. The code I use writes text to the display a number of times a second, and normally, the display works perfectly.

However, when the relay closes (it takes about 10ma, and is controlled by a transistor which is in turn controlled from one of the Arduino pins), sometimes the LCD becomes garbled. It remains garbled usually until the relay next closes, but sometimes when the relay opens, or 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 (though some I can). This string of garbled characters tends to move left along the screen as I write new text to the LCD.

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.

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.

The only thing that seems to work is having no load plugged in to the relay, but that defeats the purpose :-)

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?

LCD Summary Sheet: http://oomlout.com/LCDD/LCDD-SUMM-BC1602A.pdf

LCD Specification: http://oomlout.com/LCDD/LCDD-DATA-BC1602A.pdf

Example of garbled text: garbled text

  • 1
    \$\begingroup\$ Try adding an at least 1 uF capacitor to your power rails, that is one end of the capacitor to Vcc and other is to GND. Be careful with the direction of the capacitor if it is an electrolytic :) \$\endgroup\$ – abdullah kahraman Jun 19 '12 at 8:12
  • 1
    \$\begingroup\$ This is really bizarre. You're not driving that big relay directly, the relay box you bought actually has a tiny DIP SSR which is switching the power to the big relay, and the big relay is run off of the AC line. As such, there really should be no way for the back-emf generated by the relay actuating to get into your circuit. \$\endgroup\$ – Connor Wolf Jun 19 '12 at 8:49
  • \$\begingroup\$ This smells like a grounding/decoupling problem. Hoe much capacitance do you have across your power rails on the breadboard? \$\endgroup\$ – Connor Wolf Jun 19 '12 at 8:50
  • \$\begingroup\$ Also, how close is the relay box to the breadboarded circuit? Can you put a few feet of wire between the relay box and the rest of the circuit? That would remove the possiblity of any magnetic coupling. \$\endgroup\$ – Connor Wolf Jun 19 '12 at 8:51
  • \$\begingroup\$ Thanks for the responses. You're correct that the relay is decoupled with an SSR and various other components. I did try a diode, and later I tried a 220uF electrolytic capacitor between 5V & GND on the power rails near the LCD. Neither of these seemed to have an effect. I didn't (yet) try the two together. \$\endgroup\$ – Richard Russell Jun 20 '12 at 18:38

Do you have a diode across your relay? If not the inductive spikes on closing/opening will likely cause problems.

When you e.g. stop the current flowing through a relay, it tries to keep it going, if there is no route of discharge it will create a large voltage (essentially it will keep rising until it finds a route).
Specifically the formula is V = L(dI/dT). This means the inductor opposes changes in current through it by developing a voltage across it proportional to the rate of change of current.

Try placing a diode across the relay, orientated to oppose normal current flow.

EDIT - checking the product page it seems it is a "ready rolled" relay in a box with peripheral components added, so it's unlikely to be the above. Even so I would try placing the diode across the power to the relay.
Also make sure your supply is well filtered as mentioned in the comments. Place a few capacitors of at least 1uF next to the ICs and LCD, and a bulk cap of >100uF somewhere (all from power to ground)

  • \$\begingroup\$ Look at the datasheet for the "Relay". The input to the relay is actually driving a tiny SSR, which switches the actual power to the relay itself. Since the input to the relay thingie is a SSR input, I don't see a diode really doing anything. \$\endgroup\$ – Connor Wolf Jun 20 '12 at 9:31
  • \$\begingroup\$ I had a look (I couldn't find it before) and I agree, it was just a "can't hurt" type of suggestion without more info. Hopefully we'll get an update soon on how it is with decoupling added. \$\endgroup\$ – Oli Glaser Jun 20 '12 at 10:05
  • \$\begingroup\$ Thanks for the response. You're correct that the relay is decoupled with an SSR and various other components. I did try the diode, and later I tried a 220uF electrolytic capacitor between 5V & GND on the power rails near the LCD. I didn't (yet) try the two together. \$\endgroup\$ – Richard Russell Jun 20 '12 at 18:35
  • \$\begingroup\$ I also tried consciously moving the AC circuitry about a foot away from the 5V circuit, leaving only the 5V relay signal wire connecting them, but this didn't help. In my experimentation, I discovered that a small load on the relay (85W halogen lamp) doesn't seem to have much effect on the display, but if I have a large load (2000W kettle), it's more likely to cause the error. I have seen this problem with the lamp earlier, though infrequently. \$\endgroup\$ – Richard Russell Jun 20 '12 at 18:36
  • \$\begingroup\$ A ceramic cap of 1uF or so would be better for transients, add one in parallel with the 220uF. Try adding another one or two >100uF cap(s) also, across +5V and GND near the relay wires. Can you show us a better picture of your setup? \$\endgroup\$ – Oli Glaser Jun 20 '12 at 19:33

I had the same problem with a 16x4 LCD display when the Arduino was also controlling a SainSmart opto-isolated relay board. 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 a prepackaged Cornell Dubilier EMI/RFI filter for neatness, but a garden-variety 0.1 ufd capacitor in series with a 47-ohm resistor would probably work just as well.

  • \$\begingroup\$ may I see the circuit diagram on how you series the capacitor and resistor with the relay. THanks \$\endgroup\$ – Jam Ville Mar 2 '16 at 18:29

I was banging my head why my LCD is "garbled" and it turned out I haven't connect my Arduino GND to breadboard (if this is of some help to someone). Regards

  • \$\begingroup\$ This doesn't add much to existing comments. \$\endgroup\$ – David Jan 2 '15 at 23:17

use shielded cable on the output and ground it. It solved the problem for me.


Not the answer you're looking for? Browse other questions tagged or ask your own question.