Home Assistant Community

How to monitor electric fence?

#1

Hi,

We have an electric fence between our garden and the field next door to help keep cattle out of our garden. I would like to find a way of monitoring whether the fence is working and feed the status into HomeAssistant so I can trigger an alert if something goes wrong.

What I’m specifically talking about is checking that the fence wire itself is active - not just that the energiser is plugged in and switched on! Today I found that the fence had stopped working because the clip connecting the energiser to the fence wire had slipped and was shorting to earth - as a result, the cows were happily nosing at the wire even though the energiser was working fine! There are lots of other ways the fence could stop working when the energiser itself is still fine, such as a plant growing near the fence creating a short to earth or a physical break in the conductive fence wire itself.

The electric fence is a common commercially bought system (https://www.shockrite.co.uk/). It generates a very short pulse of approx. 7000 volts at a very low current every second using an energiser, which is then connected to a conductive wire which runs along the top of the fence. The conductive wire is insulated from the fence posts, and an earth wire is attached from the energiser to a ground stake nearby. If an animal (or person!) touches both the conductive wire and the ground they get a mild shock which discourages them from doing it again but does not injure.

Can anyone suggest a way of detecting whether the fence is working and feeding that status to HomeAssistant? I already use a number of Sonoffs running Tasmota for various sensor and switching tasks so that would be ideal. I guess some kind of simple wire coil could detect the high voltage pulse, but beyond that I’m a bit lost… The sensor needs to be weather proof but the fence runs close to a building (which also houses the mains-powered energiser) so only the bit at the fence itself needs to be outdoors.

Many thanks,
Tim

#2

In a nutshell, it’s a conductor that periodically carries a high-voltage, low-current pulse of electricity. You want a sensor that can detect this periodic pulse in order to confirm the system is functional. For example, if no pulse is detected for longer than 5 seconds, it suggests the system may be non-functional.

The first thing that comes to mind is a current sensor, the kind that just clamps onto the wire (often used for monitoring power consumption on the mains). However, this situation is the exact opposite of typical applications, namely it’s very high voltage but very low current. Therefore I’m uncertain a current sensor is the optimal solution.


EDIT
My suggestion to use a current sensor seems to be the way it’s done in commercially available systems. I found this vendor of a fence-monitoring product and the first photo clearly shows a clip-on sensor.
https://fenceguard.net/

#3

A little expensive but this one from a US electric fence manufacturer might provide a starting point.

#4

The simplest solution would be a voltage divider.

An earthed 10K 1/2W resistor with the other end connected to a string of series resistors to make up 33M Ohm connected to the fence conductor will generate 2V across the 10K resistor if the fence generates 7KV pulses.

Using many resistors to make up the 33M resistor prevents voltage breakdown and arcing across the resistor.

Looking at a typical 1W carbon film resistor data sheet it has a max working voltage of 500V. So that’s 14 resistors required. Include a safety factor of 2x and that’s 28 resistors in series to make up 33M. So 1.2M Ohms each.

Additionally, the string of series resistors could be sealed up in a bit of PVC pipe to prevent moisture on the surface causing conduction. Make sure to keep the low voltage tap wire well away from the HV string.

  Earth ----[10K 1/2W resistor]-----T------[1.2M 1W resitor x 28 ]-------Fence (7kV)

2V between T and Earth.

#5

A capacitor could help smooth the pulses too. Once you get a baseline voltage You could possibly detect reduced voltage due to weeds growing up.

#6

For an isolated method, stick a light dependant resistor over the 7kV neon bulb in one of these: http://www.zarebasystems.com/zareba-8-light-voltage-tester-rsvt8

Seal it from the light and moisture in an ABS IP67 rated hobby box.

#7

This would be cheaper :slight_smile:

#8

How is $36 cheaper than $16?

#9

Sorry, I overlooked the price. My Zareba fence tester was more expensive.
With yours multiple sensors could show rough voltage levels too.

#10

Though reading the description for yours it has a spark gap so no current is shunted to ground when someone/thing is touching the fence. The Zebra neon tester I linked to will continue to shunt some current and may reduce the effectiveness of the fence. It’s probably not meant to be permanently attached, unlike the one you linked to. Also an LDR will be more sensitive to white light than the orange of a neon. I reckon the EFL is probably a better solution.

1 Like
#11

A current sensor won’t work. If there is nothing touching the hot wire, no substantial current would occur.

The sensor in your link is not a current sensor, but is simply an alligator clip. Likely to a voltage divider to get the 5kV down to a measurable voltage. You could build something similar using a Wemos D1 Mini and put the low-voltage tap of the divider into the analog pin of the Wemos. I would put a 3V Zener on the analog input as well to short out any unexpected spikes. The Wemos can connect to your local network and send an mqtt status that your HA system can receive as a sensor.

#12

Thanks for some great ideas here.

Would something like a voltage divider network using high voltage resistors (found a range from Vishay which are rated to 3.5kv each) to get the fence voltage down to something manageable, then feed a capacitor so that the voltage spike lasts a bit longer to measure? Perhaps this could feed something like an INA219 voltage sensor to feed the Sonoff - but I doubt the capacitor will remain charged long enough to guarantee the poll time of the Sonoff will catch it. Maybe need to use a latch or similar?

Alternatively would a Hall Effect Sensor detect the pulse? Not sure, since if there is nothing touching the fence there’s no circuit and therefore no current will flow. Perhaps the inevitable leakage current will be enough (imperfect insulators, etc)?

Like the idea of using an off-the-shelf fence tester (I have one which shows voltage using 10 neons, 1 per kV) but again not sure how to capture the very short pulse - the neons don’t light all the time, they flash on in time with the fence voltage being high.

Thanks,
Tim

#13

The problem with the methods contacting the fence is that they all draw off some amount of the already small charge available - thus possibly reducing the effectiveness of the fence.

@bosborne’s find has a spark gap to circumvent this. If you are touching the fence there won’t be enough voltage to jump the gap and fire the light. So you get the full jolt.

As long as the pulse from the light and light dependant resistor are long enough for the sonoff to register you can work with this.

Just set up an automation to trigger and send you an alert if the sensor hasn’t changed in 20 seconds or so (state == off for 20 seconds). I’m assuming it pulses much more often than this but am allowing for missed pulses due to animals touching the fence.

#14

How about a coil antenna picking up the pulses from the wire, charging a capacitor through a diode, and bleeding off through a resistor? The resulting voltage should be possible to read through the GPIO of an ESP8266 or similar. Would probably be doable, albeit with a lot of tinkering with antenna lengths, values for R and C (and possibly quite a few fried ESP8266s in the process).

#15

Not quite sure what is meant by the statement’s “touching the hot wire”. I’ve used current sensors and they only require (appropriate) proximity. Physical (never electrical) contact may be needed in the event you need to wind the conductor through the magnetic core to improve detection.

#16

I’ve used electric fences before. They output 5kV at a few microamps, pulsed at a few microseconds once a second. The idea is to make contact uncomfortable- not lethal. It’s little more than the shock you get when you build up a static charge by scuffing your leather shoes on nylon carpet. No reasonable clamp-on sensor would detect this current, and that current is only present when current is flowing through the conductor- which only happens when something is touching the wire. Otherwise, it’s an open circuit.

To the purists, yes there is some leakage due to dust on the insulators or moisture in the air, but the current from leakage is measured in picoAmps.

When you plug in an extension cord to a 15-Amp circuit, there is no current flow through the extension cord until you plug in a load or touch the hot wire.

1 Like
#17

Thank you for taking the time to explain its operation in detail.

If the pulse is sent only when something contacts the wire (i.e. creates a ground path) then, I agree, a current sensor (no matter how sensitive) will be useless for monitoring the system’s health (i.e. it has nothing available to monitor until something touches the wire). Like you said, “It won’t work.”

I misunderstood the following statement which led me to believe the pulse is sent periodically, regardless of contact.

generates a very short pulse of approx. 7000 volts at a very low current every second

I now understand that statement implied ‘when contact causes a path to ground’.

#18

If there is enough current leakage to measure, something is touching the fence to partially ground it.

#19

The pulse is sent every second - but unless something is completing the circuit (such as a person or animal touching the fence wire and the ground) there is no current flow.

1 Like
#20

The term ‘send a pulse’ is a misapplication of terminology in the context of an open circuit.

The conducting wire’s voltage (measured with respect to ground) momentarily increases then decreases without, as mentioned, any current flow. Using the old metaphor of water flow, the height of the waterfall momentarily increases then decreases but no water flows over it. Nothing is “sent”.

To send a pulse implies the transmission of energy which, in this situation, doesn’t happen until the circuit is grounded (through a cow).