grove.grove_water_sensor
¶
- This is the code for
Examples
import time
from grove.grove_water_sensor import GroveWaterSensor
# connect to alalog pin 2(slot A2)
PIN = 2
sensor = GroveWaterSensor(PIN)
print('Detecting ...')
while True:
value = sensor.value
if sensor.value > 800:
print("{}, Detected Water.".format(value))
else:
print("{}, Dry.".format(value))
time.sleep(.1)
Classes¶
GroveWaterSensor
: Grove Water Sensor class
- class grove.grove_water_sensor.GroveWaterSensor(channel)[source]¶
Grove Water Sensor class
- Parameters:
pin (int) – number of analog pin/channel the sensor connected.
Inheritance
digraph inheritancec6bcc3334a { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "GroveWaterSensor" [URL="#grove.grove_water_sensor.GroveWaterSensor",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Grove Water Sensor class"]; }- property value¶
Get the water strength value
- Returns:
ratio, 0(0.0%) - 1000(100.0%)
- Return type:
(int)