Arduino On a breadboard using SMD 328P AU and 328P PU relay connection issues

I am using arduino on a breadboard schematic provided by Arduino's website for the normal IC :


And for the SMD IC I am using this circuit:

Using this kind of 8 channel relay board :


And I have successfully programmed them but the problem is when:

CASE 1: Arduino on the breadboard for both AU and PU ICs(Powered by wall socket with no loads and phase(240) applied to the relays)
I power it through a wall socket adapter (5V,1A) sufficient for my home automation project the IC starts behaving abruptly as soon as I turn on any switch from the board to which the socket is hooked up.(while no physical contact is made between the arduino except for the wall adapter) What happens is various relay pins start to toggle and i an matter of seconds serial communication and GPIOs freeze.

CASE 2: Arduino on the breadboard for both AU and PU ICs(Powered by USB with loads and phase(240) applied to the relays)
I power it through laptop via USB (5V) sufficient for my home automation project the IC starts behaving abruptly as soon as I turn on any relay by sending data serially to the arduino. What happens is various relay pins start to toggle and in a matter of seconds serial communication and GPIOs freeze and become not responding.

Every thing works fine when connected to the arduino(UNO) itself. Please tell me what should I add to my breadboard circuit to make is safe against what ever is causing this abrupt beahviour.

I don't see any 100nF caps across Vcc and GND and AVcc and GND on the breadboard.

How is the relay board connected to the Arduinos?

What happens if you power the breadboard from 3 new AA cells?

...R

Robin2:
I don't see any 100nF caps across Vcc and GND and AVcc and GND on the breadboard.

How is the relay board connected to the Arduinos?

What happens if you power the breadboard from 3 new AA cells?

...R

Trust me in both the cases I am using 100n caps for both AU and PU.
Relay board is powered by the 5V external supply , the same supply powering the arduino. So they share common ground.

Tried with arduino uno works fine for all its the bread board circuit thay troubles me freezing the ic after enormously switching relays on and off. Be it USB or battery or a wall adapter to the Vin pin.

MrJkComedy:
Tried with arduino uno works fine for all its the bread board circuit thay troubles me freezing the ic after enormously switching relays on and off.

This sentence is garbled. I'm not sure what it was intended to be.

...R

Hi,
If you are going to use a large relay board, why are you going to SMD construction, where it appears you will have enough space for a 20PinDIL 328 construction.

Also where are the 2 caps that should be associated with the crystal?
Where on your SMD diagram is the I/O that you have on the protoboard, and where are the relays connected?
Where is the press Button and where is the Green LED?

We need a COMPLETE circuit diagram please.

Have you loaded very simple sketches, each sketch just testing each facility of your circuit.

First I would be loading code THAT ONLY blinks the LED.
Second code THAT ONLY controls your LED with the Button?
Third code THAT ONLY blinks the LED in programmed response to your various serial inputs.
Like one input instruction causes the LED to flash once a second
Another input makes the LED flash twice, pause them flash twice again.
Fourth THAT ONLY turns on the relays in sequence.
etc,

It might sound tedious, but trouble shooting can be, and unless done systematically can take a very long time.

Tom... :slight_smile:
TIP: Using your DMM monitor the 5V power supply while you do your checks, as any drop in 5V will almost always cause a controller reset, and you may think its another software fault.

Robin2:
This sentence is garbled. I'm not sure what it was intended to be.

...R

I meant when I use the arduino Uno board everything works fine with the relays under load and when I use the arduino on the breadboard circuit everything works only when the relays are not connected to the load once I connect the load let's say a bulb the breadboard circuit stops responding after one or two seconds.

TomGeorge:
Hi,
If you are going to use a large relay board, why are you going to SMD construction, where it appears you will have enough space for a 20PinDIL 328 construction.

Also where are the 2 caps that should be associated with the crystal?

Both smd and pu show the same problem with the relays under load. Everything works fine for days if I just connect the relays without connecting them to 240V loads.
I am using 22pf capacitors to ground with the crystal. I am using D5 to D12 for the relays output..

TomGeorge:
Where on your SMD diagram is the I/O that you have on the protoboard, and where are the relays connected?
Where is the press Button and where is the Green LED?

We need a COMPLETE circuit diagram please.

Have you loaded very simple sketches, each sketch just testing each facility of your circuit.

First I would be loading code THAT ONLY blinks the LED.
Second code THAT ONLY controls your LED with the Button?
Third code THAT ONLY blinks the LED in programmed response to your various serial inputs.
Like one input instruction causes the LED to flash once a second
Another input makes the LED flash twice, pause them flash twice again.
Fourth THAT ONLY turns on the relays in sequence.
etc,

I need to take it to a PCB so I bought the IC socket programmed it to the SMD one. Then I checked it with the DIP IC 328P PU, which failed exactly the same way. As I said I can go on for days with relays not under load so uploading blinks and other sketches is not the thing i should do as off now. I initially checked it all. Once I bootloaded the IC the first thing I did was uploading the blink sketch just like anybody would do. After that I uploaded my sketch, all works fine and I say that again: ONLY AND ONLY 240v to the relays causes some voltage spikes to 5v or something similar that stops the serial communication and also stops anything that the arduino is doing.. It doesn't reset it. It just freezes. I am amazed that arduino uno( the board) has no problems but the bread board circuit has even when everything is connected just the same way as said on the Internet for programming both the ICs.

Also I am bypassing the bootloader after I burn it to the IC for the first time. I am uploading it using ARDUINO UNO as a programmer.( Pressing Ctrl+ Shift+U)

If anybody could help me I am having exactly this kind of problem aa mentioned in this thread.

But no solution seem to be found. It's says sone decoupling problems . If that is the case please tell me how to rectify it.

What kind of loads are you switching. Resistive, inductive.
You might have to use snubber circuits or MOVs to kill inductive spikes.

That relay board has opto couplers, both for safety and electrical isolation.
But it seems you're not using them.

You need two supplies for optical isolation.
One for the relay board (5volt/1Amp), and one for the Arduino circuit.
Relay supply connected to JD-VCC and ground of the relay board (jumper removed).
Arduino's 5volt connected to VCC (not JD-VCC).
Eight outputs connected to the relay inputs.
DO NOT connect relay ground to Arduino ground.
In void setup(), digitalWrite the pins HIGH before making them an output with pinMode.
That stops the relays chattering during bootup.
Use inverted logic (a LOW is relay "on").
Leo..

Yes, I agree. The problem is with contact arcing and the lack of arc suppression and opto isolation. Here's how to connect the relay board to use the opto-isolation feature:

Wawa:
What kind of loads are you switching. Resistive, inductive.
You might have to use snubber circuits or MOVs to kill inductive spikes.

That relay board has opto couplers, both for safety and electrical isolation.
But it seems you're not using them.

You need two supplies for optical isolation.
One for the relay board (5volt/1Amp), and one for the Arduino circuit.
Relay supply connected to JD-VCC and ground of the relay board (jumper removed).
Arduino's 5volt connected to VCC (not JD-VCC).
Eight outputs connected to the relay inputs.
DO NOT connect relay ground to Arduino ground.
In void setup(), digitalWrite the pins HIGH before making them an output with pinMode.
That stops the relays chattering during bootup.
Use inverted logic (a LOW is relay "on").
Leo..

I am using resistive loads I have made a dimmer with triac and a snubber for the inductive loads. I am not using the isolation but the JDVCC and VCC are shot together. So it is low triggered. As I am powering it up from a single supply I thought it would be use less to do so.

The problem is persistent when I power the arduino (with no loads on the relay ) with a linear 5V circuitry powered by a 12V wall socket adaptor. As soon as I turn something on the switch board to which the wall socket adaptor is connected arduino starts to misbehave and freezees. Let's say I speed up the fan by moving the fan regulator up to 5 the circuit picks I don't know what through the adaptor and switches on some relay and then freezees in a second. This problem is only when I use breadboard circuit and not with the real arduino board.

@ dlloyd
Glad you chimed in.
I like your diagram, but don't want to use it without your permission.
Leo..

dlloyd:
Yes, I agree. The problem is with contact arcing and the lack of arc suppression and opto isolation. Here’s how to connect the relay board to use the opto-isolation feature:

Hey, Thanks for the reply but the problem is when I power up from a wall socket adaptor it freezees by any change in the switch board that its connected to. Relays work fine arduino board uno isolated or not. Problem is with the breadboard circuit.

MrJkComedy:
As soon as I turn something on the switch board to which the wall socket adaptor is connected arduino starts to misbehave and freezees. Let's say I speed up the fan by moving the fan regulator up to 5 the circuit picks I don't know what through the adaptor and switches on some relay and then freezees in a second. This problem is only when I use breadboard circuit and not with the real arduino board.

The layout of that breadboard seems horrible to me.
Ground/power takes a big detour, and no HF decoupling.
You should power the Arduino with a modern switching supply, like a 5volt cellphone charger.
Then you can dump that whole analogue regulator part.

As said, that relay board should be powered with a different (5volt/1Amp cellphone) supply.
Leo..

@Wawa ... its for everyone to share.

Relays work fine arduino board uno isolated or not. Problem is with the breadboard circuit.

The breadboard circuit would be more sensitive to noise, EMI, RFI. Does the problem go away if the 240V load is disconnected?

Oh, you might find this interesting ... look at table 2.

Wawa:
The layout of that breadboard seems horrible to me.
Ground/power takes a big detour, and no HF decoupling.
You should power the Arduino with a modern switching supply, like a 5volt cellphone charger.
Then you can dump that whole analogue regulator part.

As said, that relay board should be powered with a different (5volt/1Amp cellphone) supply.
Leo…

i know how the optional opto coupler circuit works the led leg gets ground from the low triggered pin which sends the signal further to switch on the relay. That is not the case.
5V relays 5V arduino same power supply. But the case is load 240V when connected not arduino board uno but the breadboard circuit miss behaves.
Works well with UNO.
Tried it with the 5V adaptor. SAME issues.

dlloyd:
@Wawa ... its for anyone and everyone to share.
The breadboard circuit would be more sensitive to noise, EMI, RFI. Does the problem go away if the 240V load is disconnected?

Oh, you might find this interesting ... look at table 2.

Yes no problems if powered by the USB from laptop and +ve -ive to breadboard with no loads.But with wall socket adaptor same issue if something on the switch board is switched on or off while the adaptor is plugged in, the circuit freezes after a series relays triggered on and off. All happens with in 1-2 seconds and then it freezes.

Try Wawa's suggestions (I think you'll be pleased with the result).

The separate supply and opto isolation will eliminate noise/spikes through the common ground and 5V rails.
The MOV or snubber circuit will reduce emissive interference by reducing relay contact arc.

dlloyd:
Try Wawa's suggestions (I think you'll be pleased with the result).

The separate supply and opto isolation will eliminate noise/spikes through the common ground and 5V rails.
The MOV or snubber circuit will reduce emissive interference by reducing relay contact arc.

It's a bit confusing on my part I'll clear that again.I am making a PCB how can I have two supplies?
A wall socket adaptor powers 5V to arduino. The same wall socket adaptor powers the relays. They have a common ground isn't it?

MrJkComedy:
It's a bit confusing on my part I'll clear that again.I am making a PCB how can I have two supplies?
A wall socket adaptor powers 5V to arduino. The same wall socket adaptor powers the relays. They have a common ground isn't it?

You should have two supplies.
And the grounds should NOT be shared.
If you do, you won't have opto isolation.
Read the posts again.
Leo..