How can I detect a power outage with a microcontroller?
I'm doing some research with the goal of eventually creating a light dimmer controllable from a micro controller. I've figured out how to do the dimming of the light and now I need a zero cross detection circuit that I can use to determine when to phase shift the AC power.
I have a few opto-couplers which should do the trick. However (and this is my question), it appears that the AC side of the circuit takes around 1.7V (assuming I'm reading the datasheet correctly). How do I get the line voltage down from 120V to 1.7V. I assume that I could use a high value resistor, but wouldn't this generate too much heat? Seems to me like it would just fry the resistor. I'm pretty hesitant to just try this as I enjoy having all of my fingers attached.
I've seen people discuss connecting the line voltage directly to the micro controller through high value resistors here, which seems like a pretty bad idea.
To summarize my question: How can I connect AC line voltage to my opto-coupler? And if that's done with a resistor, how do I determine the correct ohms/watt rating to use?