Bird watcher with balena Fin (or RaspberryPi)

I wanted to play with my Balena Fin and make the famous Bird-Watcher but unfortunately, the documentation is a bit light to be able to reproduce it simply. So finally, I’ve decided to make a post about this project and the different steps to make it working.

The project is now deployed on a tree at home and waiting for some birds to be photographed.

Hardware involved

  • A balena Fin + Compute Module 3 (or a raspberry PI 3) – 60€ – 150€
  • A pi cam v2 – 20€
  • As an option a sound card extension – 20€
  • A bird house – 20€
  • Some 3d printed parts – 5 hours
  • Some screws – 1€
  • A long 12V power cable – 20€

So, this is basically a 200€ project.

Install the software

This part is the easiest one. Going to hub.balena.io and selecting the bird watcher, you just have a couple of clics to get it installed on a Pi. I’ve described this in my post on Balena Fin, so just take a look.

You need to select your device and configure the network. In my case, the device will be outdoor so I’ll use a WiFi connectivity even if WiFi could be setup in deployment, it seems this application requires to do it differently.

Once you deployed the application, you will see a WiFi network named BIRD-WIFI-AP. You can connect to that one from a smartphone or computer and go, with a browser, to the page:

http://192.138.42.1:8100

Here, you will get a form to select your WiFi and associated password.

Then I did not have a lot of the feature of balena io like the board monitoring and so on. So I did an update of the balena OS and the Supervisor. For this, select the board, then on the left bar, select Actions menu and then select BalenaOS update and Supervisor Update. For each of them, I’ve selected the recommended version and apply.

Create a bot on telegram to receive notifications

For this you need to have a Telegram account. Once you are connected to telegram, search in the contact BotFather. Its handle name is @BotFather.

Then you can ask for some commands listed above. As part of them, you can select

/newbot

Then the bot will ask you for a name. This one must finished by _bot. Once done, the bot will terminate by giving you an Access token. Do not loose this access token as it is the way to control the bot. And basically what we need for the next steps. The token is like 1702000000:AAG-xxxxxxxxx-xxxxxxx

Once you have this. In the Telegram app, search for your bot as for any new contact. And send a message to the bot… just like “Hello”

Once this done, you can use a browser and get the bot updates with the token obtained before.

The URL is (replacing the bold part by your token:

https://api.telegram.org/bot1702000000:AAG-xxxxxxxxx-xxxxxxx/getUpdates

This will respond something like this:

We need the chat.id field (17233xxxx) for configuring the application.

Now we can configure the application to use these elements: Go to Balean.Io dashboard. Select the device and go to Device Variables tab. there are two variables existing but set to 0.

  • TG_CHAT_ID – enter here the chat id find above
  • TG_TOKEN – enter the token created above

Configure the Balena application environment

Go to Balena.Io dashboard, then in ths Device configuration tab.

  • Search for parameter Define DT parameters set “audio=off”
  • Go to Custom configuration Variables and add:
BALENA_HOST_CONFIG_start_x = 1
BALENA_HOST_CONFIG_gpu_mem_256 = 192
BALENA_HOST_CONFIG_gpu_mem_512 = 256
BALENA_HOST_CONFIG_gpu_mem_1024 = 448

Without this setting, the camera will not startup.

Access the application to check result

Eventually restart the board from the balena.Io dashboard. Then you can make the device accessible through a public IP to access it.

Make the application accessible publicly

By clicking on the link on the right it opens a new tab and connect to the Pi through the balena VPN. You should see the camera over i (this don’t refresh on my side but working)

A message is send on telegram every time a bird is detected

So you finally get a telegram message on the bot with the name of the bird once identified. So apparently i’m a kind of Goldfinch when looking at my smartphone… may be the red color of the phone !!

So, the system is now working and the next thing to do is to install it somewhere outside where birds are. And for this we need to create an home for this gadget.

The balena fin new Home

I’ve found this little home I will have to hack a little to put the hardware and add some place for birds to come and get something for eating.

This tiny house it large enough to host a balena Fin + power supply. I will need to protect it a bit from weather.

I needed a casing, there are some cool one already made but the 3D printer is always ready for this and there is model available on balena github. Nice one but really big just to protect the board.

The Bird watcher project creator have made a simple one and finally it is the one I selected. You can get it from the Hackster page of the project.

This box allows to protect a bit the BalenaFin inside the bird house like you can show on the following picture. I also printed the top part to close the board inside. I just created a new hole on it to passe the camera connector as my camera will be placed in a new part I’ve been designed to make a door to the bird house and protect against weather.

To fix the PiCam on the bottom of my bird house door, I use some of the screws of my stock. Here are the dimensions:

  • M2 Inox A4 DIN 934 x 6
  • M2x10 Zinc DIN 965 x 2

I used 6x nuts to fix the picam as you need about 6mm spacing, so to not force on the cam lens and fix all of this correctly I had 1 nut on the picam pcb + one 6mm after + the one fixing the picam on the plastic door.

I can eventually share my bird door design but honestly it is not really nice and really made for this little house. So I’m not sure it is really useful. let me know in comments.

The last step is to protect the bird house from a risk of rain by closing all the holes with silicone seal and duck tape.

The bird watcher is ready for the rain

Final installation inside the box et last settings

BalenaFin Hardware installed, last lab test before installing outdoor

Once everything is inside the box we can install the last pieces like the seed tank. Then it’s time to pug it on and verify the camera is working.

On the first test, the camera was upside down. Don’t worry, I’ve been able to rotate the PiCam from the balean.io dashboard (no need to remove the fin from the box and make setups… just some clicks). So I created a new variable for the Camera container:

change the picam rotation from the balena.io dashboard

So once done, I’ve been able to verify my camera setting from the public URL of my bird watcher:

This is the view from the picam of the plush seen on the previous picture. Potentially the cam is a bit high … I’ll see on the field but currently it seems ok to go to the next phase of the outdoor deployment !

Outdoor installation

The main problem with a such system is the need for a power supply. I did the choice of putting the DC converted inside home and to have a long 12V cable from home to the nearest tree. I used a 10 meters cable. Not really nice, not well installed but this is working.

The bird watcher installed with its long powering cable

Now it is ready to feed some birds and take pictures. I still have one problem: the image is really blurry. This can be a problem during PiCam installation. I’ll see If it is good enough to detect some birds and have some correct photo with a short distance or if I need to investigate a bit more this problem. Let see that in a later step. I recommend to verify the camera settings before mounting. I did it by night and through it was related to the low light level, but it was not. And now, it’s a bit more complicated to fix.

Final Field installation

So I had to correct the blurry capture: i confirm that when you screw the piCam and create a pressure on the lens, you change the focus. I made a larger hole for the PiCam to reduce this pressure and also manually set the focus by turning the lens slowly. Now the result is good.

I can wait for some picture of the garden’s birds. Yesterday, they were eating a large part of the food but they did not left me any nice picture.

Optimization

Currently, after 3 days on the fields, I’ve got empty food recipient, many alert with no bird on it and watching live see part of bird in front of the camera. So basically, the camera position is not good in my initial design. So I made some improvement on the bird house:

Food recipient moved away and higher to be seen on PiCam

Basically I changed the food recipient to make it visible on the PiCam and get a better angle and distance to see the birds.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.