You are browsing as a guest. Sign up (or log in) to start making projects!

Open comments for this post

3h 21m 24s logged

DevLog #1 — Teaching a Raspberry Pi to Worry About My Plants

Why I Started This Project

I kept killing plants.

Not from neglect exactly. More from guessing wrong. Water too much, the roots rot. Water too little, the leaves curl. The problem isn’t that I don’t care. It’s that I have no idea what’s actually happening underground.

That’s what GardenBuddy is. A Raspberry Pi that watches your soil, temperature, humidity, and light in real time and tells you specifically what to do about it.

The Vision

Most plant monitors give you raw numbers. 48% soil moisture. 72°F.

Okay. Is that good? Should I water now or in three hours?

I wanted the system to answer that question directly.

Not just “your soil is at 48%” but “your plant is stable, humidity is the primary stressor right now, here’s what to do.”

That meant building two models, not one.

What I Built

The core is a double-model AI pipeline.

Model 1 is an LSTM classifier. It trains on your own sensor history. Looks at the last 30 readings (5 minutes of data) and classifies plant health as thriving, stable, stressed, or critical. Because it trains on your garden’s data specifically, it learns the dynamics of your setup rather than thresholds someone else picked.

Model 2 is a local LLM (Ollama, llama3.2:3b). It takes the LSTM’s structured output, the health class, the primary stressor, the confidence score, and writes two actionable sentences in plain English. It runs in a background thread every 30 seconds so it never blocks sensor polling.

The whole thing runs on your local network. No cloud. No API keys. No internet required.

Current features:

  • ✓ Live readings every 10 seconds: soil, temp, humidity, light
  • ✓ Rolling 5-minute history charts for each sensor
  • ✓ Garden Health Score (0-100) combining all four sensors
  • ✓ LSTM health classification with confidence and stress vector
  • ✓ Ollama-generated plain-English care advice
  • ✓ RGB LED on the Pi that goes green, amber, or red based on health score
  • ✓ InfluxDB writes for long-term history
  • ✓ Automated alerts for low soil, heat stress, and fungal risk

The Cleanup That Took Longer Than the Feature

After the AI pipeline landed, sensor_reader.py was 454 lines.

About 200 of those were fallback paths and stubs I had written “just in case the model wasn’t loaded” or “just in case Ollama timed out.” They made sense while I was building. They made the code unreadable once the system was stable.

Spent an entire session deleting them. Thirteen files touched, 219 lines removed, zero new functionality.

That cleanup felt like the project actually becoming real.

The Hardware Side

The physical setup is a Raspberry Pi 3B+ wired to a DHT22 for temperature and humidity, a capacitive soil moisture probe through an ADS1115 ADC over I2C, a photoresistor for light level, and an RGB LED that reflects the health score in real time.

Soil calibration is two constants you measure once: ADC reading in dry air and ADC reading fully submerged. Everything else derives from those.

Challenges

The hardest part was making the LLM feel useful rather than generic.

Early versions of the Ollama prompt just got handed raw sensor numbers. The responses came back vague. “Ensure adequate watering.” The model was reasoning about numbers without context for what they meant.

The fix was making the LSTM go first. Now Ollama receives structured signals: health class, primary stressor, confidence. The responses got specific immediately. The model has something to anchor to.

Looking Ahead

The foundation is working. Sensors are reading, the LSTM is classifying, Ollama is advising, the LED is changing color.

What’s missing is a trained model that has seen more than a few days of data, and a real test of the alerts under actual stress conditions. Planning to intentionally underwater and watch the score drop.

Apparently it’s doing fine.

0
3

Comments 0

No comments yet. Be the first!