For a home automation project, I want the 3,7-Volt-signal of a motion sensor (or an Arduino) to switch on a 220-VAC-device. On this forum, I found this old discussion http://forum.arduino.cc/index.php/topic,24335.0.html with the schematic in picture 1. I am rather new to this but it looked like a safe solution for the problem. So I copied the circuit in Eagle and made the PCB (see pictures 2 and 3 below). I connected it to the motion sensor, the mains 220 VAC and a 35 mA LED-lamp (picture 4). With the motion sensor on, the lamp is shining all right, as expected.
But with the motion sensor off, the lamp is blinking with a frequency of about half a second. Even with the motion sensor disconnected, no digital input, this blinking occurs. I expected no current to the lamp without any input to the MOC3041 optocoupler. Can anybody explain why this happens?
Nope, can't spot the fault just now, but you have a dangerous blunder in the PCB pattern design; you have a trace passing under the MOC3041. You should never have a trace under the optocoupler, in fact the PCB should instead be slotted under it and for at least 5 mm on either end. The trace should instead have been run under R3.
That said, there is no obvious answer to your problem - the circuit should work just fine; either there is a defective component (cheap eBay?) or you have dirty (wet; conductive) flux between critical points.
The way to think about the circuit board layout when using mains is
to make sure an ant crawling over it cannot create a bridge between
mains and non-mains. Thus the slot and large spacing between high and
low voltage sides of the board.
Instead of creating a custom circuit board it will be cheaper and perhaps safer to use a logic level SSR (solid state relay). These are readily available with opto isolation for the logic level switching and can switching inductive or resistive loads at just about any desired power level. All in a nice safe and easy to use package.
Here is an example of some of those available (I like Crydom for these)