← Projects
raspberry-pi intermediate 10 days ago ◑ 28 views ◯ 5 min read

Build a Raspberry Pi Plant Disease Detection Camera: On-Device Computer Vision for Early Blight and Pest Spotting

Build time: 1 weekend
Tools needed: Drill for enclosure mounting, basic Python/Linux familiarity, soldering iron (optional for wiring cleanup)
raspberry picomputer visiongardencamera automationmachine learning
Parts List

By the time leaf blight or a pest infestation is obvious to the eye walking past a garden bed or greenhouse row, it's often already spread. A fixed camera checking plants on a schedule and flagging anything that looks off catches problems earlier than an occasional walk-through does โ€” and a Raspberry Pi with a basic vision model is enough hardware to do it without a cloud subscription or a commercial agricultural sensor package. This project builds a weatherproof camera station that watches a bed or greenhouse row and reports likely trouble spots.

What This Project Actually Does (and Doesn't)

This builds a monitoring and triage tool, not a lab diagnosis. The camera and on-device model flag visually distinctive symptoms โ€” leaf discoloration patterns, spotting, wilting, visible pest damage โ€” well enough to tell you "go look at bed 3" instead of discovering a problem days later. It won't reliably distinguish between similar-looking diseases, won't catch problems with no visible symptoms yet, and works best as an early-warning system that still ends with you walking over and looking at the actual plant. Treat its output as a prioritized checklist, not a diagnosis.

How It Works

A Raspberry Pi with a camera module captures images on a schedule (every 15-60 minutes during daylight is typical), runs them through a lightweight on-device classifier trained on common leaf disease and pest-damage patterns, and logs or alerts when a frame scores above a confidence threshold for "looks abnormal." Running inference on-device means no images or notifications depend on an internet connection or a subscription service, and nothing about your garden leaves your network unless you choose to forward alerts somewhere.

Software Setup

  1. Flash Raspberry Pi OS (Lite is sufficient since this runs headless) and enable the camera interface and SSH during initial setup.
  2. Install a lightweight inference runtime. TensorFlow Lite or a comparable lightweight runtime runs well enough on a Pi 4/5 CPU for infrequent, scheduled image classification โ€” you don't need a dedicated accelerator like a Coral USB or Hailo HAT for a once-every-15-minutes capture rate, though adding one (covered elsewhere on this site) shortens inference time if you want more frequent checks.
  3. Use or fine-tune a plant disease classification model. Several open, pre-trained plant leaf disease datasets and models exist publicly for common crops; a pre-trained general model gives a reasonable starting point, but accuracy improves meaningfully if you fine-tune on your own photos of healthy plants in your actual setup, since lighting, camera angle, and plant variety all affect real-world accuracy more than dataset benchmarks suggest.
  4. Script the capture-classify-alert loop. A simple Python script on a cron schedule (or a systemd timer) captures a frame, runs it through the model, logs the result with a timestamp and confidence score, and sends a notification โ€” a webhook into Home Assistant or a simple MQTT message, matching the automation patterns this site's other ESP32/Pi garden projects already use โ€” when confidence crosses your chosen threshold.
  5. Tune the alert threshold deliberately. Start conservative (fewer false alarms, possibly missing a borderline case) and loosen the threshold once you've seen a week or two of real output and know what a false positive looks like for your specific setup.

Camera Placement and Lighting

Consistent framing matters more than camera quality for this application โ€” mount the camera on a fixed arm or tripod pointed at the same bed section each time rather than moving it between captures, since a model trained or tuned on consistent framing degrades quickly against inconsistent angles and distances. Diffuse, consistent lighting (shoot in similar conditions across captures, or add a simple fixed light source for a greenhouse setup) reduces false positives caused by shadows and glare being misread as discoloration.

Weatherproofing

Outdoor placement needs a genuinely sealed enclosure, not just a "resistant" one โ€” moisture inside a camera housing fogs the lens and eventually kills the electronics. Use a proper IP-rated enclosure with a clear lens window, seal all cable entries with cable glands rather than drilled holes and silicone alone, include a desiccant pack that you can swap out, and route the power cable with a drip loop so water running down the cable doesn't follow it straight into the enclosure.

Limits and Honest Expectations

On-device models at this scale will produce false positives (a shadow, a water droplet, a naturally senescing older leaf flagged as diseased) and false negatives (early-stage problems with subtle symptoms missed entirely). Treat this as a tool that redirects your attention faster than a random walk-through would, not as a substitute for actually knowing your plants and checking anything it flags in person before acting โ€” pulling or treating a plant based solely on an automated alert, without visual confirmation, risks acting on a false positive.