Projects / Greenhouse trend monitor

Greenhouse trend monitor

Intermediate1.3 hGuided buildReviewed
ESP32 DevKitGPIO21GPIO22GPIO34GPIO35BME280LightSoilGreenhouse31 Csoil 42 %light 2100Phone page
Serial at 115200 baud

Tap a part to see what it does.

Tap the parts to see what each one does. A teaching simulation, not a circuit simulator.

Build it step by step

0 of 4 done
  1. ESP32BME28026.7°C

    BME280

    SDA 21, SCL 22.

  2. ESP32630 lux

    Light divider

    LDR from 3V3 to GPIO34, 10 kΩ from GPIO34 to GND.

  3. ESP32CAPACITIsoil 52%

    Soil sensor

    AOUT to GPIO35.

  4. ESP32

    Wi-Fi and upload

    Enter your network, upload, open the IP on your phone.

In short

How do you build a greenhouse trend monitor?

An ESP32 measures air temperature, humidity, light and soil moisture and serves a phone page with the latest values and a 24-hour trend for each. You need ESP32 DevKit V1, BME280 Environmental Sensor, LDR Photoresistor, Resistor 10 kΩ, Capacitive Soil Moisture Module and Breadboard 830 Tie Points. It takes 4 steps and about 75 minutes.

Level
Intermediate
Time
About 75 min
Parts
6

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
BME280 SDA / SCLGPIO21 / GPIO22I2C
LDR + 10 kΩ dividerMiddle to GPIO34Light
Soil AOUTGPIO35Soil moisture
All VCC / GND3V3 / GNDPower

Code

Library: Adafruit BME280. Soil calibration (2900 dry, 1250 wet) comes from the Plant soil logger; use your own numbers. Paste the table into a spreadsheet to chart it.

Runs on a virtual ESP32 Dev Module in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <WiFi.h>
#include <WebServer.h>
#include <Adafruit_BME280.h>
Adafruit_BME280 bme;
WebServer server(80);
const int N = 96;                  // 24 h at one sample per 15 min
float T[N], H[N]; int L[N], S[N], head = 0, count = 0;

void sample() {
  T[head] = bme.readTemperature(); H[head] = bme.readHumidity();
  L[head] = analogRead(34); S[head] = map(analogRead(35), 2900, 1250, 0, 100);
  head = (head + 1) % N; if (count < N) count++;
}

void page() {
  String s = "<meta name=viewport content='width=device-width'><h2>Greenhouse</h2><pre>time,temp,hum,light,soil\n";
  for (int i = 0; i < count; i++) { int k = (head - count + i + N) % N; s += String(i * 15) + "," + T[k] + "," + H[k] + "," + L[k] + "," + S[k] + "\n"; }
  server.send(200, "text/html", s + "</pre>");
}

void setup() {
  Serial.begin(115200); bme.begin(0x76);
  WiFi.begin("your-wifi", "your-password");
  while (WiFi.status() != WL_CONNECTED) delay(300);
  Serial.println(WiFi.localIP());
  server.on("/", page); server.begin(); sample();
}

void loop() {
  server.handleClient();
  static unsigned long last = 0;
  if (millis() - last > 15UL * 60 * 1000) { last = millis(); sample(); }
}

What the serial monitor should show

Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual ESP32 Dev Module with its sensors at their default values. Your numbers will follow your real readings, but the format should match.

192.168.1.42

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Open the pageOne line of readings straight away
After an hourFour more lines, 15 minutes apart
Water the plantSoil percentage jumps in the next sample

If it does not work

Page will not load

Phone on a different network, or guest Wi-Fi blocks devices.

Soil reads 0 or 100 always

Recalibrate dry and wet values.

History lost

It lives in RAM: a reset clears it. Add the SD card logger for long runs.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the greenhouse trend monitor?

ESP32 DevKit V1, BME280 Environmental Sensor, LDR Photoresistor, Resistor 10 kΩ, Capacitive Soil Moisture Module and Breadboard 830 Tie Points.

How long does the greenhouse trend monitor take to build?

About 75 minutes for a intermediate maker, in 4 steps.

How do I know the greenhouse trend monitor works?

Open the page: One line of readings straight away. After an hour: Four more lines, 15 minutes apart. Water the plant: Soil percentage jumps in the next sample.

Page will not load: what should I check?

Phone on a different network, or guest Wi-Fi blocks devices.

Soil reads 0 or 100 always: what should I check?

Recalibrate dry and wet values.

History lost: what should I check?

It lives in RAM: a reset clears it. Add the SD card logger for long runs.