Jasmeet Singh
Published © GPL3+

Poseidon: The Water Saver

Poseidon is a cheap wireless water level controller for overhead tanks made using Arduino UNO and HC-12 wireless communication module.

IntermediateShowcase (no instructions)6,492
Poseidon: The Water Saver

Things used in this project

Story

Read more

Schematics

Sender Schematic

Receiver Schematics

Code

Sender Code

Arduino
This is the code for the arduino Uno board placed at the sender end near the tank. It uses an ultrasonic sensor to measure the level of water and then sends the message to the receiver end using the HC-12 module when the level reaches a certain point.
#include <SoftwareSerial.h>
SoftwareSerial myserial(2, 3); //RX and TX of HC-12 module
int trigPin = 5;
int echoPin = 6;
int tank_height; //place the height of the tank here 
int tankTop_level; //distance of the water in tank from the ultrasonic sensor after which you want to turn of the motor 
long duration;
int distance;
void setup() {
  Serial.begin(9600);
  myserial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

}

void loop() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration*0.034/2;
  Serial.println("distance:");
  Serial.print(distance);
  delay(1000);
  if(distance == tank_height){ // send '3' to receiver end when the tank gets empty
    myserial.println("3");
    Serial.println("message sent");
  }
  if(distance == tankTop_level){ // send '1' when the water reaches topmost level in tank
    myserial.println("1");
    Serial.println("message sent");
  }
  if(Serial.available()>0){
    String input=Serial.readString();
    myserial.println(input);
  }
if(myserial.available()>1){
  String input=myserial.readString();
  Serial.println(input);
  }
delay(20);
}

Receiver Code

Arduino
This is the code for the arduino UNO board at the receiver end near the water pump. It receives the data from the sender end and then accordingly controls the relay for switching on/off the water pump. It then gives missed call to the entered number.
#include <SoftwareSerial.h>
SoftwareSerial myserial(2, 3); //Rx and Tx for HC-12 module
SoftwareSerial myserial2(4, 5); //Rx and Tx for GSM Module 
int relayPin = 6, input;
int flag=0;
void setup() {
  Serial.begin(9600);
  pinMode(relayPin, OUTPUT);
  myserial.begin(9600);
}

void loop() {
 if(myserial.available()>1){
  input=myserial.read();
  delay(20);
}
  if(input=='3'){
    digitalWrite(relayPin, HIGH);
    while (input=='3' && flag==0){
    myserial.end();
    myserial2.begin(9600);
    myserial2.println("ATDXXXXXXXXXX;"); //enter the phone number in place of "XX..."
    Serial.println("callining1");
    delay(10000);
    myserial2.println("ATH");
    myserial2.end();
    flag=1;
    myserial.begin(9600);
    }
    }
  if(input=='1'){
    digitalWrite(relayPin, LOW);
    while(input=='1' && flag==1){
    myserial.end();
    myserial2.begin(9600);
    myserial2.println("ATDXXXXXXXXXX;"); //enter the phone number in place of "XX..."
    Serial.println("callining2");
    delay(10000);
    myserial2.println("ATH");  
    myserial2.end();
    flag=0;  
    myserial.begin(9600);
    }
  }
delay(20);
}

Credits

Jasmeet Singh

Jasmeet Singh

14 projects • 20 followers
Robotics | ROS | PCB Designing | 3D Printing

Comments