Building a night vision camera with Raspberry Pi NoIR and infrared LEDs enables 24-hour surveillance and wildlife monitoring without visible light. The NoIR (No Infrared Filter) camera captures near-infrared light (750-1000nm) that is invisible to humans but can be projected by cheap IR LEDs. This guide covers the NoIR camera, IR LED array design, and complete night vision project setup.
Table of Contents
- How Night Vision Camera Works
- Raspberry Pi NoIR Camera
- IR LED Array Design
- Complete Night Vision Setup
- Night Motion Detection Code
- India Applications: Wildlife, Security
- Frequently Asked Questions
How Night Vision Camera Works
Standard cameras include an IR-cut filter that blocks infrared light (to improve colour accuracy in daylight). The Raspberry Pi NoIR camera removes this filter, allowing it to see near-infrared light. When you illuminate the scene with 850nm IR LEDs (invisible to human eyes), the NoIR camera sees a well-lit scene while appearing to be in complete darkness to observers. This is how security cameras with “night vision” work.
Raspberry Pi NoIR Camera
- Pi NoIR Camera v2: IMX219 sensor, no IR filter, 8MP, 62° FOV. Produces a purple/pink tint in daylight (plants appear light pink/white — IR reflects strongly from chlorophyll).
- Pi Camera Module v3 NoIR: IMX708, no IR filter, 12MP, autofocus. Best current NoIR option.
- Arducam NoIR with motorised IR-cut: Switches between standard and NoIR modes automatically — full colour in day, IR-sensitive at night. Most professional option.
NoIR vs Standard Camera in Daylight
The NoIR camera in daylight captures infrared light alongside visible light, giving an “infrared photography” look — sky appears white, vegetation appears bright. To restore natural colour in daylight with a NoIR camera, place a visible-light bandpass filter (Schott BG3 or similar) in front of the lens — this blocks IR and restores normal colour for daytime use while the NoIR mode is still available without the filter.
IR LED Array Design
For indoor or close-range (up to 5m) night vision, IR LEDs are sufficient. Design an IR illuminator:
# IR LED array for 3m night vision range:
# Components:
# - 10x 850nm IR LEDs (5mm or SMD)
# - 1x IRF520 MOSFET or 2N2222 transistor
# - Resistors (calculate for your supply voltage)
# - Raspberry Pi GPIO pin for control
# LED current calculation:
# 850nm LED forward voltage: ~1.2V
# Desired current per LED: 50mA
# Series resistance = (Vsupply - Vf) / If
# = (5V - 1.2V) / 0.05A = 76Ω (use 68Ω or 82Ω standard value)
# Connect 5-10 LEDs in parallel (each with its own resistor)
# Drive via GPIO pin through MOSFET (GPIO can't supply >12mA directly)
# In Python:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
IR_LED_PIN = 18
GPIO.setup(IR_LED_PIN, GPIO.OUT)
GPIO.output(IR_LED_PIN, GPIO.HIGH) # Turn on IR illuminator
IR LED Range Guidelines
- 5 LEDs (50mA each), no lens: 2–4m effective range
- 10 LEDs with reflector: 5–8m range
- 20+ LEDs with focused reflector: 10–15m range
- Commercial IR illuminator (850nm, 24 LEDs): India price ₹400–1,200, 15–30m range. Easiest option for outdoor use.
Complete Night Vision Setup
# Complete night vision camera setup
from picamera2 import Picamera2
import RPi.GPIO as GPIO
import cv2, time
IR_LED_PIN = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(IR_LED_PIN, GPIO.OUT)
picam2 = Picamera2()
config = picam2.create_preview_configuration(
main={"format": "RGB888", "size": (1280, 720)}
)
picam2.configure(config)
picam2.start()
# Enable IR LEDs (turn on illuminator)
GPIO.output(IR_LED_PIN, GPIO.HIGH)
time.sleep(2) # Let camera adapt to low-light
print("Night vision active. IR LEDs on.")
while True:
frame = picam2.capture_array()
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
# In IR mode, image will be grayscale-looking
# Convert to grayscale for cleaner output
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
cv2.putText(gray, timestamp, (10, 30),
cv2.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 2)
# Save frame every 10 seconds
if int(time.time()) % 10 == 0:
cv2.imwrite(f'/tmp/night_{int(time.time())}.jpg', gray)
# Display or send to stream
cv2.imshow('Night Vision', gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
GPIO.output(IR_LED_PIN, GPIO.LOW) # Turn off IR LEDs
picam2.stop()
Night Motion Detection Code
import cv2
import numpy as np
prev_frame = None
motion_threshold = 25 # Pixel difference threshold
def detect_motion(frame):
global prev_frame
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
gray = cv2.GaussianBlur(gray, (21, 21), 0)
if prev_frame is None:
prev_frame = gray
return False, frame
diff = cv2.absdiff(prev_frame, gray)
thresh = cv2.threshold(diff, motion_threshold, 255, cv2.THRESH_BINARY)[1]
thresh = cv2.dilate(thresh, None, iterations=2)
contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)
motion_detected = False
for c in contours:
if cv2.contourArea(c) < 500: # Ignore small movements
continue
motion_detected = True
(x, y, w, h) = cv2.boundingRect(c)
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
prev_frame = gray
return motion_detected, frame
India Applications: Wildlife, Security
- Wildlife camera trap: Popular in India for monitoring tigers, leopards, deer near forest edges. NoIR camera + 850nm IR LED array + PIR motion trigger + battery power = unobtrusive wildlife camera. The animals don’t see the IR illumination.
- Home security: Raspberry Pi NoIR + 12-LED IR illuminator creates a night-capable security camera for under ₹4,000 — significantly cheaper than commercial IP cameras with night vision.
- Crop monitoring: IR photography reveals plant stress (NDVI index) visible before it becomes visually apparent — useful for farmers monitoring irrigation and disease in fields.
Frequently Asked Questions
Will 940nm or 850nm IR LEDs work better with Pi NoIR camera?
850nm LEDs are preferred. The Sony IMX219 sensor in the Pi NoIR v2 camera is most sensitive at around 700–850nm and less sensitive at 940nm. 850nm LEDs also have slightly visible red glow (barely noticeable in a dark room), while 940nm is truly invisible. If complete invisibility is critical (covert surveillance), use 940nm with a higher LED count or power to compensate for the lower sensitivity. For most applications, 850nm is the better choice.
How far can a Raspberry Pi NoIR camera see at night with IR LEDs?
With a 10-LED 850nm illuminator (each at 50mA): 3–5m in complete darkness. With a commercial 24-LED IR illuminator (₹600–1,200): 8–15m. With a high-power IR floodlight (₹2,000–5,000): 20–40m. The limiting factor is typically the IR LED power, not the camera sensitivity. For long-range night vision (50m+), use a proper IR laser illuminator or a commercial CCTV IR illuminator rated for the distance.
Add comment