Skip to content

An edge + cloud smart farm that survives an internet outage

Separate control from analysis, keep data in the right place, and let the board own safety.

Published

TLSLANESP32Boards in the plotCloudweb, app, alerts, rulesEdge at homeraw data, AI, Grafana

The hydroponic plot at my home tests an idea I also use in factories: control must never fail because analysis is down.

The Baan Rak Phak hydroponic greenhouse

Figure: the real plot this system looks after. Source: the author.

The Baan Rak Phak web sign-in page

Figure: the Baan Rak Phak web sign-in; the farm is run from web, cloud and mobile. Source: the author.

  • Baan Rak Phak app home: live climate and AI adviceLive values, AI advice
  • Weather forecast and water readings with warningsWeather and water
  • Pump, mister and relay controls (all still switched off)Device control

Two paths, two jobs

The ESP32 boards in the plot report on two paths at once. The first goes to a cloud server over MQTT with TLS and serves the web, the mobile app, alerts, automation rules and firmware updates. The second goes over the LAN to an edge computer at home, which keeps every raw reading every 10 seconds and runs AI.

If the edge computer is off, the farm, web and app keep working. If the home internet drops, the edge still gets data straight from the boards, with no gap.

Keep data in the right place

All raw data lives on the edge, because it is large and it is what AI learns from. The cloud keeps only what has to be seen from outside. The same rule suits factories that do not want production data leaving the site.

Edge at home: all raw dataEvery 10 secondsEvery value keptAI and GrafanaLarge data, close to the plot, no transfer costCloud: only what people needLatest valuesHourly summariesAlerts and rulesSmall data, reachable from anywhere

Safety lives on the board

Every relay has a maximum on-time and switches off by itself when contact is lost for too long. Whether a command comes from a person, a rule or an AI, the board has the final say on safety.

Internet dropsBoard stops the pump itselfConnectionConnectedLostWater pumpOnOff0300 s after the drop

AI that reads the forecast

The system pulls a weather forecast every hour. If the afternoon will be very hot, a rule starts misting in pulses before the hot hours, and rests when rain is likely or the greenhouse is already humid. The data collected along the way will train a model that predicts greenhouse temperature.

A watering rule that looks aheadRain forecastahead of timeChance of rainabove limit?Skipthat roundLog the reasonfor reviewSaves water and nutrients and keeps roots from waterlogging

A small lesson from the real thing

The first edge computer was a laptop. Closing the lid put it to sleep and half an hour of data was lost. Any system that must always run needs power cuts, sleep and its network address checked from day one.

Talk about a role