Introduction: Arduino Metal Detector
Build a cool looking and very unique metal detector with 5 separate search coils that light up when metal is detected. The search coil closest to the metal will light up better helping identify the location of the hidden treasure!
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Gather Materials
The goal of this project was to have some fun exploring the use of multiple search coils, use light rather than sound to indicate detection and also house everything in the head of the detector.
The heart of the detector is the Arduino Nano Atmega328 which is used to measure the pulse width of a signal which passes through each search coil. The Arduino produces a square wave pulse which is fed into an LC Tank circuit which produces a decaying sine wave signal at a frequency determined by the resonant frequency of L & C. This signal is cleaned up through the LM339 voltage comparator which in effect produces a series of pulses that are presented to a digital input pin in the Arduino. The pulseIn function was used to attempt to measure the length of the pulse width of the pulses. After a lot of messing around and varying results I was able to get stable outcome by averaging multiple samples on each coil. When metal is placed near the coil the inductance of the coil changes which varies the resonant frequency of the LC circuit and therefore the pulse width. If the variation in pulse width compared against a baseline value occurs then a LED is lit directly above the coil.
- Arduino Nano ATmega328
- LM339 Quad Voltage Comparator chip x 2
- Vero Board 50mm x 80 mm
- 1K ohm resistors x 5
- 100 ohm resistors x 5
- IN4148 Signal Diode x 5
- 0.1uf Greencap Capacitor x 5 (Mounted by Coil)
- 330pf Ceramic Capacitor x 5 (Mounted on PCB to improve stability)
- 10K pullup resister x 1
- 3v LED strip with 150 ohm resistor attached (Cut from reel) x 5
- Suitable Mop Handle with plastic flexible joint
- MDF wood 6mm thick, 2 pieces 22cm x 23 cm
- Copper Wire 0.26mm approx 25m length (5 coils with40 turns with 20mm radius)
- Ping Pong Balls x 3
- Plastic sheet A4 Blue Color (used from document file sourced from a department store)
- Two part epoxy resin glue( 5min preferably)
- Single core 2-3mm shielded cable approx 30cm length
- Vero mounting posts x 20 (Small metal spikes that make it easy to attach wires to Vero Board)
- Soldering iron
- Jig Saw suitable to cut 6mm MDF wood
- Pliers and side cutters
- 50mm hole drill
- Hot glue gun
- Electric Drill
- Box cutter knife
Step 2: Build the Search Coil Assembly
- Create a Hexagonal cardboard template from cardboard by drawing a 80mm circle and dividing the circle into 8 equal segments.
- Use the hexagonal shape to draw the shape of the search coil assembly onto sheet of paper as per the diagram.
- Copy the shape onto the MDF board and using an electric Jig Saw and cut out the overall shape twice.
- Take one of the MDF shapes and using a 50mm diameter hole saw (door handle hole drill works well) drill 5 holes in the centre of each hexagon .
- Using epoxy glue fasten the two sheets together as per the diagram so that you now have 5 holes to mount the search coils.
- Wind 5 x copper wire coils made up of 40 turns around a 40mm cylinder (I used an old caulking gun tube)
- Use hot glue to stick the windings together and ensure that the start and finish of the winding has at least 20cm of lead so they can be connected to the PCB.
- Drill a 3mm hole in each of the Search Coil assembly to enable the copper wire coil leads to pass from bottom to the PCB as per the photo.
- Hot Glue the coils into place ensuring the copper wire leads are threaded through the hole and can reach the PCB. Use a lot of glue to ensure the coils are rigid and at least flush with the base of the MDF. You don't want the coils protruding out below the MDF otherwise they will be damaged when dragged across the ground.
Step 3: Build and Test the Circuit
The unusual shape of the circuit board was an attempt to keep the circuitry central to the device to avoid interference with the search coils.
- Use the stencil created earlier to mark out the Vero Board to the required shape.
- Mount the Arduino and LM339 devices first and use them to position the components so you can drill out the vero board as per the attached picture. Solder in the Arduino and LM339 devices.
- The resistors and capacitors where the added along with shielded cable to improve stability.
- I mounted the 0.1uf Capacitors directly on the MDF as they were quite bulky and needed to be attached to the Copper Wire loops directly. Then the shielded wire was cut to length, earthed at one end (not both!) and then connected to the PCB via a Vero pin. (See closeup of circuit)
- There is a calibration button on pin D2 of the Arduino that resets the threshold for each coil to enure any variations in construction can be zeroed out.
Testing the unit
- Enclosed is a picture of the circuit diagram along with the Arduino code for testing the unit.
- Upload the code to the Arduino. Remove the USB cable from the Arduino (Important as 9v Battery + USB will overheat unit)
- Attach a 9v battery (Vin pin on Arduino) and observe that the unit has started up ok (Arduino flashing lights)
- Place the search coil somewhere away from metal. Press the calibrate button. Each LED should light as it calibrates each of the 5 coils.
- Move metal close to the search coil and the associated LED should light.
- If this does not happen check your circuit to see that everything is built correctly.
Step 4: Complete the Case
- A plastic sheet was used to cover the top and the bottom of the unit and the sides where painted to ensure it was water proof.
- Drill holes in the cover on top to enable the LEDs to emit light. Ping Pong balls were halved and used as light diffusers to give quite a cool effect when metal is detected.
- A plastic container (In this case half and ear muff) was used to house the circuit board and 9v battery.
- In this case I chose a Mop Handle with a flexible joint that enables the Metal Detector head to swivel up and down to suit the height of the user an ensure it is comfortable to use.
Step 5: Final Testing
- When the unit is turned on the sensors need calibrating.
- Lift the head away from any metal or objects and press the calibration button.
- The LEDs should light from left to right briefly and then the unit should be set to use.
- There are variables in the code that I have highlighted that can be played around with to improve or change performance.
- However I have tried to make this something you turn on and it just works.
Step 6: Single Coil Detector
I've received a number of requests for a single coil detector for various applications so have added this section for individuals to try.
There is a circuit diagram enclosed and the also modified code.
1. Please note that the circuit operates at high frequencies and that the length of hookup wires can make the circuit unstable when used on a breadboard. Therefore keep wires short with minimal overlap and ensure cabling has no movement during operation.
2. USB power from your PC will have an impact on the stability and frequency of the circuit. Therefore I recommend you power the circuit with an external 9v battery when testing.