AC Mains contactless detection with DIGITAL out

I built different circuits to detect AC mains but with flaky results.
I was not able to build a reliable solution with common circuit plans that you can find in the net.
Some (IC555 based) work for a couple of minutes perfect and then become unstable, some just don't work, some are to sensitive and so on...

My goal is a simple small plastic box to be near the normal isolated AC mains cable that detects 50HZ voltage and gives a DIGITAL out.

No measuring, no analog just if mains powered on that cable -> Digital 1, if not -> Digital 0.

Do you have any ideas hints or reliable circuits?
Thx a bunch in advance

I need to detect when my supply was running on night tariff and ended up using a mains socket with built in neon light and an arduino with an LDR blue-tacked over the neon. I do use analogue to read the LDR value but with selection of suitable values for the resistor divider if would work as digital.

The best way is to use a current transformer around ONE of the wires carrying current. In this way you get 100% definite results. You can use one of these - or maybe another type for higher currents.

Now if you need to be able to detect mains as you have described, then you have a coice: you can detect the electric or magnetic field that is caused by the cable.

I found this:

that explains how you could (possiby) use a hall sensor to detect the mag field VERY NEAR the conductor;
and this (and similar) that detect the electric field - so work at a greater distance. The disadvantage is it MAY be susceptible to interference.
http://jap.hu/electronic/wirescan.html
you could take your digital output to the arduino from the collector of T2

I'm assuming by this, that you want a non-invasive method (i.e. not wiring mains power cable's). However, if you did choose to have an invasive method, the simplest solution I've found is to use this mains optoisolator module; https://www.aliexpress.com/item/32828199766.html

You connect AC voltage to L and N. OUT goes to an input pin of arduino (set to input pullup) and GND goes to GND of Arduino. No analog required, just reading the digital pin.

I did this years ago with a CMOS 40106 hex Schmidt trigger and a length of wire. Connect a 10MOhm resistor as a pull down to one of the inputs. Connect about 250mm of mains rated insulated wire to the input. Wrap that wire around the live wire you want to detect the voltage on. Connect your whole circuit to mains earth. Power as required. You should get a square wave at the output of the 40106 inverter you are using when the mains is on.

For safety and the avoidance of doubt:
DO NOT make any electrical connection between the 40106 detection circuit and the mains live or neutral. The only connection that should be anywhere near the 40106 is mains safety earth.

Yes, i want a non-invasive solution just for the voltage, not current. Thxs

I tried a bunch of current transformers with also 12bit A/D converter. I'm not conviced by the result, the position of the L in the hole etc. is influecing the result. On my actual project i just have a digital pin left so i decided to search just for a Voltage->Digital 0/1 solution. Otherwise i need another MCU to send the results from the A/D converter over I2C (No UART left) which leads to cable lenght problems etc.

I tried this also but with unreliable results.

I also tried with a hall sensor. This works IMHO in labor when current flows. If you have just a cable under voltage WITHOUT a "consumer" (like a lamp or whatever) it doesn't work reliable in the field with other cables around.

You just want to know if vac is present at an outlet ?
Or if some device plugged into the house wiring is running ?

No, the magnetic field is proportional to the current.

I havent tried it (yet) but I'd bet this works well to detect the electric field from a live wire; I've used a very similar ciircuit with a 2N3819 JFET and very high Q tuned circuit as a radio receiver.

Yes, but not invasive, the consumers are connected but off - a very small current will flow so 50 Hz or a small magnetic field should be present, no connection with main. I know this sounds simple but i experienced it's not so.

What?

ok, not sure if it's been mentioned, but here's a non-invasive technique;

https://www.jameco.com/Jameco/workshop/JamecoFavorites/non-contact-AC-voltage-detector.html

code:

1 Like

I did this one - over an optocopler for the digital in. The problem is that the signal is flickering - you can see that in the video - the LED is flashing fast. So you can wait a second in the software for a high (or ten or 50) as a indicator for mains on.
It's a possible way - the signal has to be analysed within the software but it's also not a cristal clear "Mains On- Signal is High"

Hardware, contactless: Mains On -> Digital High

"Hardware, contactless: Mains On -> Digital High"
(Heavy Sigh)
I will re-state my question --
DO YOU want to know if
A ) vac is present at an outlet ?
Or
B ) some device plugged into the house wiring is running (drawing current)?

You mean the video accompanying that github link I sent you? Where is there flickering?

Gasp - Sorry, didn't get it... A! In a cable

Nothing personal, but I'm outta here.