digitalWrite does not trigger Relay

I'm in a prototype with a big deadline and I'm stuck on this one problem. I'm having a problem triggering relays with my mega 2560. I have 5 relays wired into 5 extension cords and the signals of the relays are digital pins 31 through 35. Also, I have a led going from pin 36 (as OUTPUT) to the ground. The pinModes are all OUTPUT that are set up in the setup() of the pde. So in total there are 5 relays on 31 - 35 and a led on 36.

When I do a digitalWrite HIGH to 31 - 36 it only sometimes throws the relays to turn the current in the extension cords on. When I digitalWrite HIGH to 36 the led always comes on bright. I know the relay lines and extension cords are set up correctly because I can pull the wires from any of the 31 - 36 and connect them to either the 3.3V or 5V port and the relays fire every time immediately.

There is something wrong with the way I'm picturing digitalWrite pushing voltage to a digital output pin. Maybe digitalWrite(HIGH) just doesn't send the right amount of voltage like a 3.3V or 5V. How do I send the right amount of voltage with a Write type function to an OUTPUT pin to ensure at least 3.3V? Or how do I throw a relay with a digitalWrite function?

Also, the relays that I am using have the following text on them "Omron", "G5LE-1A", "5VDC", "10 A 250 V AC", "5 A 250 V AC", and "2311w8"

  • Thanks, Sam

Also, do I need a resistor in the relay signal circuit for some reason? I know that the digital pins don't necessarily carry a lot of voltage and maybe I need something else in the relay signal circuit to make it more powerful.

This one? http://uk.farnell.com/omron-electronic-components/g5le-1a-dc5/power-relay-spst-no-5vdc-10a-pc/dp/5397686

with this: Coil Resistance: 63ohm?

Yes, it is that one. Are you saying that I need a resistance or something? What was your coil resistance reference to?

Do you recognise this V = IR equation?

Yes. :)

Are you saying you are driving the relays directly from the Arduino output pins?

If the answer is ‘yes’, do you have access to a spare Arduino? I predict you will need one to complete your project.

Yes. Can I not get enough V out of a digitalWrite to run this relay?

Oh, you can get plenty of V. That isn't the problem. I is more likely to be a problem. Have you tried applying that formula somebody helpfully pointed you to earlier on, to calculate how much current the relay is going to draw? And compared that to the capability of your Arduino? And have you read up on the 'flyback' effect that occurs when you abruptly stop current flowing through an inductor?

The bad news is that if you have tried to drive the relay directly, you have probably killed the output pins you used.

The Arduino output pins are rated at 40mA absolute maximum, and your relays need about 80mA. So you need to use transistors to drive those relays. You can adapt the circuit shown at http://arduino.cc/playground/uploads/Learning/solenoid_driver.pdf but for "solenoid" read "relay", and the transistor can be a small-signal type such as BC337.

After much research. I noticed that I probably fried my Mega 2560. But I have another.

I'm now on the path of finding a cheap relay shield that is compatible with the arduino mega 2560.

Do you guys have any suggestions under 100$?

Thanks for your help by the way.

dsmurl: After much research. I noticed that I probably fried my Mega 2560. But I have another.

I'm now on the path of finding a cheap relay shield that is compatible with the arduino mega 2560.

Do you guys have any suggestions under 100$?

Thanks for your help by the way.

Lots of people sell inexpensive arduino relay modules, some in shield form others as standalone modules. Be aware that some activate the relay(s) when you turn the arduino digital output pin(s) high and others activate the relay(s) when you set the output to a low. Either will work but you need to understand that to make your code work correctly.

http://www.ebay.com/sch/i.html?_trkparms=65%253A10%257C66%253A2%257C39%253A1&rt=nc&_nkw=arduino+relay+shield&_sticky=1&_trksid=p3286.c0.m14&_sop=15&_sc=1

Lefty

What do you guys think about this one. Is this a good one to buy for the arduino that will not put the arduino at risk of burning out? Can I turn all these relays on at the same time without pulling too much amps from wither the relay shield or the arduino?

I learned that there is a amperage limit that will burn the borad if the relays pull too much. Does anyone have any advise on that?

  • Thanks, Sam

Forgot to post the link: http://www.robotshop.com/devantech-usb-rly16-16amp-8channel-relay-module.html

Or this one: http://www.robotshop.com/Devantech-Serial-Relay-Module.html

dsmurl: Forgot to post the link: http://www.robotshop.com/devantech-usb-rly16-16amp-8channel-relay-module.html

If you want to drive it from the Arduino, that's not right. It takes commands from USB, which is not something the Arduino outputs (as a master). Also, it already has relays, that go to 16 A -- but only 8 volts. Thus, you'd be using relays to drive relays, which sounds quite expensive! All you need are some transistors hooked to the output pins to buffer the relay coils.

The second module is similarly not what you want, as it takes serial commands rather than Arduino pins. Now, you can make Arduino pins send serial commands, but you may still need to add wiring to boost the 5V I/O of the arduino to that serial voltage needed by the board -- I don't know how low voltage it can accept.

If I were you, I would do one of three things:

1) Get a good set of Triac (solid state) relays. Sharp has a line that does 8A / 120V and is about $8 each from Digi-Key. You can drive the trigger of these directly from the Arduino, because they don't use much current. Draw-back: you can't put more than 8 A AC current through them before they burn out, and they do need a cooling plate at that power level. (That's 1000W each, though!)

2) Get a prototype board, and solder/push some transistors in. Some nice 500mA/80V MOSFETS for a quarter each ought to do the trick. Wire the relays from +5V to the collector, wire the base to the Arduino pin out with a 1kOhm resistor, and wire the emitter to ground (if I remember correctly). That's all the buffering you need.

3) Get a more appropriate relay board; ideally one that already can drive the main power loads you're interested in. This one looks promising (as long as you don't need more than 8A per channel): http://www.amazon.com/SainSmart-8-Channel-Relay-Module-Arduino/dp/B0057OC5WK -- $26

And, most of all -- read all the specifications and run the numbers to make sure that you don't exceed any of the limitations of the devices you hook together! If you're driving a space heater or air conditioner with your mains relays, then it may very well need more than the 8A I've suggested above. If you're driving a stereo or a floor lamp or something, you should be safe.

dsmurl: After much research. I noticed that I probably fried my Mega 2560. But I have another.

It's possible you have overloaded the power supply, but more likely that you have just burned out the drivers in the specific pins you were using. You may find that other pins still work OK. In that case the Arduino isn't completely useless - unless you went round trying all the other pins after the first one stopped working. :(

the relay will not work with simply I/O pins you will have to use a proper relay module

avik_seth: the relay will not work with simply I/O pins you will have to use a proper relay module

I somehow doubt that the OP is still waiting for an answer after nearly 6 years.