Relay module is active low...how to reverse that

You have linked to another discussion which contains a broken link to the product you say you have. Sort of unhelpful.

If the relay module you are using, which you could have provided a link for, has a normally closed relay on it, and it's hard to tell with the extreme lack of specificity here, you are screwed. When it is off, the relay is closed, end of story. Get a different module.

I hope that is not the case. It sounds like when there is no input to the relay module the input is floating and somehow floats to a signal level where the relay module closes the relay without there being any signal. If this is the case, the normal solution is a pull up or pull down resistor, whichever causes the module to leave the relay open. Approximately any higher value resistor will do, probably try a 4.7K or 10K one and if for some reason that isn't strong enough, use a 1K.

You use a thing called a "pull up resistor" (or pull down) to keep the voltage on the line stable during boot.

Alternatively: Use relays with optoisolators (which you should really be doing anyway).

Since the Arduino boots with all outputs open circuit, you need to find what is pulling your relay board input low on reboot and fix that. Of course, it would make it obvious to us what the problem is if you actually revealed what the relay module is, and how you have it all connected (and I mean as always, all of the connections).

Pull-ups are clearly not going to help. I strongly suspect that that you actually mean, is that the relay board is actuated when you turn off the Arduino but leave the relay board powered, since with the power off, the protective diodes will pull the outputs down to whatever the Vcc line is, which is zero if there is no power in the Arduino board.

if your relay board includes an opto-isolator - as I presume it does since almost all of those which take active-low inputs do, then you need to separate the link connecting "Vcc" to "JD-VCC" and power the Vcc from your Arduino whilst you continue to power JD-VCC from the relay supply.

Quite right, I should've included the relay module:

The relay board has an optocoupler I believe. When the Arduino digital output is LOW, the relay is energized. When the Arduino output is HIGH, the relay coil is de-energized. I am jumpering the JD-VCC to VCC. and powering the relay board's VCC from the Arduino's 5V supply. I'm only using one of the relays, so I have a digital output from Arduino to relay 4.

That is rather a poor design, yes you will get that problem.

One way to correct this is to use a transistor to switch the Vcc line to the relay board and control that transistor from an arduino output. This will give you a sort of output enable output.

Paul__B:
you need to separate the link connecting "Vcc" to "JD-VCC" and power the Vcc from your Arduino whilst you continue to power JD-VCC from the relay supply.

I had the jumper on the Vcc and JD-Vcc. I can take the jumper off and power the Vcc from Arduino and JD-Vcc from another voltage source...but does that solve the problem? The Arduino's output will still go low when it reboots, and the relay board would still be active LOW, would it not? So when the Arduino reboots (1-0-1 transistion), the relay would still pull in until the microcontroller runs the program again.

The relay is de-energized 99.9% of the time (Arduino output is 1 99.9% of the time). I only energize the relay coil for 1 second to mimic the pushing of a button.

Active High Logic Connection:

Arduino output HIGH = Relay coil energized.
Arduino output LOW = Relay coil not energized.

This should work providing the power link is
removed and you only drive one relay.
Leave IN1, IN2 and IN3 disconnected.

UNTESTED

arusr:
The Arduino's output will still go low when it reboots, and the relay board would still be active LOW, would it not? So when the Arduino reboots (1-0-1 transition), the relay would still pull in until the microcontroller runs the program again.

Someone correct me if I am wrong here, but the Arduino output does not go low when it reboots, it is open circuit and will not actuate the opto-coupler.

What does sound of interest now, is that you are powering the relay board from the Arduino Vcc. I am betting that is the problem and that if you provide a more appropriate power source for the relay board (JD-Vcc), the problem will go away.

Oh, and if the relay power supply is only used for the relay board, do not deliberately connect its ground to the Arduino ground.

Universal problem reported here but the Arduino Vcc should never be used for powering motors, relays, or other than a couple of LEDs drawing 10 mA or so.

dlloyd:
This should work providing the power link is removed and you only drive one relay.

So what happens if he wants to use the other relays, eh? ;D

My advice - find the actual problem and fix that.

Paul__B:

arusr:
The Arduino's output will still go low when it reboots, and the relay board would still be active LOW, would it not? So when the Arduino reboots (1-0-1 transition), the relay would still pull in until the microcontroller runs the program again.

Someone correct me if I am wrong here, but the Arduino output does not go low when it reboots, it is open circuit and will not actuate the opto-coupler.

What does sound of interest now, is that you are powering the relay board from the Arduino Vcc. I am betting that is the problem and that if you provide a more appropriate power source for the relay board (JD-Vcc), the problem will go away.

Oh, and if the relay power supply is only used for the relay board, do not deliberately connect its ground to the Arduino ground.

Universal problem reported here but the Arduino Vcc should never be used for powering motors, relays, or other than a couple of LEDs drawing 10 mA or so.

dlloyd:
This should work providing the power link is removed and you only drive one relay.

So what happens if he wants to use the other relays, eh? ;D

My advice - find the actual problem and fix that.

I second this, it does not go low on reset. I have this relay board in 4/8/16 channels, and I have reset/uploaded sketches countless times with the relay hooked up to my arduino, it never goes low. Try using external power for the board, if that still doesn't work, you will probably need to tell us more about your setup.

Someone correct me if I am wrong here, but the Arduino output does not go low when it reboots, it is open circuit and will not actuate the opto-coupler.

No correction required here. Pins default to inputs and so can and will float so there is no current path and the relay will not turn on.

Oh, and if the relay power supply is only used for the relay board, do not deliberately connect its ground to the Arduino ground.

I would disagree with that. You need to sing the current to activate the opto to activate the relay so you do need the arduino ground connecting to the relay board ground if it has a separate supply.

Arduino Vcc should never be used for powering motors, relays, or other than a couple of LEDs drawing 10 mA or so.

I would disagree with that as well, providing you apply sufficient decoupling you can run everything off one supply. If you don't decouple then the simple way round is to use a separate supply.

Grumpy_Mike:

Oh, and if the relay power supply is only used for the relay board, do not deliberately connect its ground to the Arduino ground.

I would disagree with that. You need to sing the current to activate the opto to activate the relay so you do need the Arduino ground connecting to the relay board ground if it has a separate supply.

You haven't been following the theme here. Read it again and recant!

Grumpy_Mike:

Arduino Vcc should never be used for powering motors, relays, or other than a couple of LEDs drawing 10 mA or so.

I would disagree with that as well, providing you apply sufficient decoupling you can run everything off one supply. If you don't decouple then the simple way round is to use a separate supply.

I said - the Arduino Vcc. The one derived from the on-board regulator (or the USB which will admittedly provide a little more power). It will not provide power or motors and the like. You are thinking of running the Arduino Vcc from a serious power supply, which is a totally different matter.

Q

Paul__B:
So what happens if he wants to use the other relays, eh? ;D

A

arusr:
...I'm only using one of the relays, so I have a digital output from Arduino to relay 4.

Q

Paul__B:
My advice - find the actual problem and fix that.

A
problem: Re: Relay module is active low...how to reverse that
Q

Paul__B:
eh? ;D

A
Who talks like that??? (I'm from Canada) ;D

You do realize that the relay switch has TWO positions. Instead of using the Normally Open position, you could use the normally closed instead. Then just change your program logic accordingly.

dlloyd:

arusr:
I'm only using one of the relays, so I have a digital output from Arduino to relay 4.

Makes you wonder - why would you get a four relay module and only use one relay?

dlloyd:
Q

Paul__B:
My advice - find the actual problem and fix that.

A
problem: Re: Relay module is active low...how to reverse that

And - as so often turns out to be the case in these discussions, that is absolutely not the problem once you get down to it!

dlloyd:
Who talks like that??? (I'm from Canada) ;D

You would perhaps prefer "Oi!"?

KenTF:
You do realize that the relay switch has TWO positions. Instead of using the Normally Open position, you could use the normally closed instead. Then just change your program logic accordingly.

Again, you need to read the thread and understand what the actual problem is. If you do, you realise that is not a solution at all!

Actually, I am getting to quite like the new forum system in many ways (but not all). I have it set to display 25 topics per index page, and 25 messages per thread. And I have - largely accidentally - got rid of the botched "WYSIWYG" reply window function.

Depending if I read correctly...

Pins revert to input on reboot, ie a floating state?.. a 10k resistor from the relay pin you're going to drive to vcc/5v.

Should keep your relay off until pinMode switches it back to output...

Geez Paul__B, relax. The eh? comment was directed at myself (how could I NOT know who talks that way) :-[

I decided to literally interpret the issue: "Relay module is active low...how to reverse that". To me "active high" is the solution to reversing active low.

The circuit I suggested is the only way I could think of that externally configures the relay's coil to energize with a digital control signal that goes HIGH. (limitations: 1 relay, untested circuit).

Really, it's what the OP requires that's important.

What's a good way to make the relay modules active high? I have an NPN transistor that I can use to flip it, but the example I find use a ULN2803, and I don't know how to take that schematic and apply it to a single NPN transistor.

Isolated power connections not shown:

EDIT: Add 10K pulldown resistor at D3 to prevent a floating condition at the transistor's base during bootup of the Arduino.

[b][u]D3[/u]     [u]NPN[/u]    [u]RELAY COIL[/u][/b] 
HIGHZ  OFF    OFF
LOW    OFF    OFF
HIGH   ON     ON

1 Like

cjdelphi:
Depending if I read correctly...
Pins revert to input on reboot, ie a floating state?

Yes, that's exactly the point!

cjdelphi:
a 10k resistor from the relay pin you're going to drive to vcc/5v. Should keep your relay off until pinMode switches it back to output...

This is what people keep on missing in this discussion. Because pins are floating on the reboot, they simply cannot be providing the current to the opto-coupler to switch the relay. Saying "add a pull-up" isn't going to "cut it" because whatever is providing the spurious current to the opto-coupler is no doubt equally capable of pulling down the pull-up. You have to figure out the cause in order to solve the real problem.

The glib suggestion of inverting the logic isn't going to "cut it" either because that will make things worse - the relay will then be switched on by the correct operation of the open-circuit pins on reset.

Out of curiosity. Do we even know WHICH input pin is being used? Would it perchance, happen to be pin 13?

"Relay module is active low...how to reverse that". To me "active high" is the solution to reversing active low.

But that changes it to default On. It isn't really active high, it is still active low, but now the output is On by default.