Sunday, January 25, 2026

Night Vision Bird Nest Box Camera Configuration and Installation

How to setup infrared bird nest box camera with night vision

Infrared Bird Nest Box Camera Configuration and Installation

Bird Nest Box with IR Camera Setup

I had been observing house sparrows since a few years. I observed their activities outside the nest but I had always been curious about their activities inside the nest

  • How do they build the nest
  • How many eggs do they lay in a clutch and how frequently
  • How long does it take to hatch the eggs
  • How do they keep the nest clean
  • How do hatchlings spend their time in the nest
  • And many more...

I had been thinking about installing a camera in the nest box since a year or more

In the process of searching for the right camera, I came across some options

It took me sometime and thought process to decide which camera to install

I decided to go with Raspberry Pi Zero 2 W H for the nest box camera. It is a perfect fit for my nestbox, easy to setup compared to the ESP32-CAM and easy to upgrade or extend if we need more capabilities in the future

What do we need for this nest box camera setup?

All that is needed for Bird Nest Box Camera Setup
  1. Raspberry Pi Zero 2 W H (H indicates pre-soldered GPIO header)
  2. Raspberry PI Infrared IR Night Vision Camera Module
  3. Raspberry Pi Zero V1.3 Camera Cable (15cm)
  4. Raspberry Pi Zero protective case
  5. Raspberry Pi Pi3/Pi3B+ Micro USB 12.75W Power Supply
  6. Micro SD Card Reader
  7. SanDisk Ultra A1 Class 10 32GB Memory Card
  8. HDMI Female to Mini HDMI Male Adapter
  9. Micro USB OTG to USB 2.0 Adapter
  10. Infrared Light 3W for Raspberry Pi Camera
  11. Two 5mm 890nm IR LED
  12. Two 220ohm resistor
  13. Female to Female jumper cables

Setting Up The Pi

I have explained in detail how to setup Raspberry Pi Zero 2 W in this post

Guide to setting up your Raspberry Pi

Customising the Pi

I believe you have setup your Pi and is now ready to configure the camera

We shall create another user to run and manage our bird nest box camera

We shall create a new user birdwatcher. Execute the below commands in the command terminal on your Pi


sudo adduser birdwatcher
sudo usermod -aG video birdwatcher
sudo usermod -aG render birdwatcher
sudo usermod -aG audio birdwatcher
sudo usermod -aG sudo birdwatcher

birdwatcher has now been added to the groups video, audio, render and sudo

Enabling RDP is a onetime process which you already completed when setting up the Pi. You will be able to RDP with this user and every other user you create here after

The next step is to prepare the Pi for installing the camera module

Installing the Camera Module

Setting up the camera module is straight foward

Pi Zero V1.3 Camera Cable has a broad end (1mm) and a narrow end (0.5mm)

Narrow end is connected to the CSI port on the Pi and broad end is connected to the camera module

Once connected and the Pi is powered on, the camera remains powered irrespective of whether it is recording or not

This camera can see IR light when illuminated with an IR source like an IR LED or bulb. It can also see in the day light. It does not have an auto cut IR filter that can block IR light during the day. So, during the day it can see light in the visible spectrum and IR spectrum. In the dark, if we bring an IR source near this camera, we will be able to see the surrounding objects, this is how it gets night vision

This camera module has two contact points each on either side of the lens. These contact points are positive and negative terminals with a potential difference of 3.3 Volts

Pi Camera Module

As we discussed earlier, this camera module needs IR light to be able to see in the dark. There are three different ways to provide IR light, we shall discuss about these three configurations now

  1. IR Light Using 3W Infrared Light Source
  2. IR Light Using IR LEDs Powered by GPIO Pins
  3. IR Light Using IR LEDs Powered by Camera Module

In all the three configurations, the way camera module is connected to the Pi remains the same

Execute rpicam-hello --list-cameras on the command terminal of your Pi to see the installed camera module


birdwatcher@pizero:~ $ rpicam-hello --list-cameras

Available cameras
-----------------
0 : ov5647 [2592x1944 10-bit GBRG] (/base/soc/i2c0mux/i2c@1/ov5647@36)
   Modes: 'SGBRG10_CSI2P' : 640x480 [58.92 fps - (16, 0)/2560x1920 crop]
                            1296x972 [46.34 fps - (0, 0)/2592x1944 crop]
                            1920x1080 [32.81 fps - (348, 434)/1928x1080 crop]
                            2592x1944 [15.63 fps - (0, 0)/2592x1944 crop]

If you are not able to see the camera, it indicates you have not connected the cable properly

The leads (golden) on the cable should always be facing the board as shown above, be it on the Pi or the Camera

IR Light Using 3W Infrared Light Source

IR Light Using 3W Infrared Light Source

In this configuration the source of IR light is the two 3W modules attached on either side of the camera module

These 3W LED modules are powered on as long as the Pi is powered. So they emit IR light as long as the Pi is running

One good thing about these modules is, they have a photosensitive resistor which cuts down the power to these modules in day light. So these modules do not emit IR light when they are in the open receiving day light

But when the modules are inside the nestbox which is relatively dark, these modules remain turned on always

These are 3W each drawing a power of 600 mA (max), so they produce some amount of heat. You can attach heat sinks on the back of the modules to dissipate heat

When illuminated with a single module, this is how the interior of the nest box looks like

IR Light Using 3W Infrared Light Source

The wavelength of IR light emmited by these modules is about 850nm, that is the reason we see a faint red light on the modules and also pictures appear faint red

You can either go with one module or two modules depending on your need. But keep in mind the amount of heat these modules generate and the power they draw

I installed only one module but later on decided not to go with these modules as it might not be suitable in all the seasons due to the heat they generate

Camera Module Mounted on Nest Box

This is how I mounted the Camera Module with IR LED Modules on top of the nest box

IR Light Using IR LEDs Powered by GPIO Pins

IR Light Using IR LEDs Powered by GPIO Pins

In this configuration the source of IR light is the two IR LEDs

These IR LEDs are powered by the GPIO pins

Before we go in to the details of the connection, let us understand about the GPIO pins

GPIO Pins

More about GPIO Pins

For this topic we will limit our discussion to the pins that provide power to the LEDs

Pins 2 and 4 provide 5v at 1.5A. Pins 1 and 17 provide 3.3v at 500mA

We cannot connect the IR LEDs directly to any of the above the GPIO pins. Doing so would result in burnout as the current from the 3v3 and 5v pins is too high. Maximum continuous forward current rating for IR LEDs is 100mA. For this project let us target the current output range at 20mA–50mA

To bring down the current output to the desired operating range we need a resistor

If we add a 220 ohm resistor at 5v pin, that would limit the current to 23mA

If we add a 150 ohm resistor at 3.3v pin, that would limit the current to 22mA

Select the right resistor depending on the voltage

Connect the long leg of the LED to the anode and short leg to the ground. Connecting the other way would not damage the LED as the voltage is low. The LED doesn't light up as it prevents the flow of current in the opposite direction

Should you connect the resistor on the long leg or the short leg of the LED?

It can be connected on any leg. Now you might have a question, the electrons are flowing from the 5v or 3.3v pin to the ground pin and connecting the resistor on the ground side or the short leg of the LED would not stop the rush of electrons flowing in to the LED causing the burnout

But the resistor does not behave that way, it shapes/restricts the flow of electrons from the origin to the end. So, the number of electrons entering the LED would remain the same irrespective of which leg of the LED we connect the resistor

I could not think of a better analogy than this

Flow And Resistance

In the above picture, the bridge is similar to the resistor. The road leading to the bridge is the source of traffic, imagine the road to be one way. The observer in the checkpost on the other end of the bridge is similar to the LED

At the origin, the road leading to the bridge might be a six lane road with a lot of vehicles, but as the road approaches the narrow bridge it also becomes narrow allowing vehicles only in two lanes. Similarly the road leaving the bridge is also narrow with just two lanes. It might expand in to six lanes after some distance but near the bridge it is two lanes

The observer in the checkpost would see the same amount of traffic irrespective of the position of the checkpost, be it on the road leading to the bridge or leaving the bridge

One advantage of using GPIO pins to power the LEDs is that you can turn them on and off by writing a simple python script


# Run this script when you turn on the camera
from gpiozero import LED
from time import sleep
# GPIO 2 (BCM numbering)
led = LED(2)
led.on()

# Run this script when you turn off the camera
from gpiozero import LED
from time import sleep
# GPIO 2 (BCM numbering)
led = LED(2)
led.off()

For wiring and detailed configuration, refer to this guide

IR Light Using IR LEDs Powered by Camera Module

IR Light Using IR LEDs Powered by Camera Module

In this configuration the source of IR light is the two IR LEDs

These IR LEDs are powered by the Camera Module and are always on if the Pi is powered on

We know the voltage at the contact points on the camera module is 3.3v

If we add a 150 ohm resistor, that would limit the current to 22mA

But I connected a 220 ohm resistor limiting the current to 15mA

When illuminated with two LEDs, this is how the interior of the nest box looks like

We can see the pictures in blue. It is not because the LEDs are encased in blue epoxy. It is because the sensor in this camera has mapped blue light for IR spectrum. Some sensors map grey

IR Light Using Two Infrared LEDs

What you see inside are clay birds

The clarity is good enough with the illumination provided by the LEDs at 15mA current

I decided to go with this configuration as I don't have to deal with jumper cables. The reason for avoiding jumper cables is that they would clutter the box with a lot of wiring and I didn't have a way to properly conceal them inside

I also have a very limited time window to complete all this setup as the nest box is now empty and birds are not visiting the nest as it is winter. In a few more days they would start visiting

Operating the Camera and Streaming

Below are some rpicam commands to operate the camera


Command 		Description
--------------------------------
rpicam-hello	Opens a live preview window for a specified duration
rpicam-still	Captures high-resolution still images
rpicam-vid	Records video to a specified output file
rpicam-raw	Captures raw Bayer frames directly from the sensor
rpicam-jpeg	Captures high-resolution JPEGs

Example
-------
rpicam-hello -t 5000 for a 5-second preview
rpicam-still -o test.jpg saves an image to test.jpg
rpicam-vid -t 10000 -o test.mp4 for 10 second video
rpicam-raw -o test.raw
rpicam-jpeg -o test.jpg
rpicam-vid --qt-preview -t 10000 -o test.mp4 for 10 second video with preview

Youtube Streaming
-----------------
rpicam-vid -n -t 0 --inline --width 1280 --height 720 --framerate 30 
--bitrate 250k --codec libav --libav-format flv -o - | \
ffmpeg -f flv -i - -f s16le -i /dev/zero -c:v copy -c:a aac -ab 128k -g 60 
-f flv rtmp://a.rtmp.youtube.com/live2/<your stream key>

This concludes the setup of Infrared Camera for Bird Nest Box

This camera setup can also be used for monitoring the activity of wildlife

Thursday, January 22, 2026

Raspberry Pi Introduction and Setup

How to setup Raspberry Pi

Introduction to Raspberry Pi and Setup

Raspberry Pi is a Single Board Computer. It provides desktop experience in a very small form factor. Pi Zero is 65mm x 30mm. Single board computers are making computing affordable for all walks of life

Raspberry Pi Zero 2 W H

Pi Zero 2 W H shown above costs about 20$, if you add a monitor that costs about another 30$ along with a mouse and keyboard you will have a computing device for about 70$

It is not powerful as the regular desktop computers but it is a good starting point for beginners especially for school and college going kids to learn and understand how computers and electronics work. Pi Zero 2 W has the below processor, memory and wireless specifications

Processor: Quad-core 64-bit Arm Cortex-A53 @ 1GHz

Memory: 512MB LPDDR2 SDRAM

Wireless: 2.4GHz 802.11b/g/n Wi-Fi, Bluetooth 4.2, Bluetooth Low Energy (BLE)

We will discuss about setting up Raspberry Pi Zero 2 W H

What do we need for this setup?

All that is needed for Raspberry Pi Setup
  1. Raspberry Pi Zero 2 W H (H indicates pre-soldered GPIO header)
  2. Raspberry Pi Pi3/Pi3B+ Micro USB 12.75W Power Supply
  3. Raspberry Pi Zero protective case
  4. SanDisk Ultra A1 Class 10 32GB Memory Card
  5. Micro SD Card Reader
  6. USB Hub
  7. Micro USB OTG to USB 2.0 Adapter
  8. HDMI Cable
  9. HDMI Female to Mini HDMI Male Adapter

Setting Up The Pi

The first step in setting up the Pi is to install the Operating System

This guide on the official site has detailed instructions on how to install the OS

Guide to installing OS on your Raspberry Pi

When you reach this step, to keep things simple, select Password Authentication

Authentication Step

After you select Password Authentication, skip all other steps for now and proceed to below step

Set the Imager options

Once you complete all the steps, you will reach the final step

Click on Finish and we are done with OS installation for the Raspberry Pi

OS Installation Complete

The OS is now installed on the Micro SD Card

We now have to start the Pi and do some customizations

Understanding Raspberry Pi Zero Pheripherals

Raspberry Pi Zero Pheripherals

On the extreme left is the Micro-SD Slot. We have to insert the SD Card with the OS installed

Insert the Card in to the slot with the labels on the card facing toward you and gently push it in

On the extreme right is the Camera Connector Slot also called the Camera Serial Interface. This is where we connect the camera module

Micro-USB Power port is for the power supply to the Pi

Micro-USB Data port is to connect a Mouse/Keyboard/any other USB device to the Pi

Mini-HDMI port is to connect the Pi to a display device like the TV or Monitor with HDMI port

GPIO (General Purpose IO) Header is to connect Input and Output devices/components to the Pi. There are 40 pins on the Pi Zero and all higher versions. In Pi Zero 2 W H, the headers are soldered and the devices/components can be connected to the pins with the help of jumper cables

Boot The Pi and Get Started

Mount the Pi in Protective Case

I have selected Waveshare protective case for enclosing the Pi. This case is convenient as all ports and connectors are accessible through openings in the case. If you intend to install the Pi outdoors where it is exposed to dust and moisture, it is important to enclose the Pi in a protective case

Mount the Pi in the case and close it. Now it is the time to power up the Pi. Connect the power supply to the Pi and it boots up

Next to the Micro-USB Power port is a small led that lights up and blinks continuously as the Pi boots

If it stops blinking and stays solid with a green light, it indicates the Pi has booted successfully

Connecting to the Pi Desktop

The Pi has booted and is now running. Usually Rasbperry Pi conects to the Wi-Fi we configured during the OS installation step. But when I booted, the Pi Zero did not connect to the Wi-Fi

If it connects to the Wi-Fi and we could grab the IP address of the Pi, we can SSH in to the Pi to access and configure it further

If it does not connect to the Wi-Fi, we have to connect the Pi to a TV or Monitor with a HDMI port. Use the HDMI Female to Mini HDMI Male Adapter. Connect your Pi to a TV or Monitor with a standard HDMI cable. Once connected, login to the Pi with the username and password configured during the OS installation step. Once logged in we should be able to see the desktop

Pi Desktop

Use the Micro USB OTG to USB 2.0 Adapter to connect to a Key Board and Mouse. To simultaneously connect the Mouse and the Key Board, you should connect the OTG adapter to a USB hub with multiple USB ports

Click on Wi-Fi configuration on the top right corner of your desktop. Configure and connect to your home Wi-Fi. If you plan to mount the Pi far away from your router, connecting to the 2.5 Ghz channel would help. It is a long range channel compared to 5 Ghz channel and it minimizes interference from walls and other obstacles between the Wi-Fi router and the Pi

Make note of the IP address assigned to the Pi. Mostly this remains constant even if you reboot and reconnect to the Wi-Fi. If you have administrative access to your home Wi-Fi router, configure a static IP for your Pi

Using this IP address, we can connect to the Pi from another computer in our home Wi-Fi network by SSH or RDP

We also have Bluetooth on Pi Zero. Bluetooth devices can be connected to the Pi

Customising the Pi

Previously, we accessed the Pi by connecting it to TV or Monitor. If you do not have a Laptop or Desktop, this is is the only way to connect to the Pi. If you have another computer, you can access the Pi by connecting it by Remote Desktop (RDP) or SSH (Secure Shell). RDP gives you access to Pi's Desktop, where as SSH gives you access to the command terminal on the Pi. In SSH mode you will be able to interact with the Pi only by executing commands on the command line interface. In RDP you can interact with the Pi through the desktop Graphical User Interface (GUI)

When we installed the OS, we configured a user to login to the Pi

SSH in to your Pi from another computer (Desktop or Laptop connected to your home Wi-Fi) for the next steps or continue to access Pi on your TV or Monitor. To SSH, use the user you configured when installing the OS. I am assuming admin is the user you created and your Pi IP Address to be 192.160.1.10

Execute ssh admin@192.160.1.10 on the command terminal on your Desktop or Laptop. On successful login, you will be presented the command terminal (shell) for your Pi. You can execute all the commands to interact with your Pi from this shell

We shall create a new user piuser. Execute the below commands in the command terminal on your Pi


sudo adduser piuser
sudo usermod -aG video piuser
sudo usermod -aG render piuser
sudo usermod -aG audio piuser
sudo usermod -aG sudo piuser

The user piuser has now been added to the groups video, audio, render and sudo

We have to enable RDP. Execute the below commands in the command terminal on your Pi


sudo apt update
sudo apt install xrdp
sudo raspi-config

Raspi Config

Navigate to Advanced Options and press Enter

Select A7 Wayland and press Enter

Select W1 X11 and press Enter

Select Finish and Reboot the system for the changes to take effect

With this we are done setting up the Pi

Let us hope and wish, single board computers like the Raspberry Pi remain affordable