I'm using Arduino Mega with two Arduino relay module with 8 channels. This project is used to automate the lamps of my house (Leds), and I have two strip led lights too.
Some time when i press a button to turn on a lamp/led, the relay doen't trigger to light the lamp.
I powered each relay module with a dedicate power supply (5v).
It looks my Arduino Mega 2560 can't support all 16 relays, is it true? How do I check it?
Has anyone ever done something similar?
Post a link to the module's datasheet or the seller's webpage and a wiring diagram showing how the modules are connected to their power supply and the Arduino. What is the 5V power supply's current capability?
I think I see ground wires between Mega and relay boards.
That defeats opto isolation.
There should be NO ground between Mega and relay board, just VCC and the inputs. See this diagram.
Did you use snubber circuits on the relay contacts. Those relays will eventually fail (closed) and the software could hang if you don't use snubbers.
Leo..
Here are some suggestions to troubleshoot your issue:
Check Your Power Supply: Make sure your external power supply can provide enough current for all 16 relay modules.
Check Your Code: Make sure there are no logical errors in your code which might cause the relays not to trigger. Ensure that the relay control pins are set as output pins in your code.
Measure Current: Use a multimeter to measure the current drawn by the relay when it turns on. Ensure it's within the 20mA limit.
Optoisolation: The Arduino relay modules often have optoisolators that can be used to isolate the Arduino from the relay coil's power circuit. If your relay module has those, ensure you're using them, and correctly.
Interference: Long wires running from the Arduino to the relay modules can also cause issues, notably if they pick up electrical noise from the surroundings. Try to keep wires as short as possible, and where that's unavoidable, consider using shielded cable.