This circuit is designed to create an automatic plant watering system. It utilizes a soil moisture sensor to determine when the soil is dry and then activates a relay to turn on a water pump for irrigation. The system is powered by two 3.7V batteries connected in parallel, with a step-up boost power converter to increase the voltage to 5V required by the relay and the water pump. An Arduino UNO microcontroller is used to control the relay and monitor the moisture sensor.
/*
* Automatic Plant Watering System
* This system uses a soil moisture sensor to monitor the moisture level of the soil.
* When the soil is dry, the Arduino UNO activates a relay to turn on a water pump,
* which irrigates the plant. The system includes a boost converter to step up the
* voltage from the batteries to power the components.
*/
// Pin definitions
const int soilMoisturePin = A0; // Analog pin connected to soil moisture sensor
const int relayPin = 7; // Digital pin connected to relay
const int pumpPin = 1; // Digital pin connected to water pump
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Set pin modes
pinMode(soilMoisturePin, INPUT);
pinMode(relayPin, OUTPUT);
pinMode(pumpPin, OUTPUT);
// Initialize relay and pump to off
digitalWrite(relayPin, LOW);
digitalWrite(pumpPin, LOW);
}
void loop() {
// Read the soil moisture level
int soilMoistureValue = analogRead(soilMoisturePin);
// Print the soil moisture value to the serial monitor
Serial.print("Soil Moisture: ");
Serial.println(soilMoistureValue);
// Check if the soil is dry
if (soilMoistureValue < 500) { // Threshold value for dry soil
// Turn on the relay and pump
digitalWrite(relayPin, HIGH);
digitalWrite(pumpPin, HIGH);
} else {
// Turn off the relay and pump
digitalWrite(relayPin, LOW);
digitalWrite(pumpPin, LOW);
}
// Wait for an hour before the next reading
delay(3600000); // 1 hour delay in milliseconds
}
This code is responsible for reading the moisture level from the soil moisture sensor and controlling the relay and water pump accordingly. The relay and pump are turned on when the soil is dry and turned off when the soil moisture is adequate.