Project tutorial
Metal Detector Using Frequency Counter and OLED Display

Metal Detector Using Frequency Counter and OLED Display © GPL3+

There are a lot of Arduino-based metal detectors using various technologies. This is one of them that uses direct frequency measurement.

  • 1,861 views
  • 1 comment
  • 15 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)
3drag
3D Printer (generic)

About this project

There are a lot of forests in Lithuania which I like exploring on my bike. In the past a lot of Lithuanian resistance troops resided in those forests, so there is a big probability to stumble upon a stash of some kind. However that stash might as well be a grenade or a bomb of some kind, but nevertheless I always wanted to combine my motorcycle riding through the woods with treasure hunting and some time ago I decided to build a simple metal detector. Granted there are lots of metal detector designs, like BFO, VLFD, PI and so on (I'll briefly cover some of them on my blog). Some of them I've tried in the past with various results and then during one boring evening of browsing the internet I stumbled upon this blog and decided to build this type of metal detector. The design is really simple - there is a simple oscillator circuit and a frequency counter. When the coil passes over or near various ferromagnetic or paramagnetic materials the frequency of the oscillator changes and based on this change you can decide where to dig. Moreover since the frequency counter can be implemented on any microcontroller you can analyse the frequency change in many different ways potentially enabling metal differentiation and even filter out frequency drift, that plagues other types of detectors.

The code for this project can be found here in the folder arduino/MetalDetector. Folder arduino/MetalDetector/third-party contains the code that inspired this project.

Along with the Arduino source code you will find there OpenSCAD files and STL files of the 3D-printed parts for this project except for the screw, that holds arm and coil parts.

Operation

The search coil has integrated Collpits oscillator with a buffer circuit, which generates the signal of around 660kHz. This oscillator is placed as close to the coil as possible. The signal is picked up by an Arduino Pro Mini board (using ATmega168), the frequency is being measured. 32 points of the measured frequency are stored in a FIFO buffer, scaled to fit 128 pixels of the display and drawn on the 128x32 OLED display together with battery indicator.

The oscillator needs to warm up for some time, but that is not really necessary - because once you start swinging the search coil and it finds any metal, there will be a spike on the graph. If the frequency of the oscillator haven't settled before that - the graph will not be horizontal. Conversely once it settles - the graph will be horizontal. No calibration or zero-in is required for this kind of operation :)

Construction

Here is the picture of the assembled metal detector using 3D printed parts:

Here in the picture you can see the search coil wound on the 3D printed coil carcass, braided wire that connects the search coil and the Arduino, and battery holder with the arduino itself and OLED.

The search coil has the oscillator integrated. Oscillator is assembled from SMD components, mainly resistors, condensators and BC846 transistors. The board of the oscillator is wrapped in copper foil in order to insulate it from the environment. I don't remember how many turns there are in the coil, but something around 15-20. I think the lower number of turns, the better, as the frequency is higher and frequency change due to inductance change with metal present is bigger which makes metal detection more sensitive. Also the higher the frequency the faster is the frequency counter response. Although there is a tradeoff of the signal frequency and the sensitivity due to the condition of the soil. If the soil is mineral-rich and moist, it may be quite conductive thus blocking high frequency signals from penetrating thus limiting accuracy and sensitivity. The windings of the coil are sealed with epoxy glue.

This is how the insides of the detector look like:

Arduino Pro Mini and OLED are soldered to a small breadboard along with the voltage divider, push-button switch and header for the search coil. The whole thing is glued to the two 18650 Li Ion batteries, which are glued to the bottom of the enclosure.

As you can see, the OLED display is connected to the I2C interface of the Arduino, voltage divider of the battery is connected to the A0 analog pin and the signal from the search coil oscillator connected right to the digital pin 5.

Oscillator receives direct power from two 18650 cells connected in series, and outputs the generated signal. And here is the signal, that is received from the coil:

The quality of the signal is not important(clearly I haven't put much consideration into Q2 base current), as all that matters is the triggering of arduino pin, which is configured to a counter register.

3D-Printed parts

3D-printed parts were designed with OpenSCAD and printed with Geeetech Rostok 301 3D printer.

Summary

The project took me more than an evening, I'd say even more than a couple of weekends to assemble and program. There were different iterations. At first I've designed a different coil with around 30 turns, completely enclosed in epoxy glue. Also I've used a NOR gate as the oscillator buffer which worked much better than a single transistor in the final version... Although the coil was rather big - about 30cm in diameter which lowered its sensitivity for small objects. Smaller and 3D-printed coil proved to be much more stable both mechanically and electrically, however due to rather strong coupling it is sensitive even to moving my hand near the wires or even near the enclosure. I tried different approaches for frequency measurement. At first tried the same code as in the original blog post. Then after the concept proved to be viable, I added the OLED screen and moved to a frequency counting library.

I haven't yet had a chance to test it outdoors, but indoors it finds metal construction under the floor(around 15cm of concrete along with laminate). I wonder how it would perform with different soils.

At some time in the future I plan to design the coil and oscillator circuit board, experiment with VLF and PI detector designs.

There is a warning to be said, by the way. In some countries it is illegal to construct and use metal detectors, so make sure you check with your authorities before replicating this project.

Code

Github
https://github.com/foxis/ardoodles

Custom parts and enclosures

Github link to the code, openscad design files and schematics
Clone the repository

Comments

Similar projects you might like

Programmable Pocket Power Supply with OLED Display

Project tutorial by Shahariar

  • 7,114 views
  • 8 comments
  • 37 respects

DIY 7-Segment Display

Project tutorial by Pop Gheorghe

  • 1,222 views
  • 2 comments
  • 1 respect

Arduino OLED Temperature Display with Real Time Clock

Project tutorial by Keval Doshi

  • 9,113 views
  • 7 comments
  • 34 respects

Smart 3D Printer Filament Counter (FilamentBot)

Project tutorial by ArtSuzhou

  • 9,108 views
  • 3 comments
  • 25 respects

Display Current Weather with Arduino and Python!

Project tutorial by Arduino “having11” Guy

  • 7,542 views
  • 3 comments
  • 19 respects

Lightpipe 7-Segment Display

Project tutorial by Brian Lough

  • 6,107 views
  • 4 comments
  • 23 respects
Add projectSign up / Login