One brain for the greenhouse — building integrated climate control with AI, and the day I chose to stop

One brain for the greenhouse" with an illustration: The star mascot conducting the roof vents, fans and misting in the greenhouse while I watch

I am bringing every climate decision in my strawberry greenhouse into one system, built with Claude Code. CO2, circulation fans, misting and, since November 22, the roof vents run on it. Each action now comes with a reason I can see on a screen.

The big picture

Sensors feed a Raspberry Pi, which records the readings. An integrated control program decides and sends set points to the climate controller. A few things, such as misting, are driven directly, and the reasons appear on a dashboard and in notifications
The Pi sends set points only. The climate controller decides how far to open the vents
  • Sensors (temperature and humidity, CO2, solar radiation, outside air) feed a Raspberry Pi, which stores the readings in a small database.
  • An integrated control program, with modules for CO2, circulation fans, misting and roof vents, sends set points to a commercial climate controller.
  • The Pi never says "open the vent to X percent." The controller decides how far to open. Misting and a few other things are driven by the Pi directly.
  • Each decision carries a number that points to a written decision record kept next to the code. The dashboard shows it.

Tools: Raspberry Pi, a commercial climate controller, SwitchBot sensors and smart plugs, Python (Flask and SQLite), and LINE for notifications.

Switching from old to new, in six steps

  1. Shadow mode: the new system only records what it would do. The old system keeps running.
  2. Side-by-side comparison: roof vents need at least seven full days of passing results, and the count restarts when the code version changes. Misting switched only after four days of decisions matched completely.
  3. Rehearsal: on a Mac with a copy of production data and fake devices. On site, I rehearse only "stop the old system, then restore it."
  4. Cutover day: ten minutes or less from stopping the old system to the first command from the new one. Otherwise, abort and roll back.
  5. A human checks the actual values and approves them before switching.
  6. A human watches for two hours, then monitors for a week. A rollback procedure is always ready.

What I do not let the AI decide

  • Claude writes the code, tests, runbooks, rehearsals and dashboard mockups.
  • I decide the cutover date, the final go, how much change is acceptable, and the look.
  • Stopping or restarting control, or editing production data, always needs a human.
  • The controller's physical manual/auto switch cannot be overridden by software. A person reports its position. If the report gets stale, the new system stops sending commands.

What went wrong

  • A forgotten reason: an early-morning restriction marked "remove later" lost its reason, and a guess almost became the explanation. Now every decision gets its own record next to the code.
  • The manual: the controller did not behave the way I had assumed.
  • The roof vent cutover on November 21: after the old system stopped, the cutover tool refused to proceed because it could not read the stop time. The rehearsal had stopped the old system slightly differently, so the gap never showed. I did not bypass the safety check. I aborted and restored the old system, then fixed the tool.
  • The second attempt, at 1 p.m. on November 22: this time the stop time was readable. But the controller applied a value the old system had written just before stopping, a little late, and the mismatch was recorded. I aborted and rolled back again. Checking conditions only after the old system has stopped is too late. Now every condition is checked before the stop, and I wait a few minutes after the old system's last write.
  • The third attempt, at 1:20 p.m., worked. The first command from the new system matched the real equipment.
  • Right after that, I found a missing rule: when the only change is a small correction, keep the value from ten minutes earlier. Without it, the new system was rewriting the value almost every minute. It was not dangerous, so instead of rolling back, I added the rule.

The lesson: if the rehearsal differs from the real cutover, holes stay hidden.

If you want to start on a weekend

  • Start in shadow mode: record decisions before anything moves.
  • Decide how you will roll back before you stop the old system.
  • Write down the reason for each decision, next to the code.

The full story, in Japanese: 温室の「なぜ今この動き?」を1つにまとめた

Why this matters beyond my farm

The hard part was never the sensors or the code. It was keeping the reasons visible, so that people and AI do not fill gaps with guesses, and keeping a human on every irreversible step. AI made the building fast. Deciding when to stop stayed with me.