20*4 LCD errors after relay turns off 200vac device

Hello everyone,

i'm an amateur in electronics and i hope i'll be clear enough so that you'll be able to understand my problem. Please let me know if you need more information.

I'm using an arduino mega 2560 to turn on and off a 220vac device (pump, light) connected via an opto-relay.
(here is the relay board : http://www.ebay.fr/itm/8CH-5V-Module-de-relais-pour-Arduino-Shield-Conseil-PIC-AVR-MCU-DSP-ARM-Bleu-/151186014451?hash=item23336380f3)

I've attached a basic schematic of my setup and the code i'm using (basic liquidcrystal example "hello world" and the on/off command).

After few cycles, the lcd starts to become crazy and writes symbols only.
i've tried :
-use separated psu and different combinations
-powering the relay board with the same +5V than the arduino
-powering it up with a different psu
-use capacitors and diodes at different points on the circuit to protect each device
-replace every cable i had at the beginning
-put the electronic parts in a metal box

The thing is, every other tasks, codes, works fine.
The arduino, relay board, and serial monitor seems to continue his work after the LCD goes insane.
If I want to do the same thing with DC devices (motors for example), everything is fine.

I've applied most of the solutions i could find on various forums. Nothing solved it.

So...... Please help....... :cry:

code.txt (651 Bytes)

I turned around a long time with such problems, until i used some clean soldered connectors instead of a bredboard...

This is a very common problem described here.

On that relay board, Vcc must absolutely not be linked to "JD-Vcc", otherwise you have no isolation at all.

First try - a 47 µF capacitor connected between pins 1 and 2 on the LCD.

Other than that - "lead dress" is critical - all wires must be paired, parallel - and - logic wiring, relay power and mains wiring kept carefully separate.

If this is what you are using as a battery:

then give up now!

Get a proper battery. Start with a pack of six "AA" (not "AAA") alkaline cells.

Your schematic does not show a common ground between your two power supplies.
You need to connect the grounds (common ground).

Your display is not I2C ?
How is your display lcd wired? May need some more power and or more caps.

I turned around a long time with such problems, until i used some clean soldered connectors instead of a bredboard...

I've tried with a small prototype board but it didn't work for me...

The VCC is linked to the vcc pin near the 8 digital inputs. i've unplugged the jumper originally on JD-VCC and put my wallplug +5V on JD and the ground on ground...

First try - a 47 µF capacitor connected between pins 1 and 2 on the LCD.

I'll try the 47uF capacitor, which type would be best?

Other than that - "lead dress" is critical - all wires must be paired, parallel - and - logic wiring, relay power and mains wiring kept carefully separate.

I'm using wires from a starter kit for the moment (for logic and DC +5V/Gnd).
Should I use something else?

Get a proper battery.

I'll change my 9V battery for a six-battery pack. For my knowledge, why are 9V batteries bad for this ?

You need to connect the grounds (common ground).

i haven't connected the +9v and +5V grounds because, if I understood it right, the purpose of those 2 PSUs is to isolate the relay power from the arduino power. Am I wrong?

Your display is not I2C ?

No it's not, it's plugged directly via digital pins (RS, E, D4, D5, D6, D7).
Have tried to power it with strong PSU but nothing changed.

Absolutely not!

That is the one thing you must not do with an opto-isolated relay board.

cybergogo:
The VCC is linked to the vcc pin near the 8 digital inputs. i've unplugged the jumper originally on JD-VCC and put my wallplug +5V on JD and the ground on ground...

100% correct. As I explained.

Actually, they may possibly be connected, but with the utmost of care regarding the routing of wiring, as I made a point of explaining.

That is the tricky part which unfortunately, is difficult to explain in text (and I do not have any pictures to illustrate).

I've seen on the forum that RC snubber could be a solution.
Or do you think SSR relay is a better way to get rid of this problem?

@Paul__B, "That is the one thing you must not do with an opto-isolated relay board."
Is that just for this particular board, or as a general rule for all opto-isolated relay boards ?
I don't understand then. If you send a signal to the relay board (eg In2), you need a return path. If you don't hook the Gnd pin on the relay board to the ground of the arduino, then how do you get a return path for the signal ?

I could understand it if they had a In2High, and In2Low, but I don't see that on the board.

I design products that turn on/off motors. Typically for ventilation, sometimes pump motors. Curtain actuators. AC motors. 18 years at the current company.

We use a snubber across relay contacts. Typically 0.01uF 400 volt in series with a 1K 1/2 Watt carbon comp resistor. Not metal film resistors. We also sell self contained snubber for installation on higher power contactors that are external to our controls. The relays we use on our products are rated for 1HP.

So that helps. After that the way cables are routed is important. Be it external power cables or internal wiring. And the internal routing of wiring, the traces on circuit boards. That is where I come in. Because our products have to be reliable.

It is hard to give you an answer without seeing what you have done. How you have built your device. Unfortunately I don't have the time to tell you all the things to do and what not to do. (my lunch break is over)

@OP, "I'm using an arduino mega 2560 to turn on and off a 220vac device (pump, light) connected via an opto-relay."

Does your problem occur only when driving inductive loads? Does it also appear when driving filament light bulbs ?

You may get better results using a electronic relay system. Do you have one on hand to test?
I believe they will switch on and off, near the zero crossing voltage, and not at 300 volts.

Yes and no.

In many of these boards, the opto-isolators share a common positive rail rather than a negative. As you will notice in the diagram given, the positive return, not ground, then must go back to the Arduino and the code must initialise HIGH rather than LOW as noted in this recent problem (which I see has also puzzled you :grinning: ).


The clue to this arrangement is the "Vcc" to "JD-Vcc" link on the module.

Yes, I must have been puzzled by
@Paul__B, "That is the one thing you must not do with an opto-isolated relay board." (share the grounds)

While I think you meant to say:
"In many of these boards, the opto-isolators share a common positive rail rather than a negative.".

Is it never acceptable to share both ?

I think what we are trying to isolate from is the coil of the relay, rather than the 300V on the contacts of the relay (the relay does that for us). There may be some RF from the 300v and relay contacts, but no direct wiring.

If you design it well. But in that case, the opto-isolator is no more than a glorified transistor.

You would think so, but if is frequently claimed that it works just fine until you connect the mains load.

Not so much RF, but electromagnetic impulse coupled by stray capacitance and evidently, inductance when lead dress is not followed.

A common misunderstanding is that the "snubber" diode must be mounted close to the relay in order to contain the impulse. This turns out to be dead wrong! You see, the diode simply causes the current in the relay coil not to change rapidly. The sudden change in the current flowing appears in the switching transistor and power supply, so the diode should mount between the switching transistor and the adjacent supply capacitor so that on switch-off the current transfers from one to the other.

The voltage change appears across the whole wire between the switching transistor and the relay coil, but this is limited in magnitude to the supply voltage plus the diode drop - that is the reason why the diode is there after all.

Not wanting to cause a never ending discourse about this, I think we should just agree to disagree on this thread.
I look forward to your insight on the next thread.

I disagree with both theories.
First of all - the D1 diode does not control the "on rush " current when the controlling transistor is turned on connecting one side of the relay coil to ground. It is reversed to carry any useful current.For all practical purposes , the current flows thru the relay coil only and is under control of the controlling transistor.

The diode original function AKA "snubber diode" is to safely SHORT the reverse EMF to ground - under "normal" conditions when the relay coil is de- energized. .

Since the controlling transistor is turned off thus presenting high resistance between the diode anode and ground - the diode CANNOT function as short ( to ground) for the REMF.

The diode in this circuit has absolutely no function!

To be useful the anode needs to be connected DIRECTLY to ground, not via control transistor.
Adding REVERSE polarized / mounted diode directly across the Vcc power supply would provide SOME functionality, however, the REMF should be send to ground as close as possible to the source of the REMF - the relay coil - as someone mentioned already.

As far as controlling 220 AC I would check the actual label on the blue (?) relay.
I think it is rated MAX 2oo V DC. And relays usually have different rating for DC or AC.

Hi all,
Just to keep you updated.
I had to buy several parts to make some tests.
I'll be back to you asap and hopefully be able to close this thread :slight_smile:

Just another thing, i've my arduino that also resets when i plug or unplug a device on my powerstrip.
If you have any ideas on what could be the reason of this please let me know.

See you soon !

Okkkkaayyyyyyy Sooooooooo.......

@Paul__B
I've tried the 47uf capacitor on the lcd's pin 1 and 2, it doesn't work.
i've tried the lead, sorted by type wiring, it doesn't work.
I've tried the 4*1.5V AA batteries instead of the 9v battery, it doesn't work.

@ Rudy216
I'm still waiting thr the capacitors and resistors delivery, this is my last hope...

@jack wp
It happens under every type of load.
What kind of electronic relay should I use?

@Vaclav
Here are the relay specs : 10A 250VAC 10A 125VAC / 10A 30VDC 10A 28VDC
Isn't that enought?

Please tell me if you have any other suggestions.
Every help is welcome. :slight_smile:

"Just another thing, i've my arduino that also resets when i plug or unplug a device on my powerstrip.
If you have any ideas on what could be the reason of this please let me know."

Is your powerstrip at the end of a long (small) extension cord? Any unusual setup of your AC power? BTW, I assume your AC is 220v ac ?

Yes it's at the end of a 1 or 1.5meter extention cord. nothing unusual in my ac setup. it's 220vac yes