Introduction: How to Sense 220 V
For switching 220 V there are nice solutions already, including using a 5 dollar remote switchable plug and control it with arduino and a 433 Mhz module.
But how to sense with a microcontroller, if a 220 V device is under power or not?
Step 1: An Optokoppler Is the Way ...
The best solution I could find is using some kind of Optokoppler. But lightening a LED with 220 V is not so easy. it involves a handful of electronic components, which all have to be soldered togeter. On top of it, I see some problems with some circuits available for this task.
Step 2: An Optokoppler Based on a Neon Indicator Lamp
The better solution to me is using a neon indicator lamp.
On the "other side" I have choosen a photo transistor. The capacitor is very important because the system reacts so fast, that it even transports the 50 Hz (or 60). So without capacitor if you sense the signal in the wrong moment, it might falsely give you an "off" signal, because the 220 V sinus was at a low in that moment.
Step 3: Filter Surounding Light
The heat shrink tube does not filter light very well, so it is important to wrap the whole selfmade optokoppler in aluminium foil (and then maybe put it all in another layer of heat shrink tube, to keep the construction durable).
Step 4: Standard Servo Style Connections
By the way: I love to have standard servo style connections, as many actuators and sensors just need +5V, GND and signal, and I found a way to change the standard arduino connections to this. I combine pin headers from wire wrap with usual pin headers.