Using same power supply to drive relay and Arduino

I've searched for a while but didn't see that kind of setup.

My power supply is 5V 500mA switching power supply that is connected to my Arduino Nano via USB.

I have 2 modules with 2 5V relays each that have optocoupling and ability to be powered from external power source.

Only 2 out of 4 relays that are on the seprate boards are on at the same time (didn't see any DPDT relay modules).

My question is that can I somehow power Nano and the 2 relay modules from 1 power source?

My idea was to make 2 splices from the power supply and connect 1 USB connector and 2 raw cables to the modules but I don't know if that is viable.

You have to try and find a data sheet for those relay module to know what their low side current consumption is.

The basic relays (that is without the driver circuit, LED opto coupler etc.) appear to require about 100 mA if it is the same as here: relay

If that is the case, and depending on what nano you have (clone or original), you may just get away with powering the whole thing from the +5v pin on the nano.

Yeah that's the module, I tested them and 1 relay takes around 50mA. For some reason I thought that you can only take 40mA from 5V pin.

Thanks.

The +5V is not the same sort of 'pin' as pins D0, D1,D2 .... A0, A1 etc. which are switched by the microprocessor. Yes, with those pins your are restricted to an absolute maximum of 40mA.

The relay module will have a power supply input and a trigger input. I guess you measured the current consumption at the power supply input. The trigger input should require only a few milliamps, mainly for the optocoupler Led.

The 5volt relay module posted uses about 75-80mA per relay (when active).

A relay input requires 2mA drive current (sink) from an Arduino pin (LOW=active).

If you use a single supply to power the relay module and the NANO (splicing), you loose opto isolation.
Opto isolation requires two individual supplies.

Don't power the relay boards from the 5volt pin of the Nano. You will burn out the USB reverse protection diode quickly.

Writh a HIGH to the pin BEFORE you set the pinMode to OUTPUT.
That stops those modules from chattering during bootup.
Leo..