AI Scarecrow - Makes Noise When It Sees Birds

by Arpan Mondal in Circuits > Arduino

578 Views, 7 Favorites, 0 Comments

AI Scarecrow - Makes Noise When It Sees Birds

Instructables_thumbnails.png
IMG_20241122_162418374.jpg
FJB1BZ5M3VM0WP3.jpg
image.png

In Bangalore, where I live, we have a bit of a pigeon problem. Pigeons are everywhere. Everything the light touches is their kingdom. And since we recently moved to a new house, and the balcony isn't protected by nets, the pigeons have turned it into their personal restroom. I clean it one day, and by the end of the day, it's covered in droppings again. The issue is, I can't stay home all the time to keep driving them away. I go to work for most of the day, giving the pigeons a nice time.

Now, you can't call yourself an engineer if you can't find an overengineered solution to any problem. So I made this AI scarecrow! It uses an AI camera to detect birds and, when it does, it produces a loud noise designed to annoy those pesky pigeons.

Let me show you how I made it.

Supplies

Grove Vision AI v2 Kit - with Raspberry Pi Camera and, Seeed Studio XIAO: Purchase link

PAM8403 audio amplifier: Purchase link

A 5 watt speaker: Purchase Link

USB C wire

Double sided tape

Jumper cables

Soldering iron

Glue

Get the Design Ready

IMG_20241122_142501596.jpg
IMG_20241122_142716625.jpg
IMG_20241122_142930243.jpg

I started by creating a design for the scarecrow using Canva, which I then had printed on hardboard.

The first step was to cut out the eyes, as this is where the camera would see through. However, I later realized that I didn't need to cut them out completely; just a hole in one eye would be enough.

Next, I moved on to the hat. I carefully cut out the buckle area, as this is where the speaker would be placed.

Prepare the AI Module

IMG_20241122_152920702.jpg
IMG_20241122_152929315.jpg
IMG_20241122_153809581.jpg

The Grove Vision AI module is a very useful little device. It can be trained to detect all sorts of things like humans, pets, gestures, toilets (really?), and much more. Check out some of the pre trained models here: Sensecraft AI.

To begin, connect the cable to the AI module in the direction shown in the first image.

Then, connect the other side of the cable to the Raspberri pi camera like in the second image.

Now we can start uploading the model.


Upload the Bird Detection Model

Screenshot 2024-11-24 194123.png
ScreenRecording2024-11-22152534-ezgif.com-optimize.gif
IMG_20241122_151646799.jpg

Head over to Sensecraft AI models page and search for bird detection. Make sure to only use the models that are made for Grove vision AI module v2!

Although there is one named "Bird recognition", I noticed that it doesn't work very well. Instead, I suggest using the "Wild bird detection" model. I know pigeon is not a wild bird, but it still works.

Now, connect the AI module to the PC with a USB-C cable and click 'connect device'

You may be asked to choose your device by the browser. Select the right port (there should only be one) and submit.

Refer to the GIF for the complete steps.

Test the Model

Screenshot 2024-11-22 153114.png
Screenshot 2024-11-22 153159.png

After the model is completely uploaded, you should see the camera feed on the webpage. Beside it are some text which shows what the AI module is seeing.

I searched for pigeon on Google images and showed it to the camera (I know there are already a lot of pigeons, but just to test it, I didn't want to take the whole PC outside).

As you see in the images, the AI module has no problem recognizing them (as wild birds for some reason).

The number on top of the red square shows how confident the model is about its recognition.

Solder!

IMG_20241122_151329655.jpg
IMG_20241122_151428300.jpg
IMG_20241122_155126656.jpg
IMG_20241122_153556571.jpg

The part we all hate, but can't live without. At least, to make it quick, we'll solder everything in one go.

Solder the male headers to the Xiao esp32. This is time-consuming and difficult, but every single one needs to be carefully soldered. Make sure not to short any two pins!

Then, push the Xiao into the female headers in the AI module. Make sure the USB-C port in the Xiao is facing the same direction as the one on the AI module.

Then solder one wire from D2 of the Xiao. I did it on the AI module itself, as it was easier. Also, we need to solder one wire from 5v and one from GND as well to power the amplifier.

Solder wires to the L, G, R inputs, 5v positive and negative, and any one of the outputs (R or L) on the PAM8203 audio amplifier.

Oh, and I forgot to take a picture. You might need to solder wires to the speaker as well.

The Eye Hole!

IMG_20241122_155701525.jpg
IMG_20241122_155749558.jpg
IMG_20241122_160323247.jpg

Well, thanks to my mistake in cutting out the entire eyes, I had to stick black paper over them.

Only one eye needed a hole for the camera to be positioned behind it.

Upload the Code to the Xiao

IMG_20241122_153659612.jpg
Screenshot 2024-11-24 184829.png
Screenshot 2024-11-24 184935.png

Use the code attached below for the noise generation.

Make sure to install the Seeed Arduino SSCMA library.

The code basically checks if there are any boxes of size greater than zero in the camera feed. Those are the red boxes that appear when the AI module detects a bird. In case you only want to detect nearby birds and ignore the far away ones, you can specify the box size.

When it detects the box of size > 0, it calls the makeNoise() function. This function basically generates a random high frequency pulsating noise. I asked ChatGpt what frequencies annoys pigeons. Based on the suggestions, I updated the frequencies. If you'd like to hear how it sounds, check out the simulation I created on tinkercad.

Downloads

Assemble

IMG_20241122_161049141.jpg
IMG_20241122_161043916.jpg
IMG_20241122_161431140.jpg
IMG_20241122_162014578.jpg

Finally, it's time to assemble all the components.

First, position the camera behind the eye hole and stick the AI module beside it with double sided tape.

Then stick the audio amplifier beside the AI module with double sided tape.

Connect the wire from D0 to the R input of the audio amplifier. (In case you are using Left output, connect it to L input)

Connect the wire from GND to G input and 5v negative terminal.

Connect the wire from 5v of Xiao to the 5v positive of the amplifier.

Finally, connect the speaker to the audio amp output.

I stuck a piece of thin black sponge behind the hat buckle and position the speaker on it.

Enjoy a Clean Balcony :)

IMG_20241122_162411874.jpg
IMG_20241122_162438932.jpg
FIP4WGIM3VM0CLZ.jpg

Now, anytime the AI scarecrow detects a bird, it makes loud noises to drive them away. Initially, I noticed that the scarecrow would detect birds from far away and start making noise. To avoid this, I repositioned the scarecrow so that the camera feed only shows the balcony and not the area outside it.

Although, increasing the threshold bounding box size can also help fix this issue by ensuring that only birds within a certain proximity (bigger than a certain size) trigger the scarecrow.

However, there's a downside to this setup. The loud noises can be annoying to neighbors. So, I had to keep the volume at a lower level.

Does it work? Well, yes and no. Initially, it did drive the pigeons away. However, once they realized it was just random noise every time they came, they started to ignore it. On the bright side, I noticed they don't stay long in the balcony anymore, which is a plus.

I'm open to suggestions on how to improve this setup. One idea I had was to use a vibration motor to vibrate the clothes hanging lines they usually land on.