Introduction: Contactless AC Detector

This instructable idea was like a technical challenge : try to detect the presence of a AC live wire, without contact and without current flowing. The beauty of it is that you'll only need a MCU (arduino nano here), a wire, two resistors and a LED. My plan is to use this design to improve a simple switch with a remote capability without any contact with the cables.

I did not have the original ideas, but I made improvements that gives you much better detection and a signal level indicator which has a physical meaning.

Step 1: How Does It Work ?

Any AC live wire will have an oscillating voltage, 50 Hz for example. Even if it's not very efficient, those wires are antennas and generate an electromagnetic radiation that can be detected (people dealing with "real life electronics" know what a plague this can be...).

The idea is to use an arduino and put a big resistor between an antenna wire and a voltage reference. The big resistor is used to have "high input impedance", which in simple words make it easy to detect a low voltage (what you measure is not modified too much by the circuit), you just link the antenna/resistor output to an analog input of the arduino and you have a decent way to measure the EM field. This idea comes from the following website :

I made one improvement linked with my method of detection : instead of linking the antenna to ground I put it on 3.3 V so that you can actually measure both positive and negative voltage difference. This way you get more signal and you can actually check with an oscilloscope that your analogue input has a beautiful oscillating voltage (not clipped as it would be if you were using a ground reference).

The other improvement is just a basic signal detection method, let's just say you can have a much better detection when you use your knowledge of the signal you're trying to detect : a 50 Hz (or 60 Hz) oscillating voltage. It works a bit like a numerical radio actually !

Step 2: The Circuit

To build the receiver, I used :

- an arduino nano

- a power source (9v battery, 5V USB battery, ...), I used a 5V USB battery

- a small piece of wire (like 10 cm), insulated,

- a 1 Mohms resistor

- a 390 ohms resistor (for the LED)

- a LED (red for me).

Just one warning : Don't get close to unprotected live wires, be careful. This system is not made for that and that is a dangerous idea if you don't know why it's unsafe.

Step 3: The Software

The code is quite simple, it measures the A6 input voltage and makes an estimate of the amplitude of the AC voltage with the signal detection algorithm.

This estimated amplitude is used to modulate the brightness of the LED in a proportional way : no light when there is nothing, full brightness when there is something big enough (less than 0.1V is already a lot).

New : An improved version has been added using a LCD display and a better detection algorithm (the "V4" version).

Step 4: The Results

Well, it's quite nice, it worked for me more than 30 cm (1 foot) away and is indeed more and more bright when you get close to a switch or a live wire. You might be surprised by the difficulty to find a place without live wire close enough, except if you live in a cave and don't have the internet (how are you reading this ?). I added a scope screen copy to show you that indeed there is a real signal with a 50 Hz frequency !

You will maybe get some improvement if you link the ground of the circuit to the earth of your mains, but that's a bit clumsy and you have to be really sure than there is no direct link between your power supply output and your mains (else you will fry something...). If you have an isolated power supply, it will work by linking the negative output to the earth (never do that if the supply is not isolated again).

One last thought : This system only measures the oscillating voltage, you might actually get interesting results with the DC component which is also calculated (but not used).


RKSBOT made it! (author)2016-09-27

Can I use Arduino Uno r3 instead of Arduino nano??

Emmanuel2015 made it! (author)Emmanuel20152016-09-27

Absolutely, it won't make any difference.

bousse made it! (author)2016-08-22


Could you give me some more detailed info about how the algorithm works? Why do you use -1023 * 3/5 after the analog read? What are c and s used for? What do they represent?

Thanks in advance.

Emmanuel2015 made it! (author)Emmanuel20152016-08-22

Well, do you want a mathematical answer or a more physicist answer?

It's basically some signal treatment, you might look up the Fourier transform (c and s are that) or the superhetordyne AM radio receiver.

bousse made it! (author)bousse2016-08-23


A more mathematical answer please, more like the reason why you do each step in that specific order. I suppose your algorithm is based on signal mixing? And using the mixer you filter out the 50 or 60Hz component? And then with the calculated cp and sp Fourier components you calculate the amplitude? Are my assumptions correct? Thanks in advance.

Emmanuel2015 made it! (author)Emmanuel20152016-08-23

Well, the code does two things. The Fourier transform gives you an estimate of the amplitude and phase of the 50 Hz signal (c and s are indeed the two Fourier components). The sum/average is simply an estimate of the DC component and my code is a bit awkward with the 3/5*1024 substracted, it should just use this for the initial estimate of average. Actually, this subtraction is useless in the Fourier transform. I will clarify it in the next version.

bousse made it! (author)bousse2016-08-24

So the subtraction (adc0-average) you do while calculating the Fourier components is useless because in the loop "average" stays zero the whole time? Only after the loop, average gets a value (the average of all samples), am I right assuming this? Thanks in advance.

Emmanuel2015 made it! (author)Emmanuel20152016-08-24

No, the average is a very low frequency signal that gets zeroed by the Fourier transform, so it doesn't make any difference to substract it, except if you have rounding/overflow problems (I don't think that's the case). The average is relative to a 3V reference and is calculated with the sum (simple average). It might be that I had to do this to avoid an overflow when using many samples (but with a long integer, I feel rather safe?).
Looks like we're on a same time zone, that'd be funny if you spoke French.

bousse made it! (author)bousse2016-08-25

One last question, variable "t" in the formula for calculating "phi". I suppose it must be declared in microseconds because you divide by one million right? Thanks in advance.

Emmanuel2015 made it! (author)Emmanuel20152016-08-25

Yes, absolutely, it comes from the micros() function. Please note that the sampling rate is quite high, hopefully it's slowed by the trigonometric calculations, the analog to digital conversion and the LCD display commands. In another application, you might do it differently since a minimal 100 Hz sampling rate is enough (Nyquist theorem). Note also that the response speed depends on the number of samples in the window (and process time of one sample of course).

bousse made it! (author)bousse2016-08-24

I'm from Belgium, mother tongue is Dutch ;) Thanks for your help.

About This Instructable




Bio: Being an engineer, I just love to understand how things work. This website is a great opportunity for me to learn new stuff !
More by Emmanuel2015:Kiddy clock aka sleep deprivation protection systemContactless AC detectorCool EMF detector
Add instructable to: