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

Arduino-Controlled Soil Moisture Sensing and Water Pump System

View and Edit Project In Cirkit DesignerImage of Arduino-Controlled Soil Moisture Sensing and Water Pump System

Circuit Documentation

Summary of the Circuit

This circuit is designed to monitor soil moisture levels and control a water pump based on the moisture data. It uses an Arduino Nano as the central microcontroller to read analog data from a Soil Moisture Sensor and then controls a relay module that switches a water pump on or off. The system is powered by an 18650 Li-Ion battery, which provides the necessary voltage to the components. The relay module acts as an intermediary to safely control the high-power water pump using the low-power signals from the Arduino Nano.

Component List

SparkFun Soil Moisture Sensor

Soil Moisture Module

Relay Module 5V-30V

18650 Li-Ion Battery

Water Pump

Arduino Nano

Wiring Details

SparkFun Soil Moisture Sensor

Soil Moisture Module

Relay Module 5V-30V

18650 Li-Ion Battery

Water Pump

Arduino Nano

Documented Code

Arduino Nano Code (sketch.ino)

#define ledPin 6
#define sensorPin A0

void setup() {
  Serial.begin(9600);
  pinMode(sensorPin, OUTPUT);
}

void loop() {
  Serial.print("Analog output: ");
  Serial.println(readSensor());

  delay(500);
}

int readSensor() {
  int sensorValue = analogRead(sensorPin);  // Read the analog value from sensor
  int outputValue = map(sensorValue, 0, 1023, 255, 0); // map the 10-bit data to 8-bit data
  analogWrite(ledPin, outputValue); // generate PWM signal

  return outputValue;             // Return analog moisture value
}

Note: The code provided for the Arduino Nano includes a function readSensor() that reads the analog value from the soil moisture sensor connected to pin A0, maps the 10-bit analog input to an 8-bit value, and writes this value to ledPin (which is not connected in the provided net list). The Serial.print statements are used for debugging purposes to output the sensor value to the serial monitor. The pinMode for sensorPin should be set to INPUT instead of OUTPUT to correctly read the analog sensor data.

The code for the 18650 Li-Ion microcontroller instance is empty and thus not included in the documentation.