Datasheet

8
{
pinMode(WATER_SENSOR, INPUT);
pinMode(BUZZER, OUTPUT);
}
/************************************************************************/
/*Function: When the sensor is exposed to the water, the buzzer sounds */
/* for 2 seconds. */
void soundAlarm()
{
for(uint8_t i = 0;i < 20;i ++)
{
digitalWrite(BUZZER, HIGH);
delay(50);
digitalWrite(BUZZER, LOW);
delay(50);
}
}
/************************************************************************/
/*Function: Determine whether the sensor is exposed to the water */
/*Parameter:-void */
/*Return: -boolean,if it is exposed to the water,it will return true. */
boolean isExposedToWater()
{
if(digitalRead(WATER_SENSOR) == LOW)
return true;
else return false;
}
Upload the code, Please click here if you do not know how to upload.
The buzzer sounds when the sensor is damp or completely immersed in water. Have a try!
6.2 With Raspberry Pi
1. You should have got a raspberry pi and a grovepi or grovepi+.
2. You should have completed configuring the development enviroment,
otherwise follow here.
3. Connection
Plug the sensor to grovepi socket D2 by using a grove cable.