Controlling AC light using Arduino with relay


Joined Apr 24, 2011
You can find relays that work at 5 volts, or the same supply as the Arduino uses. That means just one supply for both units. Lower voltage relays need more current than a similar higher voltage unit but not excessively so, the same transistor could run either. The 4.7K resistor is a tad too large; I'd prefer something like 1K there especially for a 5 volt relay. (that is a guesstimate, I would not buy anything until I chose the relay first.)

Full disclosure: I don't use those boards but as far as I know they run off 5 volts.


Joined Apr 12, 2016
The module shown has an optical connection for isolation of the arduino. This is why it does not require a ground connection to the relay module.
Your sketch would require a connection from the arduino to ground of the transistor and provides no isolation of the arduino.

ian field

Joined Oct 27, 2012
Please tell me the major difference between these two.
The pictorial one has what looks like optocouplers on the PCB.

The relay on its own should provide adequate isolation - but the opto is a lot more safety margin.

Can't see anything wrong with the schematic version - but if the ready made PCB makes your MCU go phut, you can blame someone else.