Devices & Components
Arduino Uno Rev3
Jumper wires (generic)
9V battery (generic)
Relay (generic)
SparkFun Soil Moisture Sensor (with Screw Terminals)
Software & Tools
Arduino IDE
Project description
Code
Smart Irrigation Code
h
1//Welcome 2//Electronics University 3 4int relayPin = 8; 5int sensor_pin = A0; // Soil Sensor input at Analog PIN A0 6int output_value ; 7void setup() // put your setup code here, to run once: 8{ 9 Serial.begin(9600); 10 pinMode(relayPin, OUTPUT); 11 pinMode(sensor_pin, INPUT); 12 Serial.println("Reading From the Sensor ..."); 13 delay(2000); 14} 15 16void loop() 17{ 18 output_value= analogRead(sensor_pin); 19 output_value = map(output_value,550,10,0,100); 20 Serial.print("Mositure : "); 21 Serial.print(output_value); 22 Serial.println("%"); 23 if(output_value<20){ 24 digitalWrite(relayPin, LOW); 25 } 26 else 27 { 28 digitalWrite(relayPin, HIGH); 29 } 30 delay(1000); 31} 32
Smart Irrigation Code
h
1//Welcome 2//Electronics University 3 4int relayPin = 8; 5int sensor_pin = A0; // Soil Sensor input at Analog PIN A0 6int output_value ; 7void setup() // put your setup code here, to run once: 8{ 9 Serial.begin(9600); 10 pinMode(relayPin, OUTPUT); 11 pinMode(sensor_pin, INPUT); 12 Serial.println("Reading From the Sensor ..."); 13 delay(2000); 14} 15 16void loop() 17{ 18 output_value= analogRead(sensor_pin); 19 output_value = map(output_value,550,10,0,100); 20 Serial.print("Mositure : "); 21 Serial.print(output_value); 22 Serial.println("%"); 23 if(output_value<20){ 24 digitalWrite(relayPin, LOW); 25 } 26 else 27 { 28 digitalWrite(relayPin, HIGH); 29 } 30 delay(1000); 31} 32
Downloadable files
Look
Look

Comments
Only logged in users can leave comments