Inspiration
Growing plants hydroponically is surprisingly hard to get right. pH drifts, humidity swings, and nutrient imbalances can kill a seedling overnight — and the "optimal" response depends on multiple interacting variables at once. I realized that Gemini 3's multimodal capabilities (vision + structured reasoning) could act as an always-on agronomist: one that sees the plant, reads the numbers, remembers what it did last time, and makes calibrated decisions — every single hour, without fatigue or guesswork.
The goal was simple: drop a basil seed into a hydroponic bucket, close the tent, and let the AI figure out the rest.
What it does
Gemini Growlab is a fully autonomous indoor growing system. A Raspberry Pi sits inside a grow tent and runs a 9-step control loop every 60 minutes:
- Reads 5 sensors — air temperature, humidity, water temperature, pH, and TDS (total dissolved solids) — each sampled 5 times with outlier rejection for reliable data.
- Captures a photo of the plant under grow lights using a USB webcam.
- Loads the last 3 AI decisions so Gemini has memory of recent actions and can avoid oscillating.
- Calls Gemini 3 Flash with the sensor readings, the plant photo, ideal basil ranges, and a detailed prompt encoding hydroponics domain knowledge.
- Receives a structured JSON response with actuator commands (
light,air_pump,humidifier,ph_adjustment), per-actuator reasoning, a plant health score (0–10), and a human intervention flag. - Executes the decisions — toggling Tuya smart plugs for the grow light, air pump, and humidifier, and running peristaltic dosing pumps for pH up/down adjustments.
- Uploads everything to Supabase — sensor data, the AI decision, reasoning, and the plant photo.
- Streams 5 minutes of video to a remote PC for timelapse assembly.
A public Next.js dashboard on Vercel displays the latest sensor readings, plant photo, AI reasoning, and health score — so anyone can watch the basil grow in near-real-time.
How I built it
Hardware layer: A Raspberry Pi 3 inside a 24"×24"×48" grow tent reads a DHT22 (air temp/humidity), DS18B20 (water temp), and analog pH + TDS sensors through an ADS1115 16-bit ADC. A DFRobot signal isolator prevents cross-talk between the pH and TDS probes sharing the same reservoir. Actuators include a VIPARSPECTRA P1000 grow light, air pump, and humidifier — all on a Tuya WP9 smart power strip controlled via the tinytuya library over LAN — plus two 12V peristaltic dosing pumps driven by a TB6612FNG motor driver for pH correction.
AI layer: The core of the system is a carefully engineered Gemini prompt. It includes the current sensor snapshot, ideal ranges for basil in deep water culture (DWC), the available actuator controls, domain-specific guidelines (e.g., "only dose pH if >0.5 outside ideal range," "light affects temperature"), and the last 3 decisions for temporal context. Gemini responds in a strict JSON schema enforced by the API's response_mime_type: application/json mode, ensuring every response is machine-parseable. The model temperature is set to 0.2 for deterministic, consistent decisions. If the API fails, the system falls back to safe defaults (light on, air pump on, humidifier off, no pH dosing) and flags for human intervention.
Cloud layer: Each cycle uploads the decision row to a Supabase PostgreSQL table and the plant photo to Supabase Storage. Row-Level Security (RLS) ensures the dashboard (using the publishable key) can only read data, while only the Pi (using the secret key) can write. The Next.js dashboard on Vercel uses ISR (Incremental Static Regeneration) with 60-second revalidation, so the public page stays fresh without hammering the database.
Everything runs headless on a cron schedule — no human in the loop.
Challenges I ran into
- First time with hardware — steep learning curve: This was my first time working with Arduino-style boards and wiring up sensors. I made wiring mistakes setting up the board early on, and debugging hardware issues is fundamentally different from debugging software — there's no stack trace when a wire is in the wrong pin.
- Soldering disaster: First time soldering, and I applied too much heat to the ADS1115 ADC converter, frying it completely. Had to throw it out, order a replacement, and start over — a lesson in patience and technique that no amount of YouTube tutorials fully prepares you for.
- Sensor noise and cross-talk: pH and TDS sensors in the same water body interfere with each other electrically. I solved this with a galvanic signal isolator on the TDS line and a multi-read averaging strategy (5 readings, discard first 2 unstable ones, average the rest).
- Humidifier caused fungal infection: Initially the humidifier ran continuously between hourly readings. Humidity shot up to ~80%, which caused fungal infection on some of the basil leaves. I learned the hard way that the humidifier needs short 5-minute bursts with auto-shutoff — now baked into the control loop.
- pH safety: Bad pH readings could cause Gemini to over-dose acid or base, killing the plant. I added hard validation bounds (3.0–9.0) and default-to-neutral logic, plus prompt-level instructions for conservative dosing only when pH drifts >0.5 outside the ideal range.
- Tuya local control: Tuya smart plugs require extracting device keys through their cloud API, then communicating over encrypted LAN protocol v3.3. Getting the DPS (data point) mapping right for a multi-outlet power strip required trial-and-error testing.
Accomplishments that I'm proud of
- True autonomy: The system has been running for over 2 weeks with the basil seedlings growing visibly — the AI handles everything from light scheduling to pH correction without manual intervention.
- Multimodal AI in a real feedback loop: This isn't a chatbot or a one-shot image analyzer. Gemini sees the plant, reads the numbers, remembers its past 3 decisions, and makes a new one — then physical actuators execute it and change the real world. The next cycle closes the loop.
- Structured reasoning you can audit: Every decision includes per-actuator reasoning (why the light is on, why pH dosing was skipped, etc.), a health score, and a human intervention flag. The full decision history is browsable on the public dashboard.
- Robust sensor pipeline: Multi-read averaging, outlier rejection, cross-talk isolation, and validation bounds make the sensor data reliable enough to trust AI decisions on.
- End-to-end cloud pipeline: Sensor data flows from GPIO pins on a Raspberry Pi to a public Vercel dashboard — all automated, all free-tier.
What I learned
- Prompt engineering for physical systems is different. When your AI controls real actuators, you need guardrails baked into the prompt: conservative dosing rules, temporal context (past decisions), and explicit "never do X when Y" constraints. A hallucinated pH adjustment can kill a plant.
- Sensor fusion is hard. Individual sensors are cheap and easy; making 5 different sensors produce trustworthy simultaneous readings in a humid, warm environment with electrical cross-talk requires real engineering (signal isolation, averaging, validation, timing delays between reads).
- Structured output mode is a game-changer. Enforcing a JSON schema on Gemini's response eliminates the entire class of parsing bugs. Every response is guaranteed to have the right fields, types, and enum values.
- Free-tier cloud stacks are remarkably capable. Supabase (500 MB free) + Vercel (100 GB bandwidth free) + a Raspberry Pi can run a production IoT monitoring system at zero marginal cost.
What's next for Gemini Growlab
- Dashboard history page: Add a history view with sensor trend charts over time, so you can see how temperature, pH, humidity, and TDS have evolved across days and weeks — not just the latest reading.
- Light intensity control: The VIPARSPECTRA P1000 supports dimming. Next step is wiring a PWM signal from the Raspberry Pi so Gemini can control not just on/off but the exact light intensity — useful for seedling vs. vegetative growth stages.
- Nutrient dosing automation: Add peristaltic pumps for FloraMicro/FloraGrow/FloraBloom to let Gemini manage the full nutrient mix, not just pH.
- Multi-plant support: Scale to multiple grow tents or buckets with per-plant AI profiles and independent actuator control.
- Gemini long-context for growth history: Feed the full growth timeline (weeks of data + photos) into Gemini's long context window for better trend-aware decisions.
- Alerting: Push notifications (email/SMS) when the human intervention flag fires, so you don't have to check the dashboard.
- Community templates: Let other growers plug in their own plant profiles (tomatoes, lettuce, herbs) and ideal ranges.
Built With
- ads1115
- dht22
- ds18b20
- gemini
- next.js
- opencv
- postgresql
- python
- raspberry-pi
- supabase
- tailwind
- tuya
- typescript
- vercel
- vertex
- webcam
Log in or sign up for Devpost to join the conversation.