Sagnik Bhattacharya
Published © Apache-2.0

Project Aquatix 6 IoT Water Harvesting System

saving water smartly.

IntermediateShowcase (no instructions)8 hours6,334
Project Aquatix 6 IoT Water Harvesting System

Things used in this project

Hardware components

Light Dependent Resistor
×1
Breadboard (generic)
Breadboard (generic)
×1
Ultrasonic Sensor
×1
solenoid valve
×1
4-channel relay
×1
Ultra96-V1
Avnet Ultra96-V1
×1

Software apps and online services

Blynk
Blynk

Hand tools and fabrication machines

Jumper WIre

Story

Read more

Schematics

Breadboard Design

PNG file of circuit diagram

Fritzing file

raw data file

Code

logic.ino

Arduino
Code to run the main functions
#include <LWiFi.h>
#include <LWiFiClient.h>
#include <BlynkSimpleLinkItONE.h>


#define trig 6
#define echo 7
#define sol1 10
#define sol2 11
#define sol3 12

#define rgb0 0
#define rgb1 1
#define rgb2 2
#define rgb3 3
#define rgbinput 9



// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "bfd19e4c2a094a658cfce8e75c08a494";
int i=0;   
// Your WiFi credentials.
// Choose wifi_sec from LWIFI_OPEN, LWIFI_WPA, or LWIFI_WEP
char ssid[] = "AndroidAP411F";
char pass[] = "fuuk5340";
int wifi_sec = LWIFI_WPA;


void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass, wifi_sec);
   pinMode(rgb1,OUTPUT);
  pinMode(rgb2,OUTPUT);
  pinMode(rgb3,OUTPUT);
  pinMode(rgbinput,INPUT);
  pinMode(echo,INPUT);
  pinMode(trig,OUTPUT);
  pinMode(sol1,OUTPUT);
  pinMode(sol2,OUTPUT);
  pinMode(sol3,OUTPUT);

  digitalWrite(rgb0,HIGH);
  digitalWrite(rgb1,LOW);
  digitalWrite(sol1, LOW);
  digitalWrite(sol2, LOW);
  digitalWrite(sol3, LOW);


}

void loop()
{
  Blynk.run();
}

int tank_height()
{
  float tank_height=20.0;
long duration,distance;
    digitalWrite(trig,LOW);
    delayMicroseconds(2);
    digitalWrite(trig,HIGH);
    delayMicroseconds(10);
    digitalWrite(trig,LOW);
    duration=pulseIn(echo,HIGH);
    distance= (duration/29)/2;
    if(distance>tank_height)
    distance=tank_height;
  int percent=(tank_height-distance)*5;
  return percent;

  }

BLYNK_READ(0){
     digitalWrite(rgb2,LOW);
  digitalWrite(rgb3,LOW);
  
  int red=pulseIn(rgbinput,LOW);
  Blynk.virtualWrite(5,red);
  if (red>=100)
Blynk.virtualWrite(7,"acidic");
else
Blynk.virtualWrite(7,"non acidic");
//int clar=analogRead(A0);

  
Blynk.virtualWrite(0,analogRead(A0));
Blynk.virtualWrite(1,analogRead(A0));
Blynk.virtualWrite(3,tank_height());
      if(analogRead(A0)<=600)
      {
        Blynk.virtualWrite(2,"Fair");
      //  Blynk.virtualWrite(4,"xxx");
        }
      
      else if(analogRead(A0)<=500)
    {
      Blynk.virtualWrite(2,"Good");
     // Blynk.virtualWrite(4,"xxx");
             
        }
    
      else 
    {
      Blynk.virtualWrite(2,"Bad");
      //Blynk.virtualWrite(4,"xxx");
   
        
        }
    if (tank_height()>=80)
  {
    
      Blynk.tweet("I'm doing my bit to save water. I have just saved 20 litres.");
    if(analogRead(A0)<=160)
    {Blynk.email("saggieb12@gmail.com", "You tank is full", "Suggested use: Wash fruits and vegetabes");
      digitalWrite(sol1, HIGH);
    Blynk.virtualWrite(6,"1");
    delay(30000);
       digitalWrite(sol1, LOW);
       }
    else if(analogRead(A0)<=220)
    {Blynk.email("saggieb12@gmail.com", "You tank is full", "Suggested use: Water plants");
      digitalWrite(sol2, HIGH);
    Blynk.virtualWrite(6,"2");
    delay(30000);
    
       digitalWrite(sol2, LOW);
       }
    else
    {Blynk.email("saggieb12@gmail.com", "You tank is full", "Suggested use: Clean your courtyard");
      digitalWrite(sol3, HIGH);
    Blynk.virtualWrite(6,"3");}
       delay(30000);
       
       digitalWrite(sol3, LOW);
    }
        
    

    delay(1000);
}

Servo.ino

Arduino
Code to run the servo motor depending on input from raindrop sensor
/*
  Copyright (c) 2014 MediaTek Inc.  All right reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License..

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
   See the GNU Lesser General Public License for more details.
*/


#include <Servo.h> 


int i;
Servo myservo;
Servo myservo2;
void setup() {
    Serial.begin(115200);
    myservo.attach(9);
    myservo.write(205);
    myservo2.attach(5);
    myservo2.write(25);
       
}

void loop() {
  int raindrop=analogRead(A0);
Serial.println();
if(raindrop<=355)
{
  myservo.write(60);
  myservo2.write(170);
  }
  else
 {myservo.write(205);
  myservo2.write(205);
  }
    delay(1000);
}

Credits

Sagnik Bhattacharya

Sagnik Bhattacharya

1 project • 13 followers
I'm a geek kid who loves to develop games and apps. Want to open a startup and make my own operating system. Star Wars and GoT are <3

Comments