Devices & Components
Arduino Nano
Relay Module (Generic)
capacitive soil moisture sensor
5V DC Water Pump
Hardware & Tools
Soldering iron (generic)
Project description
Code
Arduino Plant Waterer
c_cpp
1// if the soil is dryer than this number, then start watering 2const int dry = 270; 3 4const int pumpPin = 12; 5const int soilSensor = A4; 6 7void setup() { 8 pinMode(pumpPin, OUTPUT); 9 pinMode(soilSensor, INPUT); 10 Serial.begin(9600); 11 digitalWrite(pumpPin, HIGH); 12 delay(5000); 13} 14 15void loop() { 16 // read current moisture 17 int moisture = analogRead(soilSensor); 18 Serial.println(moisture); 19 delay(5000); 20 21 if (moisture >= dry) { 22 // the soil is too dry, water! 23 Serial.println("Watering starts now..moisture is " + String(moisture)); 24 digitalWrite(pumpPin, LOW); 25 26 // keep watering for 5 sec 27 delay(5000); 28 29 // turn off water 30 digitalWrite(pumpPin, HIGH); 31 Serial.println("Done watering."); 32 } else { 33 Serial.println("Moisture is adequate. No watering needed " + String(moisture)); 34 } 35}
Arduino Plant Waterer
c_cpp
1// if the soil is dryer than this number, then start watering 2const int dry = 270; 3 4const int pumpPin = 12; 5const int soilSensor = A4; 6 7void setup() { 8 pinMode(pumpPin, OUTPUT); 9 pinMode(soilSensor, INPUT); 10 Serial.begin(9600); 11 digitalWrite(pumpPin, HIGH); 12 delay(5000); 13} 14 15void loop() { 16 // read current moisture 17 int moisture = analogRead(soilSensor); 18 Serial.println(moisture); 19 delay(5000); 20 21 if (moisture >= dry) { 22 // the soil is too dry, water! 23 Serial.println("Watering starts now..moisture is " + String(moisture)); 24 digitalWrite(pumpPin, LOW); 25 26 // keep watering for 5 sec 27 delay(5000); 28 29 // turn off water 30 digitalWrite(pumpPin, HIGH); 31 Serial.println("Done watering."); 32 } else { 33 Serial.println("Moisture is adequate. No watering needed " + String(moisture)); 34 } 35}
Downloadable files
automatic_plant_waterer_v2_av2X0UOI9J.png
automatic_plant_waterer_v2_av2X0UOI9J.png

Comments
Only logged in users can leave comments