← Projects
raspberry-pi intermediate 11 days ago ◑ 63 views ◯ 5 min read

Build a Raspberry Pi NDVI Plant Health Camera: Multispectral Imaging for Garden and Small-Farm Monitoring

Build time: 4-6 hours
Tools needed: Small Phillips screwdriver, soldering iron (if wiring a custom dual-camera adapter), computer for Python scripting
NDVIRaspberry Pimultispectral imagingplant healthinfrared cameraprecision agriculturePi Camera
Parts List

NDVI (Normalized Difference Vegetation Index) imaging is the technology behind satellite crop-health maps and drone-based precision agriculture: healthy chlorophyll-rich vegetation strongly reflects near-infrared light while absorbing most visible red light, and the ratio between those two bands produces a value that tracks plant vigor well before stress is visible to the naked eye. What used to require a dedicated multispectral sensor is now achievable with a converted Raspberry Pi camera and some careful math, putting genuine precision-agriculture-style monitoring within reach of a backyard garden or small hobby farm. This build covers the camera modification, the capture and processing pipeline, and realistic expectations for what a DIY NDVI setup can and can't tell you.

How NDVI Actually Works

The NDVI formula is simple: (NIR − Red) / (NIR + Red), producing a value from -1 to 1 where healthy, dense vegetation typically scores 0.6-0.9, stressed or sparse vegetation scores lower, and non-living surfaces (bare soil, water, pavement) score near zero or negative. The physics behind it is straightforward — chlorophyll absorbs red light for photosynthesis but has little use for near-infrared, so it reflects NIR strongly, while a stressed or dying plant's chlorophyll content drops and that reflectance pattern shifts measurably before the leaf visibly yellows or wilts. This is exactly why NDVI monitoring catches plant stress earlier than an eyeball inspection: the spectral signal changes before the visible-light signal does.

Getting a Pi Camera to See Near-Infrared

A standard Pi Camera Module has an infrared-blocking filter built into the lens stack specifically to make visible-light photos look normal to human eyes — removing that filter (or buying a "NoIR" variant of the Camera Module, which ships without it) is the first step, since a filtered sensor simply cannot capture the NIR band NDVI needs. The NoIR module alone isn't enough on its own, though: without the IR-cut filter the sensor now captures red, green, blue, and near-infrared all mixed together, which muddies the exact red/NIR separation the NDVI formula depends on. The standard DIY fix, borrowed from the drone-mapping community, is a dual-camera rig: one camera fitted with a filter that passes only red light (a filter like a Wratten 25 red, or a dedicated NDVI red-pass filter) and a second NoIR camera fitted with a filter that passes only near-infrared and blocks visible light (an "IR pass" or 720nm+ filter, sometimes called a "NDVI camera" filter when sold as a kit). The two cameras, aimed at the same scene from as close to the same position as possible, each give you one clean band to feed into the ratio.

A cheaper single-camera alternative some hobbyists use is a modified NoIR camera with a single dual-bandpass filter that passes both red and NIR together, then separates them computationally using the fact that the camera's Bayer filter still has distinct red, green, and blue photosites underneath — the "DIY NDVI" technique from the agricultural drone community ("NGB" or near-infrared/green/blue single-camera conversion) uses this approach, trading some accuracy for a much simpler single-camera rig. Start with the dual-camera approach if accuracy matters for your use case; the single-camera trick is the faster weekend build if you mainly want qualitative before/after comparisons.

Capture and Processing Pipeline

Capture a still frame from each camera simultaneously (a short Python script using picamera2 triggering both ports back-to-back is close enough for a static scene like a garden bed), then process with a short Python script using NumPy and either Pillow or OpenCV: load both images, align them if the cameras weren't perfectly co-located (a simple pixel-offset crop is usually sufficient for a fixed rig photographing the same bed every time), extract the red channel from the red-filtered image and the equivalent channel from the NIR-filtered image, apply the NDVI formula pixel-by-pixel as floating-point arrays, and map the resulting -1 to 1 range to a false-color palette (the standard convention is red/brown for low values through yellow to deep green for high values) for a human-readable output. Open-source tools like QGIS can take this a step further if you want proper georeferenced mapping across a larger plot rather than a single fixed-camera bed view.

Mounting and Use

For a garden bed or greenhouse, a fixed overhead mount (on a post, under a greenhouse roof truss, or on an arm clamped to a raised bed frame) photographing straight down at a consistent time of day gives the most comparable day-to-day data — varying sun angle and cloud cover changes raw reflectance values enough that comparing a morning shot to an afternoon shot introduces noise that looks like plant stress but is actually just lighting. Including a gray calibration card in the frame edge lets you normalize exposure between sessions during processing, which matters more than it sounds like it should for getting a usable trend line rather than a noisy one.

Realistic Expectations

A DIY dual-camera rig will never match the spectral precision of a dedicated agricultural multispectral sensor with narrow-band interference filters — consumer camera filters pass broader, less precise wavelength bands, and camera sensor spectral response varies between units. What this build is genuinely good at is relative, within-rig comparison over time: watching NDVI trend down in one section of a bed before visible wilting, or comparing a fertilized test plot against an unfertilized control under the same camera and lighting. Treat the absolute NDVI numbers as approximate and the trends and relative comparisons as the real payoff, and this becomes a genuinely useful early-warning tool for a garden or small hobby farm at a fraction of commercial multispectral sensor cost.