Community project

Smart Plant Watering Monitor

Photo of Smart Plant Watering Monitor
Generated with AI

Jonathan Diaz

Published November 30, 2026

This smart plant watering monitor uses soil moisture and air temperature sensors to track plant conditions on a small OLED display. When soil dries out, the system can automatically trigger a water pump to deliver measured doses, helping keep plants healthy without constant manual checking.

The guide provides a complete wiring diagram, parts list, and step-by-step assembly instructions using an Arduino Uno, DHT22 temperature/humidity sensor, capacitive soil moisture sensor, relay module, and submersible pump. Firmware with calibration routines and safety limits (maximum three 2-second doses per watering cycle) is included, along with serial commands for setup and testing.

Wiring diagram

Wiring diagram for Smart Plant Watering Monitor
Loading diagram…

Gather all the parts

QtyComponent
1

DHT22

Digital temperature and humidity sensor

1

Gravity: IP65 Capacitive Soil Moisture Sensor

Capacitive soil moisture sensor with IP65 waterproof and corrosion-resistant construction. Compatible with Arduino, ESP32, and Raspberry Pi.

1

0.96" OLED Display 128x64 I2C (Blue)

Monochrome 0.96 inch OLED display with 128 x 64 blue pixels, driven by an SSD1306 controller over I2C (address 0x3C). It runs from 3.3 to 5 V and connects through a four-pin VCC, GND, SCL, SDA header.

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

DFR0017 active-high relay module

5 V relay with normally open pump switching contacts.

1

4xAA Battery Pack

Four alkaline AA cells in series, nominal 6 V, ~2500 mAh. Cheap non-rechargeable choice for portable Arduino Uno-style projects; feeds VIN through the on-board regulator.

1

1N4007 Diode

General-purpose silicon rectifier diode in DO-204AL (DO-41) axial through-hole package. Rated 1A average forward current and 1000V peak reverse voltage (VRRM). Forward voltage drop ~0.7V at typical load (up to 1.1V at full 1A). Used here in series with LM7805 Vout for reverse polarity protection: anode to LM7805 output, cathode to 5V rail, resulting in ~4.3V on the output rail. Not suitable for high-frequency switching (reverse recovery ~2µs–30µs); intended for DC or 50/60Hz rectification only.

1

3–6 V mini submersible water pump

Two-wire 3–6 V pump, 130–220 mA running current. Red positive, black negative.

Assemble it in 5 steps

1. Keep both supplies disconnected

Use a 128x64 SSD1306 I2C module, an analog capacitive soil probe, a 3–6 V pump and an active-HIGH DFR0017 relay. Check your parts match before wiring. This build uses USB for the Uno and four alkaline AA cells only for the pump.

  • Do not connect the 6 V battery to the Uno 5V pin or USB. Do not switch mains electricity.

2. Connect the air and soil sensors

DHT22 VCC to 3V3, GND to GND, DATA to D2 (air readings). Connect the 10 kΩ resistor between DATA and 3V3. On a bare four-pin DHT22 viewed from its vented front, pins left to right are VCC, DATA, unused, GND. Soil VCC to 3V3, GND to GND and AOUT to A0 (soil reading).

  • DHT data uses a 3.3 V pull-up; the firmware only pulls the data line low, not high. Soil output is analog input only. Keep probe electronics above the soil.

3. Connect the screen and relay control

OLED VCC to 5V, GND to GND, SDA to A4 (data), SCL to A5 (clock). Relay VCC to 5V, GND to GND and IN to D7 (pump command). Wire by printed labels, not header position.

  • Before adding battery power, confirm the relay is off during reset and disabled mode. This firmware requires active-HIGH control; an active-LOW relay is not interchangeable.

4. Connect the pump circuit

Battery positive goes to relay COM. Relay NO goes to pump positive (red). Pump negative goes to battery negative. Put the diode across the pump: banded cathode to pump positive and unbanded anode to negative. Leave NC unconnected. Do not route pump current through the Uno or breadboard.

  • The diode is an additional required part. Reversing it shorts the battery when the relay closes. Keep water away from all electronics. Never run the pump dry.

5. Calibrate and test small doses

Put the pump under water and secure its tube above the reservoir waterline to prevent siphoning. Using the serial monitor at 9600 baud, send d with the soil probe in dry soil; send w in thoroughly watered, drained soil. Send a to enable automatic watering or x to stop. Calibration and enable state reset on every restart.

  • Below 30% relative moisture, watering uses 2-second doses at least 60 seconds apart, with at most three doses per enable. Measure the delivered water before trusting this setting. The percentage is a relative calibration, not laboratory water content.
  • No reservoir sensor is included. Supervise watering, keep the reservoir filled and do not leave this prototype unattended. A disconnected analog sensor cannot always be detected.

Review all connections

1. Connections between "air" and "Arduino"

FunctionairArduino
powerVCC3V3
groundGNDGND
dataDATAGPIO 2

2. Connections between "pullup" and "Arduino"

FunctionpullupArduino
powerP13V3
digitalP2 → DHT22 DATAEXT

3. Connections between "soil" and "Arduino"

FunctionsoilArduino
powerVCC3V3
groundGNDGND
analogAOUTGPIO 14

4. Connections between "oled" and "Arduino"

FunctionoledArduino
powerVCC5V
groundGNDGND
i2cSDAGPIO 18
i2cSCLGPIO 19

5. Connections between "relay" and "Arduino"

FunctionrelayArduino
powerVCC5V
groundGNDGND
digitalINGPIO 7
digitalNO → 3–6 V mini submersible water pump PLUSEXT

6. Connections between "battery" and "Arduino"

FunctionbatteryArduino
power+6V → DFR0017 active-high relay module COMEXT

7. Connections between "pump" and "Arduino"

FunctionpumpArduino
groundMINUS → 4xAA Battery Pack GNDEXT

8. Connections between "diode" and "Arduino"

FunctiondiodeArduino
powerCathode → 3–6 V mini submersible water pump PLUSEXT
powerAnode → 3–6 V mini submersible water pump MINUSEXT

Deploy the firmware

#include <Arduino.h>
#include <Wire.h>
#include <U8x8lib.h>
#include <DHT.h>
#include <math.h>
U8X8_SSD1306_128X64_NONAME_HW_I2C oled(U8X8_PIN_NONE);
DHT air(2, DHT22);
// DFR0017 relay is active HIGH. Change only after testing without pump power.
const uint8_t RELAY=7;
int dryRaw=0, wetRaw=0, raw=0, moisture=-1;
bool haveDry=false, haveWet=false, armed=false, pumping=false;
unsigned long sampled=0, started=0, stopped=0;
uint8_t doses=0;
char previous[8][17] = {};
void line(uint8_t row, const char *text) {
  char padded[17]; memset(padded,' ',16); padded[16]=0;
  size_t n=strlen(text); if(n>16)n=16; memcpy(padded,text,n);
  if(strcmp(previous[row],padded)) { oled.drawString(0,row,padded); strcpy(previous[row],padded); }
}
void stopPump() { digitalWrite(RELAY,LOW); if(pumping) stopped=millis(); pumping=false; }
void setup() {
  digitalWrite(RELAY,LOW); pinMode(RELAY,OUTPUT);
  Serial.begin(9600); air.begin(); oled.begin(); oled.setPowerSave(0);
  oled.setFont(u8x8_font_chroma48medium8_r);
  line(0,"Plant monitor");
  Serial.println(F("Pump disabled. Send d in dry soil, w in well-watered drained soil; a arms; x stops. Calibration is RAM only. Three 2-second doses max per arm, 60 seconds apart. Never run pump dry."));
  stopped=millis();
}
void loop() {
  unsigned long now=millis();
  if(pumping && now-started>=2000UL) stopPump();
  if(Serial.available()) {
    char c=Serial.read();
    if(c=='x') { armed=false; stopPump(); }
    if(c=='d'||c=='w') {
      armed=false; stopPump();
      long sum=0; for(byte i=0;i<16;i++) sum+=analogRead(A0);
      if(c=='d'){ dryRaw=sum/16; haveDry=true; } else { wetRaw=sum/16; haveWet=true; }
      Serial.print(F("Dry=")); Serial.print(dryRaw); Serial.print(F(" Wet=")); Serial.println(wetRaw);
    }
    if(c=='a' && haveDry && haveWet && abs(dryRaw-wetRaw)>50) {
      armed=true; doses=0; stopped=now; Serial.println(F("Armed; first dose no sooner than 60 seconds."));
    }
  }
  if(now-sampled<2500UL) return;
  sampled=now;
  long sum=0; for(byte i=0;i<16;i++) sum+=analogRead(A0); raw=sum/16;
  bool valid=raw>5 && raw<1018;
  moisture=-1;
  if(haveDry&&haveWet&&abs(dryRaw-wetRaw)>50&&valid)
    moisture=constrain((long)(raw-dryRaw)*100/(wetRaw-dryRaw),0L,100L);
  if(!valid) { armed=false; stopPump(); }
  if(armed&&!pumping&&moisture>=0&&moisture<30&&doses<3&&now-stopped>=60000UL) {
    digitalWrite(RELAY,HIGH); pumping=true; started=now; doses++;
  }
  if(doses>=3&&!pumping) armed=false;
  float t=air.readTemperature(), h=air.readHumidity();
  char b[24], v[10];
  if(isnan(t)) line(1,"Temp: error"); else {dtostrf(t,4,1,v); snprintf(b,sizeof b,"Temp: %s C",v); line(1,b);}
  if(isnan(h)) line(2,"Humidity: error"); else {dtostrf(h,4,1,v); snprintf(b,sizeof b,"Humidity:%s%%",v); line(2,b);}
  snprintf(b,sizeof b,"Soil raw: %d",raw); line(3,b);
  if(moisture<0) line(4,"Soil: calibrate"); else {snprintf(b,sizeof b,"Soil: %d%%",moisture); line(4,b);}
  line(5,pumping?"Pump: ON":"Pump: OFF");
  line(6,armed?"Auto: armed":"Auto: disabled");
  line(7,!valid?"Sensor fault": "d dry w wet a go");
  Serial.print(F("Raw=")); Serial.print(raw); Serial.print(F(" Soil%=")); Serial.println(moisture);
}

Remix this project

Make it yours in one click

Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.

Open in Schematik