Add Camera and Lights to a Bluebird Nesting Box

by imageguy in Circuits > Cameras

758 Views, 5 Favorites, 0 Comments

Add Camera and Lights to a Bluebird Nesting Box

2022-06-15_15-34-58.jpg
2023-03-07_14-40-10.jpg
2023-03-07_14-39-37.jpg

A couple of years ago we put up a bluebird nesting box. It was a great success - we had two clutches of chicks each summer. Pretty soon, though, we started wondering, "What goes on in there?"

The second summer we added a Raspberry Pi controlled camera to the nesting box. The birdhouse is close enough to the house to get our WiFi signal, so we could control the camera and watch what goes on from the inside. The setup worked, but lighting was a big problem. We didn't realize most of the light during testing came from the drain holes and, once the nest covered them, it was pitch-dark in there. We solved this by occasionally creeping close to the birdhouse and shining a battery at the entrance, but we could do this only very rarely to minimize disturbing the nest.

This Instructable shows how to make our second iteration of the camera, with 3D printed housing and LED lighting.

The main design issue was not to disturb the nest with strong lights. If you watch the nature documentaries, they show nests lighted like it was in the middle of film studio, but we don't know how they actually do this. For this reason, the circuit contains a potentiometer, so the light intensity can be controlled. All the parts of the circuit, except the camera housing, are in external housing and can be tweaked without disturbing the birds.

This assumes that your birdhouse, like ours, is close enough to a building with power and WiFi. Ours is powered with an outdoor extension cord.

You can find all the project files in my GitHub under birdhouse, including sources, shell scripts and Fritzing project. My Fritzing parts repository on GitHub contains any non-standard Fritzing parts I used.

Have fun! And if this is too big of a project for your liking, take a plunge and at least make a birdhouse - birds will appreciate it and it will provide endless fun as you watch coming and going.

Supplies


Raspberry Pi Zero 2 W. As of this writing, March 2023, supplies of Raspberry Pi are still incredibly constrained. I got the Zero 2 W used in this project on EBay last year and paid pretty penny. Check out the rpilocator website - it scours the Pi sources throughout the world and shows you what's in stock. You don't need a Zero - I used a 3B last year. But larger form factor needs a larger housing and makes it harder to attach the camera connector - the stock camera ribbon cable is just barely long enough and you might have to buy a longer cable. Note that Zero 2 has a smaller CSI ribbon cable connector and comes with a cable where one end has a Zero 2 connector and the other the regular size connector.

SD card for Raspberry Pi.

Raspberry Pi power supply. I found the hard way that a regular USB power supply is not strong enough. The voltage tends to be too low (Pi wants 5.25V), the Pi comes up in the sense that the lights are on, but it doesn't connect to WiFi. Any Pi power supply will be fine, but one that has connector inline with the plug, as opposed to at 90 degrees, will fit better into a small housing.

Outdoor extension cord.

Arducam OV5647 Sensor

1K 2W or similar pot

3.3Ohm 10W resistor

STP55NF06L MOSFET

15KOhm 1/4w resistor

10 pieces 5mm white LED

white enamel paint

50mmx20mm or similar piece of project board

28Ga or similar wires

headers and connectors

shrink tubing and/or liquid electrical tape

1/4in plywood for the housing

Pieces of 1/2 in plywood for the housing skeleton

Oil based polyurethane or some other means to waterproof the housing

4 M4 30mm or similar screws, with wing nuts, for securing the housing cover

8 M3 12mm screws for the housing

1 M3 8mm screw and nut

a piece of galvanized sheet metal for the mounting bracket

two small wood screws to mount the bracket

two smallish wood screws to attach the housing to the birdhouse

hot glue or similar adhesive

The Circuit

Screenshot from 2023-03-07 09-19-44.png
Screenshot from 2023-03-07 09-21-16.png
Screenshot from 2023-03-07 09-21-28.png
2023-01-27_14-31-31.jpg
2023-01-27_15-33-17.jpg

Attached Fritzing screen shots show Raspberry Pi 3B instead of Zero 2 W, since that's what's available in the parts library. Zero 2 W has the same pin layout.

The circuit is powered from the Pi 5V pin. This will reportedly provide all the power delivered by the power supply that is not used by the Pi itself. Zero 2 W uses less than 600mA (3W), leaving ample power for the LEDs. We use pin 4 to turn the LEDs on and off.

We want to make sure the lights are off unless we really want them on, so we add a 15KOhm pulldown resistor to pin 4. Current goes from the 5V pin through resistors to LEDs wired in parallel. Finally the connection to ground is turned on and off via MOSFET driven by pin 4.

To control the brightness, we add a potentiometer, backed up by a 3.3Ohm resistor. I am using a 10W resistor and 2W pot. 10 LEDs draw a fair amount of current, so the 1/4W resistors we usually use will melt. 10W is oversized, but better safe than sorry. The backup resistor is really just in case, since the power provided from the 5V pin is not too much for the LEDs.

Potentiometer is to dim the lights if necessary.

MOSFET, pulldown resistor and the backup resistor are soldered to the project board, as are wires connectiong to 5V, Ground and pin 4 on Raspberry Pi. Headers provide attachment for the pot and LED power wires.


Make the Camera Housing

2023-01-02_16-10-57.jpg
2023-01-02_16-11-05.jpg
2023-01-02_16-12-02.jpg
2023-01-01_14-42-19.jpg
2023-01-01_14-45-45.jpg
2023-01-06_14-27-15.jpg
2023-01-06_15-52-19.jpg
2023-01-06_16-08-23.jpg
2023-01-06_15-04-30.jpg
2023-01-06_16-09-34.jpg
2023-01-06_16-35-50.jpg
2023-01-02_16-25-40.jpg

If I was building the birdhouse from scratch, I'd have added a little more height to accommodate the camera. Since we are adding the camera to a regular birdhouse, built to standard specifications (a quick search will yield a plethora of plans), it's important not to interfere with the birds going in and out. This means the camera housing needs to be as thin as possible and mounted as high as possible.

I printed the housing using PLA, but almost any type of filament will do, since the camera housing is mostly protected from the elements in the birdhouse. The housing is not waterproof by any means, since the openings are not filled in. The base and cover are attached using M3 screws. No nuts are needed, the screws will grip the plastic in the base holes. Depending on your print quality, you might have to enlarge the holes a smidge using a drill.

A word about the order of operations. This Instructable shows painting the LEDs first, then mounting them onto the housing, then soldering and shrink wrapping. It is much better to loosely thread the LED connectors through mounting holes, then solder and shrink wrap. Then the LEDs can be glued in without soldering and shrink wrapping melting the hot glue over and over. Paint the LEDs last.

One of my concerns was that the LEDs will be too glaring and disturb the birds. I painted LEDs over with a thin coat of white enamel, getting much nicer illumination.

Since space is at premium, it might be better to use liquid electrical tape instead of shrink wrap.

Make the mounting bracket from thin galvanized sheet metal. Make sure that the holes for the mounting screws are accessible when the bracket is attached to the camera housing. Once mounted, the bracket can be bent to adjust the camera field of view.

To assemble the housing, attach the camera back to the mounting bracket first, then arrange all the wires and tighten the eight M3 screws. It will be a tight fit.

Make the Controller Housing

2023-01-10_10-21-07.jpg
2023-01-10_10-21-16.jpg
2023-01-10_10-21-25.jpg
2023-01-10_10-21-32.jpg
2023-01-18_13-33-37.jpg
2023-01-18_14-46-16.jpg

I built the housing from 1/4in (nominal) plywood, 85mm wide, 90 mm deep, 170mm high in front and 230mm high at the back It has a overhanging roof. I used strips cut from 1/2in plywood as a skeleton, then attached everything using wood glue and finish nails.

The cover is attached using four M4 screws. Heads are inside, fixed in place with hot glue. I use wingnuts for easier removal. Top of the cover is beveled to fit the roof slope, while upper screw holes are enlongated a bit so the cover can be angled during attachment.

A hole for the power cable is at the front left corner.

Two small screws through the back wall attach the housing to the birdhouse.

if you use a really thin plywood like I did, you might also waterproof it. I used oil based polyurethane.

Mounting the System

2023-01-07_15-46-37.jpg
2023-01-18_13-28-33.jpg
2023-01-18_13-28-41.jpg
2023-01-18_13-29-56.jpg

How you mount the system depends a bit on how your birdhouse is constructed. In my case, it's attached to a 2inx2in vertical post, leaving plenty of space to mount the housing on the back of the birdhouse. You can see a short section of such a post mounted onto the birdhouse to help me position the housing.

One of the sides of the birdhouse opens for cleaning. I chose to mount the housing on the other side though, in retrospect, all the cable routing would have been easier if the controller was mounted on the opening side.

To help prevent water coming in, the wires are routed through a slot cut in the birdhouse back wall using a vibrating saw. Mount the camera in the middle of the birdhouse, as close tho the back wall that you can. The field of view can be adjusted by bending the mounting bracket. Once you have the holes for mounting wood screws, cut the slot for the wires as close as possible to the camera mount.

Once you have the slot in the birdhouse back wall, position the controller housing over it as high as it will go and mark the position corresponding to the slot. You'll notice that I haven't done this as well as I could have, so my slot is a little higher in the housing than it could have been - the higher the slot, the harder it is to attach the ribbon cable to the Pi.

If possible, cut both slots so they angle slightly downwards going out of the birdhouse and the housing. This will help prevent water coming in.

Cut the slot into the controller housing back. Position the housing so the slots match and drill the mounting screw holes. You are now ready to attach everything.

Thread the camera ribbon cable and the LED power wires through the slot. You might have to widen the slot a bit with a drill to pass the connectors through. Thread the cables through the slot in the controller housing. Pull the wires through until the housing is flush to the birdhouse and attach the housing with screws.


Configuration and Final Assembly

Screenshot from 2023-03-07 09-22-34.png
Screenshot from 2023-03-07 09-24-37.png
Screenshot from 2023-03-07 12-31-14.png
Screenshot from 2023-03-07 12-31-23.png
Screenshot from 2023-03-07 12-31-32.png
2023-01-27_15-25-28.jpg
2023-01-27_15-25-17.jpg
2023-01-27_15-35-30.jpg
2023-01-18_14-26-22.jpg

We configure the Rapberry Pi next. We'll make a headless system, meaning we won't attach display and keyboard. I assume you have a computer available. I used Linux, but Mac or Windows will work as well, though some details might vary. We'll connect to the controller using ssh, so make sure you have that configured on the workstation you'll be using. It would also be really handy to have a public key set up for easier connection later.

Attach the SD card to your workstation. Note that the following will erase any contents. We'll use rpi-imager to wrote the operating system. Download the rpi-imager for your operating system from the Raspberry Pi site.

Start the rpi-imager and select the operationg system version (whatever default it offers on top) and the SD card to write to. Open the advanced settings. Set the host name, allow ssh, allow password access, set the password and configure WiFi. Write to SD.

Insert the SD into your Pi and power it up. It should show up on your local network. Log in via ssh. We now need to configure the camera interface. These cameras use "old style" interface that has to be activated. Start raspi-config via

sudo raspi-config

Enable "legacy camera support". Make sure you have python installed.

If you have generated a public key on the workstation you plan to use to control the birdhouse, copy it to the Pi by using ssh-copy-id, which should be a part of your ssh installation. You can now log into birdhouse without having to type in the password.

A word of caution. Do not set up the birdhouse with a public key access to your workstation. Birdhouse is out there in the open and someone might clone the SD card and use the credentials to log into your box and cause all kinds of havoc.

You can now connect the Pi to the camera, the lighting board to the Pi and the LEDs to the board, plug in an outdoors extension cord and turn the system on. Use pin4on.py and pin4off.py to turn the lights on and off. Close any holes in the birdhouse and tweak the lighting using the pot. Close the controller housing cover.

Downloads

Final Steps

2023-01-18_14-46-41.jpg
2023-03-07_12-26-13.jpg
Screenshot from 2023-03-07 10-52-05.png

I have a couple of things that make managing the system easier.

takepic takes a picture, saves it as JPEG and names it as a time stamp.

scplast copies the last file to the chosen location on your workstation (this assumes you accept incoming ssh). You need to edit the script with your data.

If you want to watch live video feed from the birdhouse camera, install gstreamer on both the birdhouse controller and your workstation.

My current Pi configuration had trouble installing gstreamer. The following command worked:

sudo apt-get install $(apt-cache --names-only search ^gstreamer1.0-* | awk '{print $1}' | grep -v gstreamer1.0-hybris | grep -v gstreamer1.0-python3-dbg-plugin-loader)

Installing gstreamer on your workstation depends on the OS.

Once installed, copy stream_birdhouse to the controller, stream_ws to your workstation and edit with your data. Then run stream_ws first and stream_birdhouse next - a window should pop open with the video feed.


Final Thoughts

2023-03-07_12-28-22.jpg

It'll be a some time before bluebirds show up, so I don't know how I'll actually run this. The goal is to get pictures, but not disturb the birds. My current plan is to turn on the lights at dawn and turn them off at nightfall - hopefully the predictability helps. Bluebirds spend considerable time inspecting the birdhouse before settling in - if I see they are reluctant to come in, I'll switch to turning lights on rarely, just to take a pic.

If the lights are on all the time, I'll probably take a picture automatically every so often, or possibly figure out how to do a time-lapse. I'll edit this Instructable once I know how it all turned out.

And the egg? Well, of course it's a chicken egg. For good luck!