Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Boaz Lawnce
Published

Arduino Based Wireless Intelligent Water Irrigation System

This system monitors the weather and makes decisions about when to water.

IntermediateShowcase (no instructions)4,234
Arduino Based Wireless Intelligent Water Irrigation System

Things used in this project

Hardware components

Arduino Mega 2560
Arduino Mega 2560
×1
Rain Drop sensor
×1
Soil Moisture Sensor
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Solenoid Valve
×1
12V power supply (generic)
×1
4-bit Wireless Relay Module
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Code

C/C++
const int SMS1P = 48;
const int SMS1N = 49;
const int SMS2P = 46;
const int SMS2N = 47;
const int RDSP = 50;
const int RDSN = 51;
const int SMS1O = A11;
const int SMS2O = A12;
const int RDSO = A13;
const int Rline = 24;
const int Yline = 26;
const int Bline = 28;
const int Solenoid = 30;
int RDS = 0;
int SMS1 = 0;
int SMS2 = 0;
void rain_drop_sensor_ON();
void Soil_Moisture_Sensor1_ON();
void Soil_Moisture_Sensor2_ON();
void rain_drop_sensor_OFF();
void Soil_Moisture_Sensor1_OFF();
void Soil_Moisture_Sensor2_OFF();
void Solenoid_ON();
void Solenoid_OFF();
void Three_Phase_Motor_ON();
void Three_Phase_Motor_OFF();
void read_Sensors_value();
void setup() {
  pinMode(SMS1P, OUTPUT);
  pinMode(SMS2P, OUTPUT);
  pinMode(SMS1N, OUTPUT);
  pinMode(SMS2N, OUTPUT);
  pinMode(RDSP, OUTPUT);
  pinMode(RDSN, OUTPUT);
  pinMode(SMS1O, INPUT);
  pinMode(SMS2O, INPUT);
  pinMode(RDSO, INPUT);
  pinMode(Rline, OUTPUT);
  pinMode(Yline, OUTPUT);
  pinMode(Bline, OUTPUT);
  pinMode(Solenoid, OUTPUT);
  Three_Phase_Motor_OFF();
  Solenoid_OFF();
  Serial.begin(9600);
}
void loop() {
  rain_drop_sensor_ON();
  Soil_Moisture_Sensor1_ON();
  Soil_Moisture_Sensor2_ON();
  read_Sensors_value();
  RDS = analogRead(RDSO);
  SMS1 = analogRead(SMS1O);
  SMS2 = analogRead(SMS2O);
  delay(10);
  if (SMS1 < 100 && SMS2 < 100 && RDS > 200)
  {
    Three_Phase_Motor_ON();
    Solenoid_ON();
  }
  else if (SMS1 < 100 && SMS2 < 100 && RDS < 200)
  {
    Three_Phase_Motor_OFF();
    Solenoid_OFF();
  }
  else if (SMS1 < 100 && SMS2 > 100 && RDS > 200)
  {
    Three_Phase_Motor_ON();
    Solenoid_OFF();
  }
  else if (SMS1 < 100 && SMS2 > 100 && RDS < 200)
  {
    Three_Phase_Motor_ON();
    Solenoid_OFF();
  }
  else if (SMS1 > 100 && SMS2 < 100 && RDS > 200)
  {
    Three_Phase_Motor_OFF();
    Solenoid_ON();
  }
  else if (SMS1 > 100 && SMS2 < 100 && RDS < 200)
  {
    Three_Phase_Motor_OFF();
    Solenoid_OFF();
  }
  else if (SMS1 > 100 && SMS2 > 100 && RDS > 200)
  {
    Three_Phase_Motor_OFF();
    Solenoid_OFF();
  }
  else if (SMS1 > 100 && SMS2 > 100 && RDS < 200)
  {
    Three_Phase_Motor_OFF();
    Solenoid_OFF();
  }
  else
  {
    Three_Phase_Motor_OFF();
    Solenoid_OFF();
  }
}
void rain_drop_sensor_ON()
{
  digitalWrite(RDSP, HIGH);
  digitalWrite(RDSN, LOW);
}
void Soil_Moisture_Sensor1_ON()
{
  digitalWrite(SMS1P, HIGH);
  digitalWrite(SMS1N, LOW);
}
void Soil_Moisture_Sensor2_ON()
{
  digitalWrite(SMS2P, HIGH);
  digitalWrite(SMS2N, LOW);
}
void rain_drop_sensor_OFF()
{
  digitalWrite(RDSP, LOW);
  digitalWrite(RDSN, LOW);
}
void Soil_Moisture_Sensor1_OFF()
{
  digitalWrite(SMS1P, LOW);
  digitalWrite(SMS1N, LOW);
}
void Soil_Moisture_Sensor2_OFF()
{
  digitalWrite(SMS2P, LOW);
  digitalWrite(SMS2N, LOW);
}
void Solenoid_ON()
{
  digitalWrite(Solenoid, LOW);
}
void Solenoid_OFF()
{
  digitalWrite(Solenoid, HIGH);
}
void Three_Phase_Motor_ON()
{
  digitalWrite(Rline, LOW);
  digitalWrite(Yline, LOW);
  digitalWrite(Bline, LOW);
}
void Three_Phase_Motor_OFF()
{
  digitalWrite(Rline, HIGH);
  digitalWrite(Yline, HIGH);
  digitalWrite(Bline, HIGH);
}
void read_Sensors_value()
{
  SMS1 = analogRead(SMS1O);
  SMS2 = analogRead(SMS2O);
  RDS = analogRead(RDSO);
  Serial.println(SMS2);
  Serial.println(SMS1);
  Serial.println(RDS);
  delay(2000);
}

Credits

Boaz Lawnce

Boaz Lawnce

11 projects • 38 followers
Electronics Engineer, Founder, Hobbyist....

Comments