Grove water sensor

Hi,

I’m using this type of sensor for my fyp demo project:
seeedstudio.com/wiki/index.p … ter_Sensor

I’m using it with PIC16F887 to give output to LEDs when it detects water, the concept is simple:

When sensor 1 detects water, led green blinking;
When sensor 2 detects water, led yellow blinking;
When sensor 3 detects water, led red blinking with buzzer switch on.

I have my hardware done, but stucked on PIC programming because i’m not familiar on water sensor coding,
Can anyone please help to give advice or check my coding?

TQVM

Hello! I am not very familiar with PIC16F887. But I can explain how the water sensor (One you are using) works. The sensor have the copper contacts (Those 11 vertical lines). When dipped in water, The copper contacts start to conduct with each other. The more it is exposed to the water, more it will conduct. In short: the SIG pin will go LOW when the sensor is exposed to the water otherwise it will remain HIGH. So, you can write the code accordingly.
Why don’t you use an Arduino instead? I can write you a code for it. :smiley: :nerd:

Hi! Thanks for your reply.

If that’s the case, can this sensor total immersed in water? Or only can use water drop to test it?

TQ

Hi,

We wrote a small example program for PIC

[code]void main()
{
PORTC=0; //initialize portc
TRISC=0x07; //configure portc (RC7 to RC3) as output and (RC2 to RC0 as input)
ANSELH=0; //configure an pin as digital I/O
ANSEL=0;

while(1){

//connect the grove water sensor sig to PIN RC0,RC1 and RC2( you need a 3 grove water sensor)
//connect the green led to PIN RC3,yellow led to PIN RC4,red lec to RC5 and Buzzer to RC6
if((RC0==1)&&(RC1==1)&&(RC2==1)){
//All Leds and Buuzzer off states
PORTC=0x00;

}
if((RC0==0)&&(RC1==1)&&(RC2==1))
{
//This states LED green blinking
PORTC=0x04;
delay(200);
PORTC=0x00;
delay(200);
}
if((RC0==0)&&(RC1==0)&&(RC2==1))
{

//This states LED yellow blinking
PORTC=0x08;
delay(200);
PORTC=0x00;
delay(200);
}

if((RC0==0)&&(RC1==0)&&(RC2==0))
{

//This states LED red blinking and buzzer on
PORTC=0x60;
delay(200);
PORTC=0x40;
delay(200);
}

}[/code]

Let us know if it helps you.

Thanks and Regards