Introduction: Ultra Sound Cat Repeller Based on ATTINY85
Let be clear : I like cats. But I prefer when they poop somewhere else that in my garden.
I made a very simple ultra-sound emitter because cats are supposed not to like high pitch. It is triggered by a motion sensor and emitts about 15kHz.
I made tests with 15kHz and then with 20kHz. 15kHz made the best results but I confess I am not 100% sure that it will works in any case. The purpose is to disturb the cat to make it understand to find a better place... but some are stuborn.
The project is based on a ATTINY85 programmed with Atmel Studio. Be aware that it is not an Arduino based, I like Arduino because it makes things simple but it is not adapted to the ATTINY processors.
As usualy If you have no PCB making and processors programming skills I can provide you the fully assembled board. Just contact me here.
Supplies
For this project you will need :
- Skills :
- PCB components soldering
- ATTINY85 programming
- Eagle Autodesk basics for viewing the PCB
- 3D printing
- 3D printer
- Iron solder
- A glue gun
- Velcro
- A drill
- M3 tap
- For ATTiny programming
- an USBasp programmer (found on aliexpress)
- an ISP adapter
https://www.aliexpress.com/item/4001157691588.html?spm=a2g0s.9042311.0.0.53414c4dgBdTtM
- A motion sensor HC-SR501
- A ultra-sound speaker -> search for "51MM diameter Ultrasonic speaker waterproof" on aliexpress
- 4 NiMH accumulators, AA type
- A battery pack to hold the accumulators
- 6 M3-10mm screws and nuts
- A ON/OFF switch
- 1 *C0805 100nF capacitor
- 1 *Electro. capacitor 100uF, 2.54mm, max. 7mm diameter
- 8 *Pinheaders
- 1 *green LED 1206
- 1 *SOT23 mosfet (A03400)
- 2 *10k ohms resistors, 1/4W
- 1 *2.2k resistor, 1/4W
- 1 *momentary push switch
- 1 *ATTINY85, DIP8
- 3 *XH-2 connectors
- 1 *XH-3 connector
Step 1: The 3D Printed Housing
Designed with Fusion 360.
Print in 3 times :
- First the main housing
- The bottom
- The speaker bracket
I've used :
- White PLA, see note below
- 0.4mm nozzle
- 0.3mm layers
It took about 12 hours.
note : As the housing is designed to be outdoor, choose a clear color. Not dark because it will deform itself when the sun is hot.
Step 2: The Circuit
The circuit is powered by 4 NiMh accumulators, which provide about 4.8 V. It is a good voltage for the ATTiny and there is no need to use a regulator.
The reset PIN is quickly grounded when pressing the switch, through the capacitor : this effect is of course to reset the micro-controller.
PB3 is configured as OUPUT and binded directly to the speaker. Indeed the port can deliver up to 40mA, which is plenty enough for this kind of speaker.
PB4 is configured as INPUT and indirectly binded to the PIR sensor through the MOSFET Q1. Q1 acts as a level converter, because the PIR sensor delivers only 3V ouput.
The ISP port will be used to upload the code and I will show you how in a next step.
The LED is like the built-in LED on an Arduino, very convenient ;-)
Step 3: Make the PCB
I provide here Eagle files. I recommand OSH Park to make the PCB.
No difficulties for soldering, start with the smd resistors and led, then the push switch ... finish by the capacitor.
- I've soldered a DIP 8 socket to make the ATTINY removable
Attachments
Step 4: Prepare the ATtiny 85
The ATtiny needs to be configured before we use it. It is a processus that can be complicated but fortunatly Arduino has an option to help.
First of all let add ATtiny boards support to the Arduino IDE.
- Open Arduino IDE
- File -> preferences
- add https://raw.githubusercontent.com/damellis/attiny... in Additional Boards Manager URLs
- Then go to Tools-Board-Board Manager and install "attiny" by David A. Mellis
Tip : it maybe necessary to restart Arduino somewhere ... if it doesn't work.
Second :
- plug the USBasp programmer to the cat reppeler board ISP, using the adapter (see photo)
- on Arduino : select Tools -> Programmer and select USBasp
- then Tools -> Boards -> ATtiny microcontrollers -> ATtiny 25/45/85 family
- Tools -> Processor -> ATtiny85
- Tools -> Clock -> internal 1Mhz
- Tools -> Burn Booloader
Now the ATtiny85 is ready to upload the code.
Step 5: Upload the Code
The purpose in this step is to push the provided hex file into the ATTiny memory. The hex file contains the micro-code to run the microcontroller.
The tool provided by atmel to upload code is avrdude.exe. A command line program, not convenient because of the many possible options.
I found a graphical interface to make it easier : avrdudess, and I recommand it.
https://blog.zakkemble.net/avrdudess-a-gui-for-avr...
Follow these steps :
- Plug the programmer to your computer
- Open AVRDUDESS :
- choose USBasp as the Programmer, Port usb
- in the MCU section, choose ATiny85 or click on 'Detect'
- in the Flash section, browse your files and select cat_reppeler.hex
- check 'Write'
Attachments
Step 6: Assemble the Housing
- Make a hole in the housing for the ON/OFF switch.
- Tap the 4 holes for the bottom cover
- Mount the switch.
- Mount the speaker using the bracket and M3 screws + nuts
- With the glue gun, paste the motion sensor.
- Plug the speaker, the sensor and the battery pack to the PCB.
- Glue the PCB
- Velcro the battery pack
- Screw the bottom cover
Overview :
Alternative : you can use screws for wood to replace the M3 for the bottom cover. In this case don't tap the holes.
Step 7: Step 4.1 : Mount the Speaker
You need :
- XH-2 connectors (female)
- A special connector plier
- 4 M3-10mm screws/nuts
Connect to 2 wires to the XH connector, and solder the other end to the speaker.
Then use the bracket and the M3 screws/nuts to mount the speaker. The bottom nut is painfull to place, if you forget it never mind, it will be ok anyway and the speaker will be fixed hard enough.
Step 8: Step 4.2 : Mount the Motion Sensor
- 2 XH-2 connectors
- connector plier
Wire the XH connectors. Then place the motion sensor through the square hole, you need to force just a little bit to make it enter. No need to glue, it should hold itself.
Step 9: Step 4.3 : Mount the ON/OFF Switch
Make a 6mm hole at the back of the case.
Solder 2 wires on the switch and assemble a new XH-2 connector.
Screw the switch on the box.
Step 10: Step 4.4 : Mount the PCB and the Battery Holder
Wire a new XH-2 connector to the battery holder.
Use velcro to paste the battery holder inside the box.
Use glue gun to paste the PCB.
Step 11: Step 4.5 : Close the Bottom
You can tap the holes with M3 or use small wood screw.
The thin slit is made to let water pour in case it penetrates inside the box.
Step 12: The Code
I've started to develop this project with an atmega328 on an Arduino basis. Then I've wanted to reduce the size of my PCB and I've choosen an ATTiny85.
Unfortunately the ATTiny85 is not well integrated in the Arduino environment. So I had to write my code with ATMEL STUDIO.
Let me tell you basics explanations of how it works to give you an overview.
- PB3 is configured as ouput -> it is wired to the speaker.
PB4 as input -> it is the motion sensor input - An interrupt is set on PB4
- We use timer1 to make the cat reppeling frequency
- we know that timer1 counts at speed = 1 Mhz
- if we reset timer1 each 67 counts we get 1Mhz/67 = 15 Khz -> OCR1C=67
- let use PB3 as PWM with OCR1B=35 => when timer1 reaches 35, PB3 is toggled, and then toggled again when timer1 reaches OCR1C. This way we obtain a 15 Khz signal with a ratio that is about 50%.
What happens when running :
- Put the micro in power-down mode
- A cat is coming near the motion sensor :
- the sensor triggers PB4
- micro wakes up
- the interrupt routine is called :
- PB3 is set to PWM mode with 15Khz during 10 seconds
- stop that noise
To program a micro-controller is not an easy job, and the code is difficult to understand if you do not have the habit. So don't worry about that part, it is not necessary to finalize the project.

Participated in the
PCB Challenge
30 Comments
Question 2 years ago on Introduction
how much for a fully assembled board and how do I go about ordering and making payment?
Bill
Answer 2 years ago
Hello,
10 euros for the assembled PCB, plus the shipping depending on where you leave ?
Do you need also the speaker and the battery holder ?
Regards
Reply 2 years ago
Hello
my wife has actually shot down the whole idea, so won't be needing
anything.
thanks
Answer 2 years ago
hello
i am actually on vacation. i will check that for you and send you an answer soon.
michael
2 years ago
Thank you for all your comments. Just to precise some things :
- The sound is loud and disturbing only close to the speaker (about 1 meter). The purpose is to make an exclusion zone.
- Anyway cats will continue to visit your lawn, but avoid exclusion zones.
- I guess squirels will do the same. I have a visiting squirel and I want it to continue to visit my trees.
- It won't disturb neighborhood because it is definitetly not loud enough. I don't recommand to diffuse powerfull high pitch for that reason.
2 years ago
When they do their poop, they cover it. I don't see issues here. Also they help create natural fertilizers in your garden. Lol.
Reply 2 years ago
Not by me they don't, kids tend to play in gardens, some even like to play in the dirt, also, do some research, cat/dog poop is NOT a fertilizer as it contains parasitic pathogens and roundworms that can transfer to humans...
Reply 2 years ago
There are aerosols in stores. With their help, both are weaned (both cats and dogs).
Reply 2 years ago
Cat or dogs' poop are no natural fertilizers, they spoil the the soil.
In my case, the cat daily climb my car at night and sometimes poop on it. Yuck! I am looking for some real effective solution as I am desperate to keep it away.
Reply 2 years ago
Yes your right, But if you find more or less 10 -15 poops a day in your flower-garden - believe me - even as cat lover enough is enough.
Reply 2 years ago
:-) they should....., here they poop on the lawn and don't even look back, just walk away :-( :-(
2 years ago
The practical result is? A cat may be scared first time, but will soon return out of curiosity. I think a cat is too complex biological object for such simple scarers.
2 years ago
As mentioned by both spark master and MikeD11, it needs to be loud as well as inaudible to humans. Dogs get to complaining from ambulance sirens that are more than a half mile away and I'd bet it's not the frequencies that humans perceive that set them off. (And I didn't say build this or various versions thereof so that animals can hear it a half mile away.)
Also, don't turn the poop into the soil believing it's good fertilizer. What you have is not cow manure. If you have a flower garden then cat or dog poop isn't as problematic as if it is a vegetable garden, but, you don't want it either way. If it's a food source garden it's real trouble. I don't know if composting gets hot enough to kill the parasites and microbes so I wouldn't consider that an alternative either.
One last thing and I am going on a bit. There are cat whatevers, cat haters and cat lovers. I am in the last category. A few years ago I had 3 indoor/outdoor cats and when I would return home from work in the afternoon and park at the curb, all three came out to the parkway to greet me home. They would push each other out of the way to be next to me. Multiple neighbors who had dogs noticed this and commented that my cats liked me. This is because I never got mad at them, I talked to them constantly and when they wanted me to pay attention to them I did. (Yes they owned me like a pet dog and I came running with my tail wagging when they called.) Of those 3 cats only one remains. He's about 17 years old and has 2 lead pellets inside him because he came into the crosshairs of an a-hole. Due to Covid-19 I no longer work and he is now 95% indoors like me. It's safer that way. Thanks for listening to my rant.
I support sonic solutions or other non-harmful means to keep cats out of gardens and yards.
Thank you mdeudon for sharing this build.
2 years ago
Hope this works for dogs and lazy humans, cause I really don't like dogs peeing and pooping on my lawn with lazy owners not even bothering to drop off their little baggies of poo into the trash.
Reply 2 years ago
Hear! Hear!
2 years ago
These devices can be bought everywhere for little money. Building it yourself and pay probably a lot more is only for fun. Had several of these and they all annoyed neighbours only, not cats. An electric fence is the way to go
Reply 2 years ago
Yes because they all operate around 20kHz which is well in the human audible range. Mine start at 25kHz up to 50 kHz and disturb the cats, dogs and foxes only.
Now we've plenty of birds in the garden - it's a pleasure. They found out that there are less felines around. Cool.
2 years ago
Hi mdeudon, I had a similar issue and have built an own repellent. As you did. If you don't mind I'll share some findings. 15kHz is well in the audible range of humans. If you have neighbors then this sound, specially in the night, is going to be disturbing (own experience - I couldn't sleep because of that due to my own "invention"). Investigating I've found out that cats hear up to 65kHz. So I've build mine to start at approx. 25kHz and sounding up to approx. 50kHz (back and forth). The result is. astonishing and the neighbors and I sleep well now - 25kHz is well above the human hearing capabilities even for younger people.
Good Luck.
Question 2 years ago
Does it works on dogs too?
i think ill pay you to make one for me, i hate cats!
2 years ago
Nice work , but you can produce more irrating sounds with the transducers from https://myskunkworks.net/index.php?route=product/... and using an attiny85 from digispark.
https://www.instructables.com/Digispark-Attiny-85-With-Arduino-IDE/
This tiny mcu is programmable with the arduino IDE over usb and use the same sketch structure like a ordinary uno. So things could be simplified