When power OFF Arduino, it triggers all 12V relays On.

Hi,

I use Arduino Mega and 12V 16-channel relay (Sainsmart). Arduino and Relay are powered by different batteries.

The relay is used for controlling several pumps and solenoid valves.

While I was testing the system, I disconnected 5V power for Arduino. Then, suddenly, all 16 relays were turned on. I need to prevent this unexpected behavior because the system will be installed in a remote area.

Simple solution I can think of is to connect a single channel relay. So, this new relay can supply 12V to 16-channel relay only when Arduino has power. However, it means that I need to turn on the single channel relay whenever one or several of 16-channel relay run. My system is run by a solar panel.

Is there any other method you guys can think of?

Thank you in advance for your help.

D

If you are using a relay card you will likely have changeover relays. Ie.:

N.O - normally open and N.C - normally closed connections.

You should look at connecting your pumps to whatever side of the relay is off in the 'no-power' situation you mention.

Then change your HIGH's to LOW's and vice versa in your code so that the pumps come on when you want them to.

Dan

danlay:
You should look at connecting your pumps to whatever side of the relay is off in the 'no-power' situation you mention.

Except that then, all outputs will turn on when the Arduino is in reset!

The schematic for that relay board is confusing. It suggests the input array has the same 5V supply connected to it as powers the relays. In that case it would not actually be opto-isolated at all. Check to see if that is the case.

In any case, the "5V" on the input connector must be connected to your Arduino 5V. There is no alternative. If that 5V is not internally connected to the 5V which operates the relays, you are winning and th3 "GND" on the input connector must not be connected to your Arduino.

Paul__B:
Except that then, all outputs will turn on when the Arduino is in reset!

No, Arduino pins are high-impedance on reset. You should use NO and COMM unless
there's a need to have the circuit closed when the relay board is powered down. You
only want to waste power in the relays when the load is on normally.

Indeed Paul__B.
Incomplete and confusing documentation, no resistor values, and it seems that the onboard switching 5volt supply feeds the opto transistors as well as the opto LEDs.
Opto isolators are now like tits on a bull.
It needs cutting and joining several circuit board tracks to fix this.
Leo..

MarkT:
No, Arduino pins are high-impedance on reset.

Precisely! So that is why I was explaining that the "fix" suggested, to use the NC contacts on the relay, will result in all the connected devices being turned ON during reset.

MarkT:
You only want to waste power in the relays when the load is on normally.

Quite so. So what was suggested, is not a good idea.

Hi,
When you removed power from the arduino, did the relays turn ON then OFF?
Or turn ON and stay ON?

Tom... :slight_smile:

They will turn on if the power is removed from the Arduino because the protective diodes to the Arduino pins pull those pins down to the supply voltage which has been shut down.

Most of those "China" relay boards use low-true logic, you pull the input low to energize the coil, some have a Berg jumper to switch the coil supply from local to remote but no telling where the opto isolator led supply is coming from. These things are potentially dangerous for newbies trying to switch mains voltage.

I would use a failsafe master relay controlled by an output on the controlling board to interrupt the coil supply.

Both 8-ch and 16-ch relay boards have low-true logic.

The only difference is that the 8-ch board gets 5volt opto LED power from the Arduino.
And the 16-ch board is self-powered.

When Arduino is powered down, the 8-ch board optos don't get supply.
But the 16-ch board lights up all the optos, because all Arduino outputs are low.

Those 8-ch boards draw 2mA per opto, so it's no problem to use several 8-ch relay boards.
Another drawback of that 16-ch board is that it is NOT opto isolated.
Leo..