01-02-2016, 11:23 AM
Yes, I've used optocouplers for this sort of thing. The LED in even the most basic types is reasonably sensitive, so you can get away with just a couple of milliamps. For simplicity, I'd just use a diode and resistor (~150k) on the mains side (and an inverse parallel diode across the LED in case the series diode leaks). The transistor will be switching off 50 times a second, but a cap in parallel with that works well. A pull-up resistor charges the cap in the absence of mains, and a Schmitt CMOS input takes it from there.
I use optocouplers in unexpected situations - sometimes they are just can be the easiest/cheapest way to level-shift...
I use optocouplers in unexpected situations - sometimes they are just can be the easiest/cheapest way to level-shift...







