ESP32 CAM Bird Box Camera: Night Vision and Live Stream Guide
ESP32 CAM bird box camera: IR LED night vision, mounting, live stream on your phone and in Home Assistant, cable and power table, condensation protection.
An ESP32 CAM bird box camera lets you watch the eggs, the chicks growing up and the parents' feeding visits without disturbing the birds at all. Ready-made systems are expensive, but you can do the same job yourself with an ESP32-CAM board, a few infrared (IR) LEDs and a power cable. The ESP32-CAM is a small board with a camera and Wi-Fi; it sends the image to your home network as a live stream, and you watch it on your phone, your computer or your Home Assistant dashboard.
In this guide you'll find the parts of a bird box camera, night vision with IR LEDs and why you need a camera without an infrared filter, the wiring table and complete code that switches night mode on by itself. Then you'll watch the stream on your phone and in Home Assistant, calculate the voltage drop for your cable length, place the camera correctly in the box, protect it from moisture and condensation, and set everything up before spring, before the birds start looking for a nest. If you are programming an ESP32-CAM for the first time, read the ESP32-CAM guide first.

How does a bird box camera work?
The system has three parts. The ESP32-CAM sits in a small compartment in the roof of the box, captures a few JPEG frames per second with its OV2640 camera and broadcasts them to your home network as an MJPEG stream. For images in the dark, IR LEDs next to the camera light up the box with light that the human eye can't see and that doesn't disturb the birds; the ESP32-CAM reads a light sensor and switches these LEDs on in the evening and off in the morning. The last part is the power line: since the box is usually a few metres from the house, the thickness and length of the power cable is the biggest factor in whether the system runs reliably.
| Part | Job | Note |
|---|---|---|
| ESP32-CAM (AI Thinker) | Captures the image and streams it over Wi-Fi | Version with PSRAM, OV2640 camera |
| OV2640 without IR filter (NoIR) | Sees infrared light | Normal lenses block IR, so the night image stays black |
| 4 × 850 nm IR LEDs | Light up the box at night | Two series pairs with 68 Ω resistors |
| Logic-level N-MOSFET (AO3400, IRLZ44N) | Switches the IR LEDs from a GPIO | 100 Ω to the gate, 100 kΩ from gate to GND |
| LDR light sensor module (with DO output) | Tells night from day | Threshold set with the trimpot |
| 5 V 2 A adapter or 12 V + step-down converter | Power supply | Chosen by distance, see the table below |
| USB-TTL adapter or ESP32-CAM-MB | To upload the code | Only needed while programming |
Night vision: IR LEDs and a camera without an IR filter
The secret of night vision is not in the camera but in the lens. Most OV2640 modules supplied with the ESP32-CAM have an infrared-cut filter inside the lens; it gives correct colours in daylight but also blocks the light from the IR LEDs, so the night image stays black. That is why you should buy an OV2640 module without a filter, labelled "night vision" or "NoIR". A filterless camera shifts daytime colours slightly towards pink; inside a closed bird box you'll hardly notice. For the IR wavelength, 850 nm gives the best results: the OV2640 is sensitive to it, the LEDs only give a very faint red glow, and research shows that most birds can't see this wavelength. 940 nm is completely invisible, but the camera is less sensitive to it, so you need more LEDs for the same image.
| Light source | Camera image | Effect on birds | Recommendation |
|---|---|---|---|
| 850 nm IR LED | Bright, sharp black and white | They can't see it, very faint red glow | Best choice for a bird box |
| 940 nm IR LED | Darker, noisier | Completely invisible | Double the number of LEDs |
| White LED (the board's flash) | Colour | Scares the birds, can make them abandon the nest | Never use it |
Lighting a small box doesn't take much power; too much light washes the image out to white. Connect four 5 mm 850 nm LEDs in two series pairs and give each pair a resistor. The forward voltage of an IR LED is about 1.45 V, so two of them make 2.9 V. For 30 mA from a 5 V supply the resistor is R = (5 − 2.9) / 0.03 = 70 Ω, so 68 Ω as a standard value. Both pairs together draw about 60 mA and are switched by GPIO 13 through the MOSFET. Repeat the calculation for your own LED's values with the LED resistor calculator. Place the LEDs on both sides of the lens, angled slightly outwards, and stick a layer of tracing paper or white tape in front of them to spread the light, so there is no bright spot on the eggs.
Wiring table
| Connection | ESP32-CAM pin | Note |
|---|---|---|
| Supply +5 V | 5V | The board has its own 3.3 V regulator, never put 5 V on the 3V3 pin |
| Ground | GND | IR circuit, LDR and supply share a common GND |
| IR LED MOSFET gate | GPIO 13 | 100 Ω in series, 100 kΩ to GND; the LEDs stay off at boot |
| LDR module DO | GPIO 14 | The module's VCC comes from 3.3 V |
| LDR module VCC | 3V3 | Keeps the DO output at 3.3 V level |
| Programming (USB-TTL) | U0R, U0T, GPIO 0 | GPIO 0 to GND while uploading, then disconnect |
Step-by-step setup and code
- Install the ESP32 board package in the Arduino IDE and select AI Thinker ESP32-CAM as the board.
- Enter your own network details in the WIFI_ADIN and WIFI_SIFREN fields in the code.
- Upload the code with an ESP32-CAM-MB board or a USB-TTL adapter (GPIO 0 to GND), then disconnect GPIO 0 and press RST.
- Open the address shown in the Serial Monitor (115200 baud) in your phone's browser: the http://ip-address/ page shows the stream.
- Adjust the LDR module's trimpot at dusk: the module's LED should change state right at sunset.
- Focus the lens for the distance to the floor of the box (about 15–20 cm), then place the board in the roof compartment.
1// ESP32-CAM kuş yuvası kamerası: MJPEG yayın + IR gece modu
2// ESP32-CAM bird box camera: MJPEG stream + IR night mode
3// Kart / Board: AI Thinker ESP32-CAM (PSRAM)
4#include "esp_camera.h"
5#include <WiFi.h>
6#include "esp_http_server.h"
7
8const char* WIFI_SSID = "WIFI_ADIN"; // kendi ağ adın / your network name
9const char* WIFI_PASS = "WIFI_SIFREN"; // kendi şifren / your password
10
11const int IR_LED_PIN = 13; // MOSFET kapısı -> IR LED'ler / MOSFET gate -> IR LEDs
12const int LDR_PIN = 14; // LDR modülü DO / LDR module DO
13const int DARK_LEVEL = HIGH; // karanlıkta DO seviyesi (modüle göre) / DO level in the dark (module dependent)
14
15// AI Thinker kamera pinleri / AI Thinker camera pins
16#define PWDN_GPIO_NUM 32
17#define RESET_GPIO_NUM -1
18#define XCLK_GPIO_NUM 0
19#define SIOD_GPIO_NUM 26
20#define SIOC_GPIO_NUM 27
21#define Y9_GPIO_NUM 35
22#define Y8_GPIO_NUM 34
23#define Y7_GPIO_NUM 39
24#define Y6_GPIO_NUM 36
25#define Y5_GPIO_NUM 21
26#define Y4_GPIO_NUM 19
27#define Y3_GPIO_NUM 18
28#define Y2_GPIO_NUM 5
29#define VSYNC_GPIO_NUM 25
30#define HREF_GPIO_NUM 23
31#define PCLK_GPIO_NUM 22
32
33#define BOUNDARY "kusyuvasiframe"
34static const char* STREAM_TYPE = "multipart/x-mixed-replace;boundary=" BOUNDARY;
35static const char* STREAM_SEP = "\r\n--" BOUNDARY "\r\n";
36static const char* STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %u\r\n\r\n";
37
38bool nightMode = false;
39int darkCount = 0;
40unsigned long lastCheck = 0;
41unsigned long lastWifiTry = 0;
42
43// Ana sayfa: yayını 81. porttan gösterir / index page: shows the stream from port 81
44esp_err_t indexHandler(httpd_req_t* req) {
45 static const char page[] =
46 "<!doctype html><html><head><meta name='viewport' content='width=device-width'>"
47 "<title>Kus Yuvasi</title></head><body style='margin:0;background:#000'>"
48 "<img id='s' style='width:100%'>"
49 "<script>s.src='//'+location.hostname+':81/stream'</script></body></html>";
50 httpd_resp_set_type(req, "text/html");
51 return httpd_resp_send(req, page, HTTPD_RESP_USE_STRLEN);
52}
53
54// Tek fotoğraf (Home Assistant için) / single photo (for Home Assistant)
55esp_err_t captureHandler(httpd_req_t* req) {
56 camera_fb_t* fb = esp_camera_fb_get();
57 if (!fb) {
58 httpd_resp_send_500(req);
59 return ESP_FAIL;
60 }
61 httpd_resp_set_type(req, "image/jpeg");
62 esp_err_t res = httpd_resp_send(req, (const char*)fb->buf, fb->len);
63 esp_camera_fb_return(fb);
64 return res;
65}
66
67// MJPEG canlı yayın / MJPEG live stream
68esp_err_t streamHandler(httpd_req_t* req) {
69 char part[64];
70 esp_err_t res = httpd_resp_set_type(req, STREAM_TYPE);
71 while (res == ESP_OK) {
72 camera_fb_t* fb = esp_camera_fb_get();
73 if (!fb) {
74 res = ESP_FAIL;
75 break;
76 }
77 size_t hlen = snprintf(part, sizeof(part), STREAM_PART, (unsigned)fb->len);
78 res = httpd_resp_send_chunk(req, STREAM_SEP, strlen(STREAM_SEP));
79 if (res == ESP_OK) res = httpd_resp_send_chunk(req, part, hlen);
80 if (res == ESP_OK) res = httpd_resp_send_chunk(req, (const char*)fb->buf, fb->len);
81 esp_camera_fb_return(fb); // izleyici ayrılınca döngü biter / loop ends when the viewer leaves
82 }
83 return res;
84}
85
86void addRoute(httpd_handle_t h, const char* path, esp_err_t (*fn)(httpd_req_t*)) {
87 httpd_uri_t u = {};
88 u.uri = path;
89 u.method = HTTP_GET;
90 u.handler = fn;
91 u.user_ctx = NULL;
92 httpd_register_uri_handler(h, &u);
93}
94
95void startServers() {
96 httpd_handle_t web = NULL, stream = NULL;
97 httpd_config_t cfg = HTTPD_DEFAULT_CONFIG();
98 cfg.server_port = 80; // sayfa ve fotoğraf / page and photo
99 if (httpd_start(&web, &cfg) == ESP_OK) {
100 addRoute(web, "/", indexHandler);
101 addRoute(web, "/capture", captureHandler);
102 }
103 cfg.server_port = 81; // yayın ayrı portta / stream on its own port
104 cfg.ctrl_port = 32769;
105 if (httpd_start(&stream, &cfg) == ESP_OK) {
106 addRoute(stream, "/stream", streamHandler);
107 }
108}
109
110bool startCamera() {
111 camera_config_t c = {};
112 c.ledc_channel = LEDC_CHANNEL_0;
113 c.ledc_timer = LEDC_TIMER_0;
114 c.pin_d0 = Y2_GPIO_NUM;
115 c.pin_d1 = Y3_GPIO_NUM;
116 c.pin_d2 = Y4_GPIO_NUM;
117 c.pin_d3 = Y5_GPIO_NUM;
118 c.pin_d4 = Y6_GPIO_NUM;
119 c.pin_d5 = Y7_GPIO_NUM;
120 c.pin_d6 = Y8_GPIO_NUM;
121 c.pin_d7 = Y9_GPIO_NUM;
122 c.pin_xclk = XCLK_GPIO_NUM;
123 c.pin_pclk = PCLK_GPIO_NUM;
124 c.pin_vsync = VSYNC_GPIO_NUM;
125 c.pin_href = HREF_GPIO_NUM;
126 c.pin_sccb_sda = SIOD_GPIO_NUM;
127 c.pin_sccb_scl = SIOC_GPIO_NUM;
128 c.pin_pwdn = PWDN_GPIO_NUM;
129 c.pin_reset = RESET_GPIO_NUM;
130 c.xclk_freq_hz = 20000000;
131 c.pixel_format = PIXFORMAT_JPEG;
132 c.grab_mode = CAMERA_GRAB_LATEST; // hep en yeni kare / always the newest frame
133 if (psramFound()) {
134 c.frame_size = FRAMESIZE_SVGA; // 800x600
135 c.jpeg_quality = 12; // 10-63, küçük = kaliteli / lower = better
136 c.fb_count = 2;
137 c.fb_location = CAMERA_FB_IN_PSRAM;
138 } else {
139 c.frame_size = FRAMESIZE_VGA; // 640x480
140 c.jpeg_quality = 15;
141 c.fb_count = 1;
142 c.fb_location = CAMERA_FB_IN_DRAM;
143 }
144 return esp_camera_init(&c) == ESP_OK;
145}
146
147void setNight(bool on) {
148 nightMode = on;
149 digitalWrite(IR_LED_PIN, on ? HIGH : LOW);
150 sensor_t* s = esp_camera_sensor_get();
151 if (s) s->set_special_effect(s, on ? 2 : 0); // 2 = siyah-beyaz, 0 = normal / 2 = grayscale, 0 = normal
152 Serial.println(on ? "Gece modu / night mode" : "Gunduz modu / day mode");
153}
154
155void setup() {
156 Serial.begin(115200);
157 pinMode(IR_LED_PIN, OUTPUT);
158 digitalWrite(IR_LED_PIN, LOW);
159 pinMode(LDR_PIN, INPUT);
160 pinMode(4, OUTPUT);
161 digitalWrite(4, LOW); // beyaz flaş LED'i kapalı kalsın / keep the white flash LED off
162
163 if (!startCamera()) {
164 Serial.println("Kamera baslatilamadi / camera init failed");
165 delay(5000);
166 ESP.restart();
167 }
168 WiFi.mode(WIFI_STA);
169 WiFi.setSleep(false); // akıcı yayın için / for a smooth stream
170 WiFi.begin(WIFI_SSID, WIFI_PASS);
171 while (WiFi.status() != WL_CONNECTED) {
172 delay(500);
173 Serial.print(".");
174 }
175 Serial.print("\nYayin / stream: http://");
176 Serial.print(WiFi.localIP());
177 Serial.println(":81/stream");
178 startServers();
179}
180
181void loop() {
182 // 2 sn'de bir ışığa bak, 3 aynı okumada modu değiştir / check light every 2 s, switch after 3 equal readings
183 if (millis() - lastCheck > 2000) {
184 lastCheck = millis();
185 bool dark = digitalRead(LDR_PIN) == DARK_LEVEL;
186 if (dark != nightMode) {
187 if (++darkCount >= 3) {
188 setNight(dark);
189 darkCount = 0;
190 }
191 } else {
192 darkCount = 0;
193 }
194 }
195 // Wi-Fi koparsa 30 sn'de bir yeniden dene / retry Wi-Fi every 30 s if it drops
196 if (WiFi.status() != WL_CONNECTED && millis() - lastWifiTry > 30000) {
197 lastWifiTry = millis();
198 WiFi.reconnect();
199 }
200 delay(10);
201}
202The code starts two separate web servers. The server on port 80 provides the main page and a single JPEG photo at /capture; the server on port 81 sends a continuous MJPEG stream at /stream. The stream keeps sending frames in a loop as long as a viewer is connected, so it runs on its own port and doesn't block photo requests. If PSRAM is found, 800×600 resolution and two frame buffers are used; the CAMERA_GRAB_LATEST setting always sends the newest frame and reduces lag. In loop() the light sensor is read every two seconds, and three identical readings in a row are needed to switch to night mode, so the IR LEDs don't flicker at dusk. In night mode the IR LEDs turn on and the camera switches to a black-and-white effect, because the filterless sensor's colours in infrared turn into a meaningless purple tint. If the Wi-Fi connection drops, the code tries to reconnect every 30 seconds.
Watching the live stream on your phone
Once the board is on the network, just open the browser on a phone on the same Wi-Fi and type the address from the Serial Monitor. The main page shows the stream at screen width; if you want to open the stream directly in an app, use http://ip-address:81/stream. To stop the address changing every time, reserve a fixed IP for the board's MAC address in your router's DHCP settings. This simple server streams to one viewer at a time; if a second person tries to connect, they wait until the first viewer leaves. If everyone at home will watch, bring the stream into Home Assistant as a single client and let everyone watch from there. To watch from outside your home, use Home Assistant's remote access or a VPN instead of exposing the board to the internet; the ESP32-CAM's simple server has no password.
The bird box camera in Home Assistant
Home Assistant can show the ESP32-CAM's MJPEG stream directly as a camera entity without extra software. For this you use the built-in MJPEG IP Camera integration. Once the camera is added, you can put it on a dashboard card and write automations that take a photo from /capture when motion is detected or at a set time every morning and send it as a notification. For adding sensors over MQTT and automation logic, see the ESP32 MQTT and Home Assistant article.
- In Home Assistant, go to Settings, Devices & services, press Add integration and choose MJPEG IP Camera.
- Enter http://192.168.1.50:81/stream in the MJPEG URL field (replace the IP address with your board's).
- Enter http://192.168.1.50/capture in the still image URL field; the dashboard thumbnail is taken from here.
- Leave the username and password fields empty and press Submit.
- Add the new camera entity to the dashboard with a Picture Glance card.
If you'd rather manage everything from Home Assistant instead of writing code, you can program the ESP32-CAM with ESPHome. ESPHome's esp32_camera component connects the camera to Home Assistant directly through its own API; the IR LED appears as a light entity and the LDR as a binary sensor, and the LED switches on by itself in the dark. The configuration below uses the same AI Thinker pins. If you're new to ESPHome, the ESPHome setup article walks you through it step by step.
1# ESPHome: ESP32-CAM kuş yuvası / ESP32-CAM bird box
2esphome:
3 name: kus-yuvasi
4
5esp32:
6 board: esp32cam
7 framework:
8 type: arduino
9
10wifi:
11 ssid: !secret wifi_ssid
12 password: !secret wifi_password
13
14api:
15ota:
16 - platform: esphome
17logger:
18
19esp32_camera:
20 name: Kus Yuvasi
21 external_clock:
22 pin: GPIO0
23 frequency: 20MHz
24 i2c_pins:
25 sda: GPIO26
26 scl: GPIO27
27 data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
28 vsync_pin: GPIO25
29 href_pin: GPIO23
30 pixel_clock_pin: GPIO22
31 power_down_pin: GPIO32
32 resolution: 800x600
33 jpeg_quality: 12
34 max_framerate: 10 fps
35
36output:
37 - platform: gpio
38 pin: GPIO13
39 id: ir_output
40
41light:
42 - platform: binary
43 name: IR LED
44 id: ir_led
45 output: ir_output
46
47binary_sensor:
48 - platform: gpio
49 pin: GPIO14
50 name: Karanlik
51 filters:
52 - delayed_on_off: 5s
53 on_press:
54 - light.turn_on: ir_led
55 on_release:
56 - light.turn_off: ir_led
57Cable length and power table
While streaming, the ESP32-CAM draws an average of 180–250 mA from 5 V; during Wi-Fi transmit bursts this rises to up to 400 mA, and the IR LEDs add 60 mA. For a safe design, plan for 0.5 A. The board's 3.3 V regulator needs at least about 4.5 V at its input to work properly, so with a 5 V adapter you can lose at most 0.5 V in the cable. Because the current flows out and back, the drop is calculated over both wires: ΔV = I × R × 2 × L. The resistance of a copper conductor with a 0.5 mm² cross-section is about 0.034 Ω per metre. To try the values yourself, use the Ohm's law calculator. If the box is more than 10 metres away, the most robust solution is to send 12 V and step it down to 5 V next to the box with a small LM2596 buck converter: the current drops to less than half and the converter easily tolerates a few volts of loss at its input.
| Cable | Conductor resistance | Drop at 5 m | Drop at 10 m | Drop at 20 m | Recommendation |
|---|---|---|---|---|---|
| Thin USB cable (about 0.08 mm²) | 0.21 Ω/m | 1.07 V | 2.13 V | 4.26 V | Only 1–2 m |
| 0.25 mm² (alarm cable), 5 V | 0.069 Ω/m | 0.34 V | 0.69 V | 1.38 V | Up to 5 m |
| 0.5 mm², 5 V | 0.034 Ω/m | 0.17 V | 0.34 V | 0.69 V | Up to 10 m |
| 0.75 mm², 5 V | 0.023 Ω/m | 0.11 V | 0.23 V | 0.46 V | 15–20 m |
| 0.25 mm², 12 V + step-down converter (0.25 A) | 0.069 Ω/m | 0.17 V | 0.34 V | 0.69 V | Best for long runs |
| Power option | Distance | Pros | Cons |
|---|---|---|---|
| 5 V 2 A USB adapter + thick cable | Up to 10 m | Simplest setup | Cable cross-section matters, voltage drops over length |
| 12 V adapter + step-down converter at the box | 30 m and more | Stable even with thin cable | The converter must be protected from moisture |
| PoE splitter (Ethernet cable) | Up to 100 m | Power over a single cable, stable over long distances | Needs a PoE switch or injector and a splitter with 5 V output |
| 18650 battery + solar panel | Wireless | No cable | Continuous streaming uses about 25–30 Wh a day, not enough in winter |
Placing the camera in the box
The best image comes from mounting the camera in the ceiling of the box, directly above the floor. Build a second ceiling inside the box and put the ESP32-CAM in the 3–4 cm gap above it; the lens looks down through a 10 mm hole in this inner ceiling. This way the birds can't reach the electronics and nesting material doesn't cover the lens. The OV2640's standard lens is focused at a distance; to see eggs 15–20 cm away sharply, you need to bring the focus closer by turning the lens anticlockwise. On most modules the lens is fixed with a drop of glue; break it gently with pliers, turn it a quarter turn and adjust while watching the image. There are also wide-angle OV2640 modules with 120–160 degrees to see the whole floor. Hang the box 2–3 m above the ground with the entrance hole facing east or south-east, away from the midday sun and the prevailing wind.
| Bird species | Entrance hole diameter | Floor (inside) | Hole to floor |
|---|---|---|---|
| Blue tit | 26–28 mm | 12 × 12 cm | At least 12.5 cm |
| Great tit | 32 mm | 14 × 14 cm | At least 12.5 cm |
| House sparrow | 32–35 mm | 14 × 14 cm | At least 12.5 cm |
| Starling | 45 mm | 16 × 16 cm | At least 15 cm |
Protection against moisture and condensation
- Separate the electronics from the nest chamber: the birds' breath and wet feathers raise the humidity inside the box; keep the camera compartment separated by the inner ceiling.
- Leave ventilation: don't seal the camera compartment airtight; cut two small ventilation slots under the roof overhang. In a fully closed box, air that cools at night drops its water onto the board.
- Coat the board: apply protective conformal coating to both sides of the board, except the lens, connectors and antenna, so condensed water can't cause a short circuit.
- Add silica gel: leave a small silica gel sachet in the compartment and replace it at every autumn clean-out.
- Don't put the lens behind a window: glass or acrylic in front of the lens fogs up on cold nights; let the lens look out openly through the hole in the inner ceiling.
- Make a drip loop in the cable: let the cable hang downwards before it enters the box so rainwater doesn't run in along it, and seal the hole with a cable gland or silicone.
- Give the roof an overhang: the roof should stick out at least 3 cm at the front and be covered with a waterproof layer.
Setup calendar before spring
| Period | What to do |
|---|---|
| December – January | Build the box, upload the code, test the camera angle and night vision indoors |
| February | Hang the box, run the cable, add it to Home Assistant; tits start looking for nest sites |
| March – April | Nest building and egg laying; don't open the box, only watch the stream |
| April – June | Incubation takes about 2 weeks, the chicks stay in the nest for about 3 weeks; a second brood is possible |
| September – October | Once the box is empty, remove the old nest material, replace the silica gel and check the board |
Common mistakes and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Night image completely black | The lens has an IR-cut filter | Fit an OV2640 module without a filter (NoIR) |
| Night image all white, no detail | IR too strong or too close | Use a larger resistor, diffuse the LEDs, angle them sideways |
| Board keeps restarting | Brownout: long or thin cable, weak adapter | Use thicker cable or 12 V + step-down converter, add 470 µF on the 5V pin |
| Camera init failed error | Camera ribbon cable not seated or wrong board selected | Reseat the connector, select AI Thinker ESP32-CAM as the board |
| Stream freezes or is very slow | Weak Wi-Fi signal in the garden | Use an ESP32-CAM with an external antenna, move the router closer or add an access point |
| Image is blurry | Lens focused at a distance | Turn the lens to focus at 15–20 cm |
| Image foggy in the morning | Condensation | Cut ventilation slots, add silica gel, remove any glass in front of the lens |
A bird box camera built with an ESP32-CAM and a few IR LEDs turns into a little documentary that everyone at home follows every spring. You can find the basics used in this project, such as the Wi-Fi connection, the web server and automatic lighting with PIR and LDR, in the ESP32 projects in the BlueGrays app with step-by-step circuit diagrams and ready-made code, and then move on to the ESP32-CAM Telegram article to add a feature that sends a photo when motion is detected in your bird box.
Frequently asked questions
What camera do I need for a bird box camera?
The OV2640 camera that comes with the ESP32-CAM is fine in daylight, but for night vision you need an OV2640 module without an infrared-cut filter, labelled "NoIR" or "night vision". Modules with a 120–160 degree wide-angle lens are better for seeing the whole floor of the box.
Does infrared light disturb birds?
Most birds can't see 850 nm infrared light, and the LEDs only give a very faint red glow, which is why it is widely used in bird box cameras. A white LED or the board's flash, on the other hand, scares the birds and should never be used.
How much power does a bird box camera use?
While streaming continuously the ESP32-CAM draws 180–250 mA on average at 5 V, about 1–1.3 W including the IR LEDs. That is about 25–30 Wh a day; with a mains adapter the cost is negligible, but a battery and small solar panel won't keep up in winter.
How long can the cable be for an ESP32-CAM bird box?
With 5 V, a 0.5 mm² cable is enough up to about 10 metres, while thin USB cables shouldn't be longer than 1–2 metres. For longer distances, sending 12 V and stepping it down to 5 V next to the box with a buck converter, or using a PoE splitter, is the most reliable solution.
How do I add an ESP32-CAM to Home Assistant?
The easiest way is the MJPEG IP Camera integration: you enter the board's :81/stream address as the MJPEG URL and /capture as the still image URL. Alternatively, you can program the board with ESPHome and connect it directly to the Home Assistant API with the esp32_camera component.
When should I install a bird box camera?
Install it by the end of February at the latest, because tits start looking for nest sites in February and March. Once the birds have moved in, the box shouldn't be opened; maintenance and cleaning are done after the season, in September or October.
Projects to build after reading this
See all projects
LED Blink with ESP32
Teaches basic GPIO output usage with ESP32. We achieve a blinking effect by turning an LED on and off from a digital pin. ESP32 version of the classic blink project on Arduino UNO; the basic blink commands in the Arduino environment are the same, but the ESP32's pin layout and 3.3 V GPIO levels differ from those of the Arduino UNO.

ESP32 Built-in LED Blink
Blinking the built-in blue LED on the ESP32 DevKit V1. No external components required! The first project you should try when you buy an ESP32. GPIO 2 is connected to the built-in LED.

ESP32 Wi-Fi STA Connection (with LCD Screen)
In this project, we connect the ESP32 to the home Wi-Fi network in Station (STA) mode in a secure, fault-tolerant manner. We store the SSID and password in a separate secrets.h file to prevent leaking to Git, set up an auto-reconnect mechanism, and display the RSSI signal level and IP address on an I2C LCD screen. The internal LED works as a status indicator. It is a production-grade connection manager.

ESP32 Asynchronous Web Server (with IP Display on LCD)
In this project, we’re turning the ESP32 into an asynchronous web server that you can control from your phone or computer on the same Wi-Fi network. Thanks to the ESPAsyncWebServer library, the server can process multiple requests simultaneously (unlike the classic WebServer.h, which blocks on a single request). You’ll be able to open the ESP32’s IP address in a browser and click the ON/OFF buttons (the /on and /off routes) to turn the LED connected to GPIO 5 on and off.

ESP32 mDNS: Accessing the Device via bluegrays-esp.local (with LCD Screen)
In this project we add an mDNS (Multicast DNS) service to the ESP32, so you reach it by a readable host name like bluegrays-esp.local instead of an IP address. Even if the IP assigned by DHCP changes, the device always answers to the same name. A small web server on the board lets you control the LED from your browser at http://bluegrays-esp.local/.

ESP32 OTA Update — Wireless Firmware Installation (With LCD Screen)
In this project you'll learn to upload new firmware to the ESP32 over Wi-Fi, without a USB cable. With the ArduinoOTA library the ESP32 becomes visible on the network and shows up automatically as bluegrays-ota under "Network port" in the Arduino IDE. The first upload goes over USB; after that every update is wireless, a key feature for devices out in the field.

Automatic Lighting with the ESP32 PIR Motion Sensor
In this project an HC-SR501 PIR motion sensor detects someone entering the room and turns on an LED automatically. millis() tracks how long the LED stays on: each HIGH reading refreshes the last-motion time, and the LED turns off at least 10 seconds after the last HIGH. The code also waits 50 ms with delay(50) in every loop, so the loop is not fully non-blocking. Great for stairs, hallways, bathrooms or closet lighting.

ESP32 Motion Alarm System (PIR + Buzzer + LED + Telegram)
A smart security alarm: when the PIR sensor detects motion, it sounds the buzzer, lights the LED and sends the owner an instant Telegram notification. A 30-second cooldown limits how often the alarm repeats; it does not filter out the PIR sensor's false detections. Use it at home, in a garage, a storeroom or a study.
More articles
BlueGrays app
Build this circuit step by step on your phone
Wiring diagram, code and parts list on one screen. 500+ Arduino, ESP32, ESP8266, Pico, mBot and micro:bit projects ready to build.
Scan with your phone
Point your camera at the code and your phone's app store opens.
or open the store

