Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Based Soil Moisture Monitoring and Watering System with Temperature Display

View and Edit Project In Cirkit DesignerImage of ESP32-Based Soil Moisture Monitoring and Watering System with Temperature Display

Circuit Documentation

Summary

This circuit is designed to monitor soil moisture levels and temperature, control a water pump and a fan, and display the temperature on an LCD screen. The core of the circuit is an ESP32 microcontroller, which interfaces with a soil moisture sensor, a temperature sensor, a 2-channel relay module, a 5V mini water pump, a 40mm 12V fan, and an I2C LCD 16x2 screen. The ESP32 reads the sensors' data and controls the water pump and fan via the relay module based on the sensor inputs. The temperature is displayed on the LCD screen. The circuit is powered by a 12V battery, which also directly powers the fan.

Component List

Wiring Details

Battery 12V

SparkFun Soil Moisture Sensor

ESP32 (30 pin)

5V Mini Water Pump

40mm Fan 12V

2-Channel Relay

Temperature Sensor (TEMP)

I2C LCD 16x2 Screen

Documented Code

ESP32 Microcontroller Code

// The ESP32 code is not provided in the input. Please ensure that the code for the ESP32 is included here.

Temperature Sensor Code (Running on ESP32)

/*
 * This Arduino Sketch measures the temperature using a connected
 * temperature sensor and displays the value on an I2C LCD screen.
 */

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Define the I2C address for the LCD
#define I2C_ADDR 0x27

// Initialize the LCD
LiquidCrystal_I2C lcd(I2C_ADDR, 16, 2);

// Define the pin for the temperature sensor
const int tempSensorPin = 21; // D21 on ESP32

void setup() {
  // Initialize the LCD
  lcd.begin();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Temp: ");

  // Initialize serial communication
  Serial.begin(115200);
}

void loop() {
  // Read the temperature sensor value
  int tempValue = analogRead(tempSensorPin);

  // Convert the analog value to temperature (assuming a specific sensor)
  float voltage = tempValue * (3.3 / 4095.0);
  float temperatureC = (voltage - 0.5) * 100.0;

  // Print the temperature to the LCD
  lcd.setCursor(6, 0);
  lcd.print(temperatureC);
  lcd.print(" C");

  // Print the temperature to the Serial Monitor
  Serial.print("Temperature: ");
  Serial.print(temperatureC);
  Serial.println(" C");

  // Wait for a second before the next reading
  delay(1000);
}

Note: The code for the other microcontrollers (USB Cable and 2-Channel Relay) is either not provided or is a default template without specific functionality. Additional code should be written and documented for these components based on the desired behavior of the circuit.