DIY Metal Detector based Arduino

DIY Metal Detector based Arduino Nano

Metal detector, sounds a bit high-end, below we just use an Arduino, 10 meters of copper wire, a 100 ohm resistor and a passive buzzer to make it.

Detectors can be designed in various sizes and shapes as needed, the difference being the fabrication of the coils. It is still useful to make a small handheld probe for daily inspection of metal objects. Not only can you find small things like coins, but it can also be used to detect furniture joints, metal screws or nails used in wall decoration to help understand the structure.

  • Arduino Nano × 1
  • Thin copper wire × one turn
  • 9V battery × 1
  • 100 ohm resistor × 1
  • Switch × 1
  • Button × 1
  • Passive buzzer × 1
  • 10 muF capacitor × 1
  • 2 sticks for skewers × 1
  • 7 8cm wires × 1
  • Heat shrink tube × several
  • Soldering Iron× 1
  • Hot melt glue gun × 1

make a coil

Easy to make a copper wire coil with at least 20 turns, preferably more than 50 turns. The more you wrap around, the better the detection effect will be. The detector is sensitive to objects larger than one-tenth the diameter of the coil. So the smaller the coil, the higher its sensitivity. The total resistance of the final coil should not exceed 10 ohms.

I am using AWG26 enameled wire here, 0.4mm in diameter. Resistance 0.13 ohms per meter. 60 turns are wound, and the inner diameter of the circle is 6.3 cm. About 12 meters of enameled wire were used, and the resistance was 1.5 ohms.


Download the code files for this project to Arduino. The code files are downloaded in the project repository.

Connect the leads on both ends of the coil to pin 8 and pin 10 of the Arduino.

Connect a 100 ohm resistor from pin 8 to GND.

Connect a passive buzzer and 10 microfarads in series between GND and pin 12.

Give it a try! When a metal object is placed near the coil, the built-in LED on the Arduino will start blinking and the buzzer will sound at the same frequency.

If that doesn’t work, you can troubleshoot the problem with the blinking pattern of the LED:

Only one flash – no pulses on the probe, need to check the wiring for a problem.

Double flashing – delay is too short, need to increase the number of coil turns.

Triple Blink – Delay is too long and the number of coil turns needs to be reduced.

Quadruple flashes – no stable pulse, need to confirm whether the resistance of the coil meets the requirements.

For more detailed troubleshooting, you can also change debug false in the code to debug true. You can see the delay value fed back by the serial monitor. It is recommended to adjust the coil so that the value is between 5 and 20.

Principle description

The metal detector consists of two parts, the detection coil and the filter circuit. The detection coil is the core part. After the coil is energized, a magnetic field will be generated, and if metal enters the magnetic field, it will cause the magnetic field to change, thus judging that there are metal impurities.

The challenge here is that the pulse delay is very short: the characteristic time of an RL circuit is tau = L/R, where L is Henry and R is ohm. The coil inductance we are using is about 300 microhenries, so for R = 100 ohms, tau = 3 microseconds. We’re looking for a 1/5000 change in inductance. It is therefore necessary to measure time with an accuracy better than 1 nanosecond.

The Arduino’s clock speed is 16 MHz, so such measurements are not accurate enough. But the accuracy can be improved by combining large amounts of detection data.

However, repeated measurements are not enough, because the quantization error is always the same: if the delay changes from 3.03 microseconds to 3.02 microseconds, the delay is always 48 clock cycles. To overcome this problem, we measured the timing of the falling edge of a short pulse and swept between 3 and 5 times the length of this pulse (the initially found delay value).

The code is designed to measure inductance 100 times per second for fast detection. For a pulse delay of 25 clock cycles, the timer is set to repeat every 215 clock cycles, so in 10ms, 15 of the 50 pulse lengths can be repeated 15 times, and a total delay of 750 pulses provides the measurement, The resolution of the delay time is 10^-4.

At start-up, the first measured value is used as the reference value. Whenever the measured values ​​differ by more than a predefined threshold, the phase counter starts to increment. When the phase counter exceeds the maximum value, a 1ms LED pulse will be generated and the buzzer will sound simultaneously.

make handle

Solder the circuit as shown in the picture, find a suitable size box, and put both the battery and the device in it. Punch holes and attach buttons ie.

Hot glue the probe to the handle and you’re done!

Download Code

Original post:

error: Content is protected !!