AI-Powered Bird Sprinkler
June 27, 2026
code: https://github.com/mattsahn/bird-away
I live in NYC and my parents have a house in Florida with a pool. The pool attracts a lot of birds and it was getting to be a bit of a problem with their associated output. We tried a few things (fake owl, floating alligator head) to keep them away, but birds are smart and determined and those did not work for very long. When I was there, I would sometimes sneak up on them with a hose and that would scatter them pretty effectively (except for one large duck that seemed to enjoy being drenched by a hose). So, I had the idea of automating this process as a fun project.
The Idea
Simple. Have a camera pointed at the pool, take pics in a loop, have AI analyze the pic and return “yes” if there are birds in the pic, trigger a sprinkler with relay via GPIO on a Raspberry Pi. For extra credit, also save pics/video to the cloud so that I can get the satisfaction of seeing it work.
The Hardware
- Raspberry Pi 4 on home Wi-Fi — runs the Python monitoring service
- IP camera — aimed at the pool, connected on same Wi-Fi network
- Relay module — wired to GPIO pin
- 12V solenoid valve — on its own 120V power supply, switches on by the relay for set duration
- Sprinkler head — connected to water supply, aimed at pool
- Status LED button — heartbeat-blinks while the service is running to give positive indication IRL. Also can trigger a manual run.
How It Works
A Python process runs on the Pi and is set to start itself whenever the Pi starts, so that it is resilient to power restart. It connects to the IP camera using RTSP protocol and captures an image every 2 mins. It posts this to OpenRouter as an API call along with a prompt asking if there is a bird in the picture. The AI model will respond with either “yes” or “no”. If “yes”, then the service will start recording a video clip, sleep for a few seconds, then power on the sprinkler relay, keep it on for 5 seconds, keep recording a few more seconds, and then post the image and video to an S3 bucket.
Cloud Stuff
The whole payoff is seeing birds get sprayed and startled. So, capturing this for posterity was key, and in a way I can see it remotely from NYC to admire my creation. I also need to be able to login to the Pi to maintain it, make changes and new features, etc, without being there. For remote access, I use Raspberry Pi Connect which is free and allows me to login to a shell from any internet browser. $0. awesome. For visual evidence, the process will upload the still image when bird detection triggered and a video to Cloudflare R2 service which has a generous free tier. For ease of viewing, I created a simple webpage that organizes and displays all the snaphsots and links to videos so that I can check from my phone anytime. The page is deployed on Vercel, also free.
The web dashboard: each card is a detection with a thumbnail, timestamp, and link to the video clip
Engineering Notes
Heat management
I was very concerned about heat in the florida sun baking the Pi in the plastic enclosure, and took a lot of measures to try to manage heat. For the Pi, I got an alumininum case that thermally connects to the processor and passively dissipates heat:
But, I needed that heat to not accumlate inside of the plastic enclosure, but also keep it waterproof, so I cut out an opening in the enclosure and caulked it in so that one side of the case is exposed to the atmosphere so heat can go there:
For good measure, I added some reflective tape as well to bounce off the most intense direct sunlight:
The Pi will tell you the temp of the processor, but I also want to know the ambient temp inside the enclosure, so I added a temperature/humidity sensor, which lets me see that. My goal is for processor to stay under 140°F and for enclosure to stay under 120°F or so, then all is well.
Zero SD card writes
Raspberry Pi SD cards go bad when you write a lot to them and i’ve experienced this quite a lot over the past decade of doing home Pi projects. So, I have this setup to basically not write anything to the filesystem/SD card. The app logging is all in memory and same for the pics and video files. I can read logs when i’m connected with a service command and I don’t care about storing the image/video locally at all, they are uploaded to the cloud. I really want this thing to last and run for months on its own and this should help a lot.
Remote monitoring
I added a free healthchecks.io monitoring setup to send periodic heartbeats. If/when these stop, I get an email alert.
AI stuff
Picking and tuning an AI model ended up being a project in itself. This system relies on running inference on images a lot - like thousands of times a month, so cost matters. I’m not interested in spending $100/mo to spray birds. So, I had to do a whole lot of evaluation of different models as well as experimenting with downscaling image sizes. I did this fairly scientifically by capturing a handful of “bird” and “no bird” images, scaling to some different sizes, and running against a number of different models via OpenRouter. OpenRouter was pretty key for how easy it is to swap models with a single API and account/billing. I wanted a model that accurately detected birds and no-birds, and costed as little as possible.
The winner?
gemma-4-31B-it - This is an open-weight model and only costs me about 60 cents per month! For 10,000 images analyzed! I was pretty shocked I was able to bring the costs this low to less than $10/year.
OpenRouter billing page. Look how cheap!
My prompt:
You are a bird detector for a backyard pool. Respond with exactly 'yes'
if you see one or more birds in, on, or near the pool in the provided photo.
Respond with exactly 'no' otherwise. Output only the single word.
Results
The thing works! It’s detecting and spraying birds and (usually) shooing them away. Ducks are tricky. They DGAF about being sprayed for the most part. I guess being comfortable with water is kind of their thing, so i’m thinking of other deterrents I might add to complement - like a blast of ultrasonic sounds or something. What i’m most looking for is reliability and so far, so good.
Full source code and much more detail here: github.com/mattsahn/bird-away.
Questions or feedback: open an issue on GitHub.