The circuit below provides a simple method to detect a mains votlage input with an input range of 90 – 240V AC:

The output gives a low signal for around 90% of the time when a mains input is present, so you need to connect it to an edge detect input of a microcontroller (e.g. an irq or capture input), or add some circuitry to introduce a delay before the output can return high.  The selected opto is a high safety type for over kill and a simpler model could be used where local regulations permit. Using 2off 56k resistors on the input gives a low but good enough LED drive voltage range. The opto isolator has to be AC otherwise an external diode would be needed to protect against LED reverse voltage.

Output with 90VAC input:

Output with 240VAC input:

The 2W resistors are overkill and are not at all hot to touch (after turning power off!) at 240VAC input.

We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.


Your email address will not be published. Required fields are marked *