AC main detector module – ElectroSchematics.com

This is the photograph of a common, cheap eBay module called a “220V AC Mains Sensor”. You can see the reverse-engineered schematic of this module below. Needless to say, this is a redesigned and tested version from my lab.

MB6M Datasheet https://www.vishay.com/docs/88660/mb2m.pdf

PC817 Datasheet https://www.farnell.com/datasheets/73758.pdf

Years ago, I shared the idea of ​​a simple ac mains detector built around a few electronic components. You can go through this link to see details of that project. https://www.electroschematics.com/mains-voltage-sensor/

Recently I needed a solid-state relay (SSR) quickly and purchased it from an unknown online store. Sadly, it was a defective product and I lost money because the seller did not have a return policy. After that, I designed and built a simple SSR to continue my project.

The same problem occurred when I bought some AC Mains sensor modules. After some thought, I decided to make updated versions of my own AC mains sensor and SSR modules.

You can probably see the SSR project mentioned above on this website. In this article I will try to cover most of the design details of a new universal AC mains sensor module (universal ac mains detector module).

Isolated Voltage Detection – Tips & Tricks

Isolated voltage detection is vital in many industrial applications. Isolation is a means of preventing direct or alternating currents between two parts of a device, while allowing signal and power transfer between those two parts. Isolation also manages ground-potential differences provides noise immunity and defends against high voltages. Traditionally voltage detection applications have used dc or ac optocouplers (photocouplers) where they fit in the middle of the signal path for isolation.

Obviously, the easiest and safest way to detect mains electricity using a microcontroller is with the optocoupler. To safely connect such dangerous high voltage (AC230V) to the optocoupler, it is necessary to limit the current. Because the ac input voltage is high, you must also consider the power rating of the resistor. You can calculate this using the equation “P = V2/R”.

Try to use at least two resistors in series instead one. Then the power is distributed over more components. Even more significant is the diminution of maximum voltage across the series resistors.

There is no ‘clean’ dc voltage on the output, instead, it resembles a square wave.

For those whom this isn’t enough, see the output captured by my oscilloscope. I performed these experiments using the PC817 optocoupler.

If you want a smooth/steady dc output for your microcontroller’s GPIO, the following upgrade is for you. The value of the capacitor (C) in this new version is not very important – between 2.2uF to 10uF will be okay in most situations.

The first version still seems to be good if you care about “Zero Cross Detection” (ZCD). I will explain this in more detail in another post.

Another good idea, which I highly recommend, is to use a bidirectional optocoupler (also known ac optocoupler) which has two internal LEDs as opposite directions. This is the datasheet of Vishay’s H11AA1 ac optocoupler https://www.vishay.com/docs/83608/h11aa1.pdf

Universal AC Mains Detector Module – DIY Project

There are countless ways to make a mains zero crossing detector. My Universal 230V AC Mains Detector design simplifies monitoring a high voltage signal as it delivers a digital (H/L) signal output with perfect galvanic-isolation. It does not require any bulky or expensive components and can be done using jellybean parts only.

Below is my final schematic. In this version in which I used the ac optocoupler, the entire build is much more simple.

Warning! Playing with AC230V is DANGEROUS. Take care to prevent fatal electric shock. As always, you are doing this project at your own risk. The Author and/or the Publisher cannot be held liable for any damages.

The do-it-yourself project shown above consists of two equally important segments. The first one handles the high voltage ac input, and the second provides isolation between the high voltage and low voltage dc section. The fuse and metal oxide varistor are optional components for additional circuit protection.

A varistor or metal oxide varistor (MOV), also known as voltage dependent resistor (VDR), is a special resistor that is used to protect circuits against high transient voltage. A varistor is able to short surges and spikes and keep them away from the following application. See MOV-10DxxxK series datasheet published by Mouser https://www.mouser.in/datasheet/2/54/mov10d-777448.pdf

Under normal conditions the resistance of the varistor is very high, however, when the connected voltage gets higher than the “clamping voltage” of the varistor its resistance immediately gets extreme low. The varistor can simply be wired between line and neutral but after a fuse. If so, when the varistor gets a short circuit, the fuse will blow and disconnect the mains from the following application.

The pull-up resistor can be used with microcontrollers that do not have the internal pull-up resistor. Moreover, the 2-pin jumper if included will help you enable/disable the smoothing capacitor when needed. Remember, never touch the circuit board once powered – you can get electrocuted!

Note that the final ‘unsmoothed’ output (JP1 = Open) looks like the left side waveform in the below scope capture, and the ‘smoothed’ output (JP1 = Close) appears similar to the right side waveform. Obviously, the smoothed output does not look perfectly flat, but the fluctuations are not higher than 500 mV. You can monitor the output status (perhaps thru a microcontroller) to know if ac mains input is present or not (the voltage output should be smoothed to the required level).

coffee break

There may be many different opinions on how to do this. But I want to keep this design as it is a proven solution for me. I hope it will be useful for you. Leave me a comment in the box below. Constructive criticism is always welcome!

Leave a Comment