Spirit Pi 5 · pulse induction

Build and use the Spirit Pi 5 metal detector

Spirit Pi 5 is a pulse induction (PI) detector built on the proven Clone PI-W circuit. An Arduino Nano times the pulses, and your phone is the screen and the speaker over Bluetooth. This page shows how to build it, load the firmware, set it up in the app, and what to check when something goes wrong.

In development

The firmware and the app are new and are still being tested on real coils. If something doesn't work as described here, write to me and I'll fix it in the next update.

Have an earlier Spirit Pi? The same app screen works with it: see the earlier Spirit Pi instructions.

Spirit Pi 5 detector screen: B&B (battery and Bluetooth) and D&F (delay and frequency) tiles, the signal ring with its scope, the profile and threshold bar, and the + / Balance / − buttons
The detector screen in the app (red theme).

How it works

A pulse induction detector sends a short, strong current pulse through the coil and then listens to how fast the magnetic field dies away. Metal under the coil keeps the field alive a little longer. The detector measures that "tail" a few microseconds after each pulse, 200 times a second.

  1. Arduino NanoTimes every pulse to 0.25 µs and reads the result.
  2. IRF740 + coilA 120 µs pulse through the coil, then it switches off.
  3. TL074 + 4066Amplifies the coil's decay and samples it after the delay D.
  4. HC-05Sends 50 readings a second over Bluetooth.
  5. PhoneBalance, signal, sound, target ID and your settings.
  • Why PI: it hardly reacts to mineralised ground, beach sand or salt water, and it reaches deep. The price is that a simple PI detector can't tell metals apart the way a VLF detector does.
  • Target ID (discrimination): Spirit Pi 5 can take a second sample later after each pulse. Thin or poorly conducting objects (foil, small pieces) fade fast and give a low ID; thick or well conducting objects (big coins, large pieces) fade slowly and give a high ID. It doesn't separate iron from other metals.
  • Works without the phone too: if the app isn't connected, the detector uses its own LEDs and speaker, if you fitted them.
  • Pro: My metals (learn and name your own metals) needs the Pro version of the app. Everything else on this page is free.

What you need

  • Spirit Pi 5 boardsThe analog board (TL074, CD4066, IRF740, four 2N5551) and the Nano board, my own design based on the Clone PI-W circuit.
  • Arduino NanoATmega328P, 16 MHz. It plugs into the Nano board.
  • Bluetooth moduleHC-05 or HC-06 (classic Bluetooth). Set to 38400 baud once (see Firmware below).
  • Search coil300–400 µH, as for the original Clone PI-W. For example a 25 cm round coil.
  • 12 V battery3S Li-ion (11–12.6 V) or 8 × AA, through the power switch.
  • Android phone with BluetoothWith Spirit PI on Google Play.
  • MultimeterTo check the supply, Uref and the battery reading.
  • OscilloscopeOptional. Shows the pulses on D7–D10 and the coil decay.
  • Speaker, LEDs, buttons boardOptional. Only for using the detector without the phone.

Build the detector

Spirit Pi 5 uses two boards based on the Clone PI-W circuit (4066 version): the analog board (coil driver, preamplifier, sample switch and integrator) and the Nano board (the Arduino Nano and the connectors). Join them pad to pad: T0–T3, U_ADC, U_REF, +12V and GND. The drawing and the table show which Nano pin each signal reaches.

Schematics

Click a schematic to open it full size.

Analog board: coil driver (IRF740), preamplifier, sample switch and integrator (TL074, CD4066).
Analog board
Nano board: Arduino Nano, Uref (TL431), speaker driver (BC547) and connectors.
Nano board
Buttons board: LEFT, RIGHT, OK, UP and DOWN on A1–A3.
Buttons board

PCB files

The files of my two boards: EasyEDA projects (analog and Nano boards), the toner-transfer sheets as PNG and as A4 PDF (print at 100 %, actual size), layer PDFs and parts lists. The battery meter below is not on the boards.

wire optional

Connections and Nano pins

Analog board + Nano board (Spirit Pi 5) Arduino Nano HC-05 / HC-06 T0 D7 coil pulse T1 D8 preamp gain T2 D9 sample T3 D10 integrator reset U_ADC A0 signal Uref AREF Uref (TL431) optional BATT A7 +12V after switch ÷5 +12V VIN GND GND recommended 10k to GND D1 TX recommended: 1k + 2k to GND RXD D0 RX TXD 5V VCC GND GND A4 STATE D6 speaker (BC547) A1–A3 buttons board: 5 buttons D2…D13 7 LEDs (D2–D5, D11–D13) OPTIONAL
NanoBoard / moduleWhat it does
D7T0Coil pulse (HIGH = MOSFET on). Recommended: 10 kΩ from D7 to GND, so the MOSFET stays off while the Nano boots (my board works without it).
D8T1Preamp gain switch.
D9T2Sample switch (4066).
D10T3Integrator reset.
A0U_ADCSignal from the analog board.
AREFU_REFADC reference from the TL431 (about 4.57 V).
A712k / 3kBattery voltage ÷ 5. Optional: battery meter (see below).
VIN · GND+12 V · GNDPower, common ground for board, Nano and module.
D1 (TX)RXDDirect on my board, and it works. Recommended: 1 kΩ in series and 2 kΩ from RXD to GND. The module's RX is a 3.3 V input and the divider protects it from the Nano's 5 V.
D0 (RX)TXDDirect.
5V · GNDVCC · GNDModule power.
D6BC547Speaker (optional).
A1, A2, A3buttons boardOptional, 5 buttons (table below).
D2–D5, D11–D13LEDsOptional 7-LED bar graph.
A4STATEOptional (HC-05 only): tells the Nano a phone is connected.
  • Unplug the Bluetooth module (D0/D1) while you upload the firmware over USB. A jumper or a small switch makes this easy.
  • AREF goes to Uref, never to 5 V. The firmware sets the external reference first thing; don't add analogRead() to it.

Optional: detector battery meter

The boards don't measure the battery voltage, and the detector works fine without it: the app shows "—" instead of the battery. If you want to see the battery level and get a warning when it runs low, add three parts to the Nano board:

12 V battery + / − switch +12V 12k3k10nF A7 GND Arduino Nano A7 GND soldered on the Nano board, pads +12V · A7 · GND A7 = battery ÷ 5 (12 V → 2.4 V)
  • 12 kΩ from the +12V pad to the A7 pad. Take +12V after the power switch, so the divider doesn't drain the battery while the detector is off.
  • 3 kΩ from A7 to GND, with 10 nF in parallel (it filters the spikes of each coil pulse).
  • The Nano board already has the +12V, A7 and GND pads: solder the three parts there, under the board. Nothing else changes on the boards.
  • In the sketch set BATT_WIRED 1 and write your Uref in VREF_MV (see Load the firmware). Then set the battery range in the app (step 8 of Set up the app).
  • Check: with the battery at 12.0 V, A7 measures about 2.4 V.

Buttons board (optional)

For using the detector without the phone. It has no PCB: build it on perfboard following the buttons board schematic above (5 buttons, 7 resistors). If you connect it, set BUTTONS_WIRED 1 in the sketch (without the board, A1–A3 float and would read false presses).

ButtonInputFunction
UPA3Threshold +
DOWNA3 (20 kΩ)Threshold −
RIGHTA1 (20 kΩ)Volume +
LEFTA1Volume −
OKA2Balance. Hold 3 s: factory settings

Load the firmware

  1. 1

    Download and open the sketch

    Download the firmware, unzip it and open spirit_pi_5/spirit_pi_5.ino in the Arduino IDE. Both files must stay in the spirit_pi_5 folder.

  2. 2

    Check the options at the top

    • VREF_MV: measure Uref on the AREF pin with the multimeter and write it in millivolts (for example 4570). Only the battery meter uses it.
    • BATT_WIRED: 1 only if you fitted the optional battery meter on A7.
    • BUTTONS_WIRED: 1 only if you fitted the buttons.
    • BT_STATE_WIRED: 1 only if the HC-05 STATE pin goes to A4.
    • BT_BAUD: 38400. Leave it unless your module runs at another speed.
  3. 3

    Upload

    Choose Tools › Board › Arduino AVR Boards › Arduino Nano, processor ATmega328P (or ATmega328P (Old Bootloader) if the upload fails on a clone). Unplug the Bluetooth module and upload.

  4. 4

    Test it in the Serial Monitor

    Open the Serial Monitor at 38400 baud. You should see <I/SP5/1.2/2>, a <C/…> line and then about 50 <D/…> lines a second. Type ? and press Enter: it answers again with I and C.

  5. 5

    Set the Bluetooth module to 38400 baud (once)

    New modules usually run at 9600 baud. Set them once with a USB-serial adapter or an Arduino sketch that passes the serial through:

    • HC-05: enter AT mode (hold the button while powering it), then AT+UART=38400,0,0.
    • HC-06: AT+BAUD6.

    The pairing PIN is usually 1234 or 0000.

First power-up

  1. 1

    Supply

    Without the coil, power the board from 12 V. Check 5 V after the 78L05 and Uref ≈ 4.5–4.6 V on AREF. Write the exact Uref in VREF_MV if you haven't yet.

  2. 2

    Pulses (oscilloscope, optional)

    On D7 you should see a 120 µs pulse 200 times a second. D8, D9 and D10 switch just after it. With the default settings the sample (D9 LOW) starts about 17 µs after the end of the pulse and lasts 26 µs.

  3. 3

    Connect the coil

    Connect the coil and power up again. In the Serial Monitor the first number of the <D/…> lines (the signal) should stay steady and drop when you bring a coin close to the coil. If it sits at 0 or at about 8180, the signal is saturated: see the troubleshooting section.

Set up the app

  1. 1

    Choose Spirit Pi

    Install Spirit PI and choose Settings › Choose metal detector version › Spirit Pi. The same screen works with Spirit Pi 5 and with the earlier Spirit Pi: the app recognises which one is connected.

  2. 2

    Pair the Bluetooth module

    Turn the detector on and open Settings › Set bluetooth module. Tap Search, tap your HC-05 to pair it (PIN 1234 or 0000), then tap it in the paired list to use it.

  3. 3

    Connect and balance

    Back on the detector screen, tap the connect button (left of the bottom bar). The status bar shows Connected · firmware 1.2 and the app balances automatically for one second: keep the coil still and away from metal. Tap Balance again whenever you change place or settings.

  4. 4

    Set the threshold

    The number on the right of the bar is the threshold, selected by default. Use + and − (hold to repeat). Raise it if it beeps on nothing; lower it to reach deeper. Default: 40.

  5. 5

    Choose a profile and the pulse settings

    Tap the profile name in the middle of the bar (Original). The panel that opens has four starting points, Original, Coins, Depth and Mineralized ground, and every pulse setting with a slider. Changes go to the detector at once; Save keeps them in the detector after you switch it off.

    You can also tap the Delay or Frequency tile in D&F and change it with + / −.

    Pulse settings panel: profile chips (Original selected), the Discrimination section with Target ID, Late sample and Reject ID below, the My metals button and the Delay slider
    Profiles, discrimination and pulse settings.
  6. 6

    Turn on the target ID (optional)

    In the same panel, switch on Target ID. The app balances again, and from then on every target shows an ID from 0 to 99 under the signal value, with a class: thin (below 25), medium or thick (60 and above). The tone gets higher with the ID.

    • Late sample (25 µs): how much later the second sample is taken. More gives clearer IDs but a weaker late signal.
    • Reject ID below: targets with a lower ID are still shown but don't sound or vibrate. Useful to skip foil.
  7. 7

    Teach the app your metals (Pro)

    With Target ID on, tap My metals. Each metal is learned with 5 passes over the coil: tap Learn, pass the object 5 times at the same height, and the app saves its ID window. From then on the detector shows its name, for example LARGE COIN · ID 76.

    • The speaker button next to a metal ignores it: it is still shown, but silent.
    • Metals whose windows overlap are marked; the app can confuse them.
    • A profile remembers the delay and late sample it was learned with. Make one profile per coil.
    My metals panel: profile Ø 25 cm, the ID ruler with the windows of the learned metals, and the list of metals with their ID, Ignore and Repeat buttons; Iron is ignored
    My metals: learned metals with their ID window. Iron is ignored.
  8. 8

    Set the battery range (with the battery meter)

    If you fitted the battery meter, in Settings › Battery settings enter the voltage of your battery when full and when empty (12 V and 10 V by default). The battery percentage on the detector screen uses this range, and the app warns you at 15 %.

The detector screen

  • Top buttonsFlashlight, sound mode (vibrate → sound → silent) and Settings.
  • Status barDetector battery %, the detector name and connection state, the Bluetooth signal bars. The gold crown means Pro.
  • B&BBattery voltage ("—" without the battery meter), and the Bluetooth module (tap it to choose another module).
  • D&FDelay and Frequency. Tap one, then change it with + / −.
  • SignalThe ring lights up with the signal strength; the number is how much the signal dropped. Under it: the target ID or the metal name. The trace shows the last 5 seconds.
  • Bottom barConnect / disconnect, the profile (opens the pulse settings panel), and the threshold.
  • + / −Change the selected value: the threshold, or the Delay / Frequency tile you tapped.
  • BalanceMeasures the background again. Keep the coil still and away from metal for one second.

Settings you can adjust

Pulse settings are in the panel that opens from the profile name. The firmware checks every value and limits it to protect the MOSFET and the battery.

SettingDefaultChange it when…
Delay (D)15 µsShorter for small, thin targets (more sensitive to ground). Longer on mineralised ground or a wet beach.
Frequency (F)200 HzHigher for a faster response (more battery). The firmware lowers it if the pulse doesn't fit.
Coil pulse (T0)120 µsLonger for more power and depth (more current). Limited to 5 % of the period.
Sample window (T2)26 µsLonger averages more of the decay: steadier, a little less sensitive to small targets.
Reads per pulse8More reads = less noise, lower maximum frequency.
Averaging16More = steadier, slower reaction. 8 reacts twice as fast.
Threshold40On the bottom bar. Higher if it beeps on nothing.
Target ID · Late sampleoff · 25 µsTurn on to see the ID of each target. More late sample = clearer ID, weaker signal.
Reject ID belowoffTo silence foil and other low-ID targets.
Reconnect automaticallyonSettings › Detection. Retries 5 times if the Bluetooth connection drops.
ThemeRedSettings › Theme: red or blue.

If something is wrong: where to look

Start with the line of text above the bottom bar: the app writes there what it is waiting for or what it found.

The Arduino IDE says "ISR was not declared", "SREG" or "OCR1A was not declared"
Arduino IDE › Tools › Board

Another board is selected (an ESP32, for example). Choose Arduino Nano and compile again.

"The detector sends no data"
Bluetooth module speed · power

The phone is connected to the module, but nothing arrives from the Nano. Check that the module was set to 38400 baud, the D0/D1 wiring (TX to RX), and that the Nano is powered and running (Serial Monitor over USB, with the module unplugged).

It can't connect
Settings › Set bluetooth module

Pair the module first and select it in the paired list. Allow the Bluetooth permission when the app asks. Only one phone can be connected to the module at a time.

"This detector doesn't identify itself as a Spirit Pi 5"

The module answers with another firmware. Load the Spirit Pi 5 firmware. An earlier Spirit Pi is recognised by itself and shows Connected · classic.

It beeps all the time, or gives false signals
Balance · threshold · delay

Balance with the coil still and away from metal. Then raise the threshold. On mineralised ground or a wet beach use the Mineralized ground profile or a longer delay. Check the coil cable and that the battery isn't nearly empty.

"Signal saturated"

The signal reaches the end of the ADC range. Balance away from metal, raise the delay, or check the analog board (the preamp gain and Uref). A single saturated reading over a big target is normal.

It doesn't detect anything
Oscilloscope on D7 · coil · Uref

Check that the coil gets the pulses (D7 and the MOSFET drain), the coil wiring and Uref. A very long delay also hides small targets: try the Original profile.

The battery shows "—", or the percentage is wrong
VREF_MV in the sketch · Settings › Battery settings

"—" means the detector doesn’t measure the battery: the optional battery meter isn’t fitted, or BATT_WIRED is 0. If the percentage is wrong: check that the 12 kΩ / 3 kΩ divider to A7 is fitted. Measure Uref on AREF and write it in VREF_MV. Then enter the full and empty voltage of your battery in the app.

"The detector adjusted a value…"

The firmware limits the pulse to 5 % of the period and makes sure everything fits in it. The slider jumps back to the value the detector really uses. That protects the MOSFET and the battery.

The target ID changes from pass to pass

Pass slowly, at the same height. Very weak or very deep targets give unstable IDs. Raise the late sample a little, and learn your metals again if you changed the delay, the coil or the late sample.

The detector's own speaker sounds while the phone is connected

The detector switches to its own speaker when it doesn't hear from the app for 3 seconds, for example if the app was closed or the connection dropped. Connect again, or turn the detector's volume to 0 with the buttons.

Something doesn't work? Tell me

Spirit Pi 5 is in development. Every coil and board is a little different. If a step on this page doesn't work for you, write to me and I'll fix it in the next update.

Please include:

  • Your phone model and Android version.
  • The firmware version (status bar: Connected · firmware …).
  • A few lines from the Serial Monitor, if the problem is in the detector.
  • What you did, what you expected, and what happened.