{ % feed_meta %} Automated Electric Fence Status Monitoring - Part 1 | A Few Pinches of Salt

Automated Electric Fence Status Monitoring - Part 1

Since we installed an electric fence at home, we have had endless problems. This post is a follow-up from my first attempt at solving the problem in One Way Tracking Part 2. The fact that it is a home installation means that we are the people who need to maintain and fix the fence every couple of months. In addition to this, whenever it rains, the electric fence alarm has been set off. This is often due to leaves or branches of nearby trees getting caught on the fence and setting the alarm off. Sometimes it is due to dirt forming on the surface of the insulator from the wire to the rod keeping the fence up.

Some of this is avoidable with consistent trimming of the trees nearby, however, it is not always possible and the alarm does go off.

We have also experienced times when the fence simply turns off 1.

The Problem

Now that we have got an idea of what is happening, I needed to figure out how best to tackle the problem. Basically, it stems from the issue that the electric fence module turns off the electric fence output and will either alarm 2 or simply be off. This can be for a number of reasons (of which I won’t get into).

This leaves the issue with two possible cases:

In both of these states, the output to the fence is off. So, how do I solve this.

The Solution

There are a number of methods of approaching this issue, the electric fence provides the ability to install an add on module that has the capability of communicating with a security service 3. I do not like this approach as it would require the company to come out and evaluate the fence 4. In addition, this would cost money to keep running.

Barring the use of a product developed by the company, I need a way of monitoring the system myself. This means designing a solution that will be capable of monitoring the status of the fence at any given time and providing me with updates on the fence if it changes, the main goals can be as follows:

Simply put, the system needs to be able to reliably and continuously monitor the status of the electric fence periodically 5.

The last requirement stated in the list implies that the system needs to be able to provide the status of the fence from anywhere, which means the information should be accessible from the internet. This is particularly useful in cases that I am not at home and I am not connected to my intranet with direct access to the monitoring system.

The Design

In the previous post where I talked about this process, I since figured out that there is an additional LED that is a direct indicator of the status of the fence. This is the LED corresponding to the “ON” status. This is an LED that conveys the status of the fence at any given point in time.

In that previous post I stated that I could make use of a camera to continuously take images of the face of the module and do some form of computation on the image to determine if the LED is on or not. This is a fairly complex solution that will required setting up a camera at the fence 6.

I thought of another method of detecting the fence status which is designing a measurement device that measures the voltage of the fence, however, measuring this high voltage with simple and low-cost equipment didn’t appear feasible. In addition, I came up with a far simpler solution to the problem.

I knew that I could tell the status of the fence depending on whether the LED was on or not, so I simply had to design something that could tell me if the LED was activated.

I could do a measurement of the voltage across the LED 7 to determine if it is on or not. The difficulty with this method is that I would have to create a solution to get the measurement into the box while keeping the lid closed. The lid is used as an interlock to make sure that if the lid is opened, the fence immediately disables its output and turns off.

I didn’t want to be soldering onto the board or drilling into the box which would probably void the warranty and also be a hassle in the case that the module broke and had to be replaced, meaning I would have to start the process all over again.

So, I used a tried and trusted technology, the simple light dependent resistor (LDR). This simple electronic device changes its resistance depending on the light incident on its surface.

The LDR

The light dependent resistor adjusts its resistance depending on the level of light incident on the surface of the component. So, all that I need to do is to place the LDR onto the surface of the fence module and measure its resistance. This resistance is an indication of the state of the fence at any given point in time.

Put simply, the LDR can only be in any of two resistances. Each resistance corresponds to either the ON state of the electric fence or the OFF state of the electric fence.

Measuring the LDR

One cannot simply place a multimeter on the LDR each and every time I need to get the status of the electric fence, so I have to create a simpler method of monitoring this value. Fortunately, I can make use of one of the first circuit analysis tools any person is introduced to, the voltage divider.

Put simply, I will place a resistor in series with the LDR and put a voltage across the two components. Measuring the voltage across the point where the two devices interface will give me an idea of what the resistance of the LDR is, as I already know the resistance of the normal resistor.

All that this now needs is a voltage source and a voltage measurement, which is a lot easier and straight forward to monitor with the use of an Arduino.

The Arduino here is used as the 5 V reference voltage and then the simple use of the ADC built into the Arduino is used to measure the voltage divider circuit 8.

The system is currently set such that the LDR is connected to ground and the resistor to 5 V, this means that the voltage measured should be at one of two levels.

The exact voltage level does not matter much as it will be either a “high” or a “low”, I calibrated this during testing to know which range I should provide for the monitoring and status notifications. Essentially, if the voltage measured goes above a specified threshold, then I will set off the notifications.

To illustrate this simple circuit diagram, the following figure assists.

</embed>

The Communication Part

At this point I have an accurate method of continuously monitoring the status of the fence, however, I need a method of getting this information from the fence to the internet. Luckily I had access to an ESP-01 chip from a few years ago which provides the ability for the Arduino to connected to a Wifi network and communicate with the internet. I simply used this to communicate with a ThingSpeak channel and continuously send the voltage measured through to the internet through this channel.

This is a relatively simple process to get this value out to the greater world as I can continuously send the value through to some database on the internet.

The Notification Part

Now I need to create a system that is capable of notifying me of any changes in state of the electric fence.

I love the system that IFTTT has created as they have the ability to interface with ThingSpeak. This means that all I need to do is to connect my IFTTT account to ThingSpeak and create a recipe in ThingSpeak such that it will trigger the IFTTT recipe. This allows the recipe to send an email notification to my main email where I can see the status.

The Aftermath

Over the past couple of months, I have had this system up and running. It runs relatively flawlessly and provides me with an up to date status of the electric fence, giving me emails when the fence is off. I have successfully used it to notify my family when the fence turns off, even when I am away.

The only problems that I have encountered is my method of attaching the LDR to the face of the electric fence module. I have used duct tape to attach the LDR to the module and over time, the tape appears to lose its adhesiveness to the surface. Naturally this will happen as this piece of equipment needs to be rugged as it is outdoors and experiences extreme temperature swings, rain, wind, dust, etc.

I still have yet to find a failsafe method of keeping the LDR in place.

So far this system has performed quite well, providing timeous and reliable status updates of the electric fence when required.

  1. None of this is what you want happening with an electric fence as sometimes the alarm does not go off and we end up going about our lives without knowing that the electric fence has been off for long periods of time. 

  2. Silently or not, depending on how the fence is configured. The way that it is currently configured is that upon each power cycling, the alarm is turned on or off. 

  3. The electric fence module is a Merlin 4 from Nemtek, I have found two of their operating manuals online here, and here. There appear to be a few different versions of the system. 

  4. This also means that each time out fence is damaged, we would have to call out the repair crew which would cost money and generally be a hassle when we could simply fix it ourselves. 

  5. This parameter can be changed depending on requirements. Five-minute intervals should be more than sufficient to provide timeous information of the system. 

  6. At the time of writing, I have not been able to get a camera down at the gate yet. 

  7. And I suppose its series resistor. 

  8. The Arduino is powered with the use of a power bank; this helps for when the power goes out at the gate as the Arduino can run for an extended period of time.