Measuring human waste in the wells with ultrasonic sensor

I was thinking not to write this post but then I thought it might be very useful for those people who live in rural areas and use wells to dump their wastes. I've seen people in village that they rely on visual indication of their wastes and that's pretty gross. Well, if they find out this system then I'm sure they will be over the moon.

OK, let's see the diagram and then the sketch.


//define the pins for ultrasonic sensor and leds here
int trigPin = 2;
int echoPin = 3;
int led1 = 4;
int led2 = 5;
int led3 = 6;


void setup() {
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);

}


//send a pulse and calculate how long it took to travel
void loop() {
   int duration, distance;
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;

if (distance >=1 && distance <=10){
   Serial.print(distance);
    Serial.println(" cm");
    digitalWrite(led1, HIGH);
    digitalWrite(led2, LOW);
    digitalWrite(led3, LOW);

  }

  else if (distance >=11 && distance <=20){
   Serial.print(distance);
    Serial.println(" cm");
    digitalWrite(led2, HIGH);
    digitalWrite(led1, LOW);
    digitalWrite(led3, LOW);

  }

  else if (distance >=21 && distance <=30){
   Serial.print(distance);
    Serial.println(" cm");
    digitalWrite(led3, HIGH);
    digitalWrite(led1, LOW);
    digitalWrite(led2, LOW);

  }
 
else {
    Serial.print(distance);
    Serial.println(" cm");
    digitalWrite(led1, LOW);
    digitalWrite(led2, LOW);
    digitalWrite(led3, LOW);
    delay(60000);
  }
}

Places to change:
You might need to change those green highlighted places after measuring the actual place where you going to insert the ultrasonic sensor.

* if (distance >=1 && distance <=10){
In this example we can see that if the sensor gets reading between 1 to 10 then it will turn on the led1 which is red led, and that will indicate that the well is full or nearly full.

* delay(60000);
This means that the sensor will take the readings after every minute, but if you want to get the readings even slower, then set the numbers higher.

That's all for this post and I think you can use this system in many places not just in human waste wells.

No comments:

Post a Comment



Newly posted:
Reason why rich getting richer and poor getting poorer