
When I first saw this project, I had mixed reactions to it. On the one hand, badgers are awesome. But on the other, they can cause absolute mayhem on your property if left unchecked. Many consider them to be a pest.
Lots of people resort to unscrupulous means to rid their gardens of mammalian pests, but James Milward decided to take a more friendly 21st-century approach. He used a Ring camera and vision AI on a Raspberry Pi to spot badgers and foxes in his garden and then scare them away safely.

I’ve spent a lot of nights photographing badgers, and they’re wonderful creatures. The European Badgers here in the UK, I mean, not those crazy things in the USA or Africa, India and Southwest Asia. But even though the European ones are a lot more friendly and subdued than their counterparts, it’s understandable why some folks don’t want them in their garden.
Aren’t there products available to do this already?
There are several off-the-shelf solutions available that perform these sorts of tasks, but they’re often not very reliable. James tried a bunch of those options before building his own. He tried scent marking repellant, mixes of citronella/chilli, and he blocked the entry points along his fences. I know from my own experience that last one doesn’t work. Badgers just dig under or around them.
When he tried the ultrasonic repellants, though, he found a glimmer of hope. He placed several around his garden but noticed some issues. Namely, they have different modes for different pests – foxes and badgers require different settings. They run 24/7, so they’ll often trigger when they’re in the garden themselves. They’re typically solar-powered, charging up the battery that runs all night. In the UK, solar power isn’t too reliable for obvious reasons.
But it gave James the inspiration he needed.
In steps 21st century technology
The advancements in single-board computers like the Raspberry Pi (buy here) and microcontrollers like the ESP8266 (buy here), not to mention the massive leaps made in AI – and specifically vision AI – over the past few years, present us with other options.
This is the technology that allowed James to take his ultrasonic repellers to the next level. Using the TensorFlow tutorial below, he was able to have his Ring camera talk to a Raspberry Pi, automatically detect when a fox or a badger was in view, and then trigger the ESP8266 to tell the ultrasonic sensor to do its animal-appropriate thing.
Adding AI vision to a project is always a pretty daunting task when you’ve never done it before. But in this case, it overcomes all of the problems James experienced.
The benefits of AI Vision
It’s going to not only detect movement, but it knows what that movement’s from. Even if it’s not moving, and just sitting there, it can still detect whether it’s a fox or a badger. This means he can tell the ultrasonic deterrent to play the correct frequency for the animal in question.
It also means that even if he leaves it on 24/7, it’s not going to be going off during the day while he or his children are in the garden. It’s not going to detect them as foxes or badgers, so it doesn’t waste battery power when it doesn’t need to.
And while it doesn’t technically solve the solar charging issue, the reduction in battery use means that when the UK sees a little sun, it doesn’t need to charge the battery up as much to top it off, helping to ensure it runs for longer.
It’s a great, if geeky, solution to keeping your garden free from “pests” that’s ultimately harmless to the animals. Sure, the noise might upset them, but they’re eventually just going to stop entering the garden without injury.
Want to make your own?
James has made all of the source code and details to build your own available on GitHub. He’s also posted a complete write-up of the project, going into more detail about the underlying principles involved in making it all work. He also talks about some of his plans for the future with this system.
If you’ve been thinking about using your cameras – any of your cameras, not just Ring cameras – with AI vision, it’s a project that’s well worth checking out!
FIND THIS INTERESTING? SHARE IT WITH YOUR FRIENDS!