Arduino mega can't handle relays? (blynk controlled but probably hardware issue)

Hi,
In my project I control 5 relays with buttons in the blynk app.
But most off the time when I switch one, the hardware disconnects!

I am using an arduino mega, and a WW5500 ethernet module.
Everything in the project worked fine, till now.

This is the code that controls the relays (its the same for all the other relays):

BLYNK_WRITE(V61) {
  relay1_state = param.asInt();
  digitalWrite(relay1, relay1_state);
}

But I thing it is a hardware issue...

I hope there is a solution.
Isaak

How much current can the Mega supply from a pin ?
How much current does a relay take to operate ?
Are the relays powered from the Mega ?
The voltage regulator on the Mega can only supply a limited current
How many relays are there in total and what is their total current consumption ?

What relay modules are you using?

Thanks for the quick replies!

I am using this relay board.
The relays are powered by a separate power source (12V 1A converted to 5V with this module).
They work by pulling the pin to ground, so LOW means that they are closed.

I have no idea how much power they draw... but if you want i can measure it (not easy, its build in somewhere).

Isaak

OK, so that is a fairly standard relay board.

You are presumably using two of them for five relays.

Each actual relay requires 90 mA at 5 V when actuated, so five will be 450 mA. OK so far. Here is the circuit:

Remove the jumper. Connect ground and "JD-VCC" to the 5 V regulator by a pair of wires - bundled together. I suggest a 220 µF or greater capacitor across the supply.

Connect the "IN"s and "VCC" but not ground to the Arduino via ribbon cable. With that 1k resistor to the optocoupler, it takes only 2 mA to switch the relay module.

You should not be powering a Mega 2560 via "Vin" or the "barrel jack" for a serious project, especially with an Ethernet module. You should be able to power it from your 5 V 3 A(?) supply via a separate pair of wires bundled together to "Gnd" and "5V" (but you are supposed to disconnect the "5V" when connecting to a PC via USB).

Thanks for the reply!
What do you mean by optocoupler? is it some kind of transistor?
Edit: I don't have one of those...

Isaak

The optocoupler is the component "U1" on that circuit for (each section of) the relay module. It electrically separates the signals you use to control the relays (2 mA) from the current used to actually operate the relay (90 mA). Look it up on Wikipedia.

Ah thx, but I already did it with transistors...
Is there some kind of delay when posting in different countries? Because your poste came late but the time above your post is not that long after mine...

Isaak

Thanks for the help tho!

If you have set the time zone correctly, you should see the times correctly for each post including your own. I posted some
nine hours and 19 minutes after yours, it shows as 09:17 in my time zone and almost the same time as I am posting now (and I really should be at work :astonished: ).

Check that the time is correct on your message(s), if it does not appear to be you need to correct your personal information on the forum.

Paul__B:
If you have set the time zone correctly, you should see the times correctly for each post including your own.

How...

Location settings in 'profile' don't do anything.
Leo..

Wawa:
Location settings in 'profile' don't do anything.

Works fine for me!

Profile ==> Setting ==> Look and Layout ==> Time zone

Yes, I can set the time zone
The time zone is set correctly, but "Local time" on the summary page is 12 hours behind.
Shows Mar23 9pm, while it's here Mar24 9am.
"Last active" shows 9am though.
Leo..

Wawa:
The time zone is set correctly, but "Local time" on the summary page is 12 hours behind.

Noticed that. Clearly a bug, but the timestamps on posts are correct. Go figure! :roll_eyes:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.