I'm new on this forum, I'h planning to deploy a lights home automation and need some help about how to calculate the resistors and capacitors associated to a PcF817 optocoupler in order to get 5V at output when 220V is applied to a lamp through a switch. here it is a basic block diagram.
here it is the circuit that I'm planning to use.
I'll appreciate and colaboration. Regarys.