Published: August 04, 2014, Edited by: Mads Hobye

Make a virtual fence

Credit: Nikolaj Møbius

The same technology used to make virtual fences for lawn movers and dog fences can be replicated with an Arduino and a wire. We have designed such library.

This is an Arduino library that allow field sensing and data communication over a low frequency magnetic loop. The library allow the use of simple, easily obtainable, hardware to implement transmitter loop and receiver circuits. The library offloads the complex signal processing required for magnetic field sensing and data en-/decoding allowing both experienced and novice users to use this technique for yet-to-be-determined purposes.

Description

The magnetic loop is a length of wire surrounding an area from tens of square centimeters to hundreds of square meters. The loop can be excited with a low frequency (5 KHz) signal, either directly from microcontroller pins or via. an audio amplifier.

Once excited the magnetic field within, and in plane with, the loop will be virtually constant regardless of the location. Outside the loop the field will drop off with the distance squared. In close proximity with the wire (10 cm.) the signal will follow a specific profile of strong peaks and valleys.

By using a resonant ferrite antenna the signal from the loop can be picked up and its magnitude determined by sampling and processing the signal from the antenna.

By modulating the intensity of the field it is also possible to convey low rate digital messages from the loop to receivers within the field.

Applications may use either the presence, absence or magnitude of the signal to determine the location of receivers.

By using multiple antennas on a single receiver some degree of orientation may be obtained by comparing signals.
The low rate data capability can be used to differentiate between multiple receivers.

Possible applications

  • Robotic location/orientation
  • Theft prevention
  • (lost)Object location

What you need

  • Two Arduino boards (Preferably Arduino Uno)
  • Two 10k Resisters
  • 22 micro fahrad capacitor
  • 100 nano fahrad capacitor.
  • Coil / inductor: 10mH (cypax.dk part no: 07.055.0510)

How to

  • Download the library here.
  • Move the folder to your Arduino library folder.
  • Make the two circuits drawn below.
  • Upload example code from the library for Receiver and Transmitter.

If you want the virtual fence to work on a larger area then we recommend that you amplify the transmitter signal. This can be as simple as using a audio amplifier.

Circuit schematic

Limitations:

Currently the magloop library only supports one-way communication. Development of bi-directional communication may be possible.

Library repository:

https://github.com/dzlonline/magloop.git