# Contactless AC Detector

8,235

69

15

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 : http://www.aaronalai.com/emf-detector.

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).

## Recommendations

• ### 3D CAM and CNC Class

1,703 Enrolled

## 15 Discussions

This seems to be far superior than the Instructable I followed, because of the range it gets. In the one I tried, a solid core insulated wire, approximately 16awg, was used, in a 2.2cm coil approximately 3.5cm, in its coiled length. Is the wire in this Instructable solid core and what is its gauge? I will find the exact type of wire while I wait for the 1Mohm resistor to arrive, in order to recreate the same results.

Hi,
Well, the gauge isn't really important, the wavelength of the signal is huge and the wire is just a very bad antenna. Just try any wire, it should be ok. The real trick is much more about signal treatment.

Hi,

Can I used this method to find live cables in concrete roof of 125mm thick?

Hi,
Well if it's not steel reinforced concrete, it should work. What you might need is maybe to use a digital output with a LCD screen and a longer averaging.

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

Hi,

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?

8 replies

Hi,
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.

Hi,

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.

Hello,
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.

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.

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.

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.

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).

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