FWIW, I recently discovered a Fairchild MID400 AC Line Monitor. It’s ideally suited for sensing the presence of AC voltage in a circuit. Due to its design, the MID400 doesn’t switch fast enough to turn on/off with the 60 cycle line frequency.
By properly sizing the resistors on the input (do your wattage calculations to avoid cooking your resistors like my first test!), you can safely and efficiently measure the presence of line voltages. I had previously used simple relays for isolation, but got concerned about the inefficiency, size and cost of this approach. On the output side of the device, I tie Vcc to 5Vdc, which I have readily available. I then tie Vo to 3.3 through a pull-up resistor and tie Vo to my imp input pin that is configured as a digital input. The logic state is reversed. In other words, you’ll get a 0 when voltage is present on the input and a 1 when voltage is not present. I’m pretty sure I used a 10K for the pull-up resistor (kinda my standard practice).
I’m using a 8.2K 2 watt on each leg of the input, but could (should?) have gone with a higher resistance.
Depending upon how you wire this up, be sure to insulate well (I used liquid tape on my board) to avoid getting a line voltage “surprise” if your fingers touch the wrong spot!
I’ve benefitted so much from this forum that I thought I’d share this experience.