Arduino PetSafe Cat Barrier


Introduction: Arduino PetSafe Cat Barrier

Hey, all! I finally decided to write this as an instructable of my own - my first. To give proper credit, this project originated with user whyameye's original post on Sept. 2, 2013 - Original PetSafe Barrier Project. I built on his success, and used data he gathered on how the PetSafe "shock collar" system worked, and used an arduino to build my circuit to emulate his results with his 555-chip circuit.

I wired up an Arduino Duemilenove with the output NPN power transistor via a 1k resistor on pin 9, just as if I were wiring up a basic LED blinking circuit, then wired a 1k potentiometer in series with the output load wire loop to adjust field strength. All was powered with a 9V battery. (Note: if you need more field strength, simply wire the power supply for the TIP29 power transistor to a separate, higher DC voltage supply - maybe try 9V or 12V first. Remember to tie the DC- to the common ground)

I used the arduino timer1.pwm routine to generate the 10.5KHz during the on pulse, and a loop with 18ms on / 18ms off for the 36 ms pulse carrier wave. This emulates the astable multivibrator circuit whyameye created with his 555 circuit. Here is a the arduino sketch code:

* Astable multivibrator signal emulator

* for PetSafe fence


#include "TimerOne.h"

void setup()


pinMode(9, OUTPUT);

Timer1.initialize(95.2); // initialize timer1, and set a 95.2us second period (10.5KHz)


// the loop routine runs over and over again forever:

void loop()


Timer1.pwm(9, 512); // setup pwm on pin 9, 50% duty cycle

delay(18); // wait for 18ms

digitalWrite(9, LOW); // turn the LED off by making the voltage LOW

delay(18); // wait for 18ms


Step 1: Wiring the Breadboard Circuit

Step 2: Results



    • Woodworking Contest

      Woodworking Contest
    • Make it Move Contest

      Make it Move Contest
    • Microcontroller Contest

      Microcontroller Contest

    We have a be nice policy.
    Please be positive and constructive.




    Just wanted to say that this is an awesome project. In my case, the 1K resistor to pin 9 was too high, so I used a 100ohm resistor instead.

    I have a Pet Stop pet fence, so I had to change the period to 142.8us (7Khz) with a delay of 6.5ms (13 ms total).

    Thanks crazy1gadgets !

    1 reply

    Nice to know it worked out for you. I played around with the resistors, too, after I posted the project. Glad you were able to figure out the duty cycle for the Pet Stop pet fence.

    Any chance I can purchase this set up with the collar? I have an incredibly stubborn dog insistent on eating the cats food every day. I would love to shock him when he goes for the cats bowl.

    You are correct that setting pulse period to 160 us will get you to 6.25KHz. The fact that Vce only cycles between 3.8v and 5.2v (while Vbe cycles between 5v and 0v) is telling me that either your transistor or transistor circuit is faulty.

    Connect a 1K or greater resistor between your 5v power supply and the collector of the transistor, then measure Vce again as you cycle (1 second pulses again). You should definitely be cycling between 5v and 0v as all you have with your power transistor is a simple inverting amp (when you apply 5 volts from arduino pin 9 to the base, current flows across the base 1k resistor through the transistor to ground which saturates it, so it should "switch" the transistor CE pathway completely open connecting collector to ground - with only minor voltage drop, maybe .6v or so).

    Again, I would suggest taking the transistor completely out of the circuit and loop your wired + resistors directly to arduino pin 9, just to test response from your collar. I actually did this with my Arduino (see posts in Whyameye's original post on Sept. 2, 2013 - Original PetSafe Barrier Project), and measured about 9mA, well within the pin 9 current limit of 20mA. Get that to work, then add back the transistor to the circuit.

    Vc3 drops to 3.8 then to 5.2. Vbe drops to 0.

    All that being said my collar is definatly different. Some research on web shows its 6.25 KHZ. I attempted to change the 95.2 to 160 in the code to represent 6.25. However still no go. Ill try to remove/replace transister with adjusted code later on and see if that works.

    After digging around the web a while I came up with the fact that the collar I have uses 6.25KHZ. How would I adjust the code to equal this?

    Thanx in advance.

    Yeah, unfortunately the original design by Whyameye (see previous posts from over a year ago) were specifically for the PetSafe dog collar he had (I don't remember the model. It works with my PetSafe Cat Collar 300-648 (are you sure you didn't transpose your numbers above)?

    Interesting that your voltage drops from 5.2 to 3.8v each second. Vce should drop pretty much to zero when in the "off" state up to max voltage in "on" state. Try reading Vbe with your meter to see what you get. Better yet, disconnect the power transistor entirely and see what output your arduino puts out between pin 9 and ground. If that bounces between 0 and 5v then your arduino is ok, then it's probably a bad transistor.

    You may even be able to get the collar to trigger without the power transistor in place. Just connect the loop antennae wire between your +5VDC source and pin 9 but be sure to put your 1k resistor and the 1pot, and see what you get.

    Remember, the external transistor is only there to prevent too high current draw from the arduino board chip. There shouldn't be enough current to "fry" the chip, but you don't want to heat it up too much and wear it out. (I think I mentioned this in a previous post).


    I tried out the coughaway.pd from the other post. It did not trigger my dogs collar. Now i did not run an antenna. But i heard it form my PC and brough the collar very close to my PC. I think this collar might be working differently then the ones you guys used.

    Without a 'scope this may be difficult to troubleshoot. Does your multi-meter have frequency measurement capabilities (i.e. Hz)? Then you could see if you were getting an output at least in the loop.

    For the carrier square wave (18ms on + 18ms off = 36 ms period) you should be able to measure approx 28 Hz. The pulse is 10.5 KHz so you might see this as well depending on your settings.

    If you don't have a frequency setting on your multi-meter, you will need to at least see if you are getting any kind of output at the loop. I would suggest changing the carrier wave pulse to 1 second on, 1 second off, then you will easily be able to see output voltage at the loop turn on and off each second - change the last lines of your Arduino sketch to:

    Timer1.pwm(9, 512); // setup pwm on pin 9, 50% duty cycle

    delay(1000); // wait for 1 sec

    digitalWrite(9, LOW); // turn the LED off by making the voltage LOW

    delay(1000); // wait for 1 sec

    Once you can verify you are at least getting voltage at the loop, then go back to the original program, and try again. Let me know how it goes

    Best of luck!

    Just tried it today and cant get it to work. Only 2 legs of the POT get used correct? The middle leg going to the Transister?

    2 replies

    yes, the middle leg of the pot will go to the collector of the transistor. The pot will in this case function as a variable resistor only (rheostat). The other leg will go to the loop wire.

    Are you getting any results at all? Do you have a 'scope or multimeter to make any tests?

    I do have multimemter but no scope. Ill try it out once more. Does the POT setting only work in a small area? should i dial it up very slowly?

    Thank you for this! I am trying to cover a yard which is approximetly 100 feet x 100 feet- could you post a hint as to how I could power that perimeter wire? Thank you!

    Awesome. Thanks heaps for this. Will make it this weekend.