Rahul Narang
Published

Implementation of ML in IoT (SMART IRRIGATION SYSTEM)

The Smart Irrigation System is an IoT based system which is capable of automating the irrigation process by analysing diff. parameters.

IntermediateShowcase (no instructions)4 hours11,423
Implementation of ML in IoT (SMART IRRIGATION SYSTEM)

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Arduino UNO
Arduino UNO
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
Temperature Sensor
Temperature Sensor
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Breadboard (generic)
Breadboard (generic)
×1
Rain Sensor
×1
Level Sensor
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Bolt IoT Android App
Bolt IoT Android App
Snappy Ubuntu Core
Snappy Ubuntu Core
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Code

Arduino Code

Java
Write code in Arduino IDE
#include <Servo.h> 

int servoPin = 3; 
Servo Servo1;
const int sensorMin = 0; // sensor minimum
const int sensorMax = 1024; // sensor maximum
boolean check;

void setup () {
 
  Serial.begin (9600);
  Servo1.attach(servoPin);
  pinMode(A2,INPUT);
  Serial.setTimeout(50);
  }
 
void loop() {
  // read the input on analog pin 0:
  int value = analogRead(A1);

  int sensorReading = analogRead(A3);
  int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
  
  int lightIntensity = analogRead(A2);
  
  if(lightIntensity< 100)
  {
  
  Serial.println("LOW LIGHT INTENSITY CANNOT OPEN VALVE");
  Servo1.write(180);
  Serial.println("Valve Closed");
  
  Serial.print(lightIntensity);
  delay(1000);
  
  }
  else{
    
  Serial.print(lightIntensity);
  delay(1000);
  if (value > 500) {
    //Serial.println("Very heavy Rain");
   //CUTOFF THE SERVO//
 Servo1.write(180); 
 //Serial.println("Valve Closed");
   delay(1000); 

    }
  else if ((value > 300) && (value <= 500)) {
    //Serial.println("AVERAGE Rain");
   switch (range) 
  {
    case 0: // Sensor getting completely wet
      Serial.println("RAINING");
      Servo1.write(180);
      Serial.println("Valve Closed");
      break;
    case 1: // Sensor getting partially wet
      Serial.println("RAIN WARNING");
      Servo1.write(90);
      Serial.println("Valve Partially open");
      break;

    case 2: // Sensor dry
      Serial.println("NOT RAINING");
      Servo1.write(0);
      Serial.println("Valve Fully open");
      break;
  }
  delay(1000);
 
    }
  else{
    Serial.println("Dry Weather");
  switch (range) 
  {
    case 0: // Sensor getting completely wet
      Serial.println("RAINING");
      Servo1.write(180);
      Serial.println("Valve Closed");
      break;
    case 1: // Sensor getting partially wet
      Serial.println("RAIN WARNING");
      Servo1.write(90);
      Serial.println("Valve Partially Open");
      
      break;

    case 2: // Sensor dry
      Serial.println("NOT RAINING");
      Servo1.write(0);
      Serial.println("Valve Fully Open");
      
      
      break;
  }
    
  delay(100);
  }
  }

}

Credits

Rahul Narang

Rahul Narang

3 projects • 40 followers

Comments