Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
haris511
Published © GPL3+

How to make your own DIY water sensor!

Make your own water sensor without needing to buy one online with components such as a transistor, Led, buzzer, and resistors.

AdvancedFull instructions provided2,080
How to make your own DIY water sensor!

Things used in this project

Hardware components

5 mm LED: Red
5 mm LED: Red
Any red led will do.
×1
Resistor 220 ohm
Resistor 220 ohm
You may be able to use other types like 360 or something like that but if you are out of options you could use a 10k potentiometer and set the resistance high.
×2
General Purpose Transistor NPN
General Purpose Transistor NPN
Any regular NPN transistor will do.
×1
Jumper wires (generic)
Jumper wires (generic)
You will need LOTS and LOTS of them.
×10
Arduino UNO
Arduino UNO
Any Arduino will do but I prefer the Uno.
×1
Buzzer
Buzzer
Any buzzer will do.
×1
Resistor 10k ohm
Resistor 10k ohm
Any 10k resistor will do.
×2
Cable, Serial Converter Programming
Cable, Serial Converter Programming
A serial cable for your Arduino.
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Water Sensor

It won't work but you need it for the connections

Code

Water Sensor

Arduino
You upload it to your Arduino and then touch the two prongs. Make sure to check your serial monitor.
const int Buzzer = 5; //Buzzer pin
const int led = 6; //Led pin
const int watersensor = 7; //Water Sensor pin
int watersensorstate = 0; //State of the water sensor
// setup (intializes everthings)
void setup() {
pinMode(led, OUTPUT); //set the Led as an output
pinMode(Buzzer, OUTPUT); //set the buzzer as an output as well
pinMode(watersensor, INPUT); //set the water sensor as an input
Serial.begin(9600);//Start the serial connection
}
//loop (Does the actual program)
void loop() {
 watersensorstate = digitalRead(watersensor); 
 //Set the water sensor state as either high depending on the water sensor
 //if it senses water it will turn on the led, pulse the buzzer, and say "Water Detected"
 if(watersensorstate==1){
  digitalWrite(led, HIGH);
  digitalWrite(Buzzer, HIGH);
  delay(150);
  digitalWrite(Buzzer, LOW);
  delay(150);
  Serial.println("Water Detected");
  }
  //otherwise it will do nothing and say "No water Detected"
  else{
    digitalWrite(led, LOW);
    digitalWrite(Buzzer, LOW);
    Serial.println("No water Detected");
    }
}

Credits

haris511
3 projects • 1 follower

Comments