grove.grove_moisture_sensor

This is the code for

Examples

import time
from grove.grove_moisture_sensor import GroveMoistureSensor

# connect to alalog pin 2(slot A2)
PIN = 2

sensor = GroveMoistureSensor(PIN)

print('Detecting moisture...')
while True:
    m = sensor.moisture
    if 0 <= m and m < 300:
        result = 'Dry'
    elif 300 <= m and m < 600:
        result = 'Moist'
    else:
        result = 'Wet'
    print('Moisture value: {0}, {1}'.format(m, result))
    time.sleep(1)

Classes

class grove.grove_moisture_sensor.GroveMoistureSensor(channel)[source]

Grove Moisture Sensor class

Parameters:

pin (int) – number of analog pin/channel the sensor connected.

Inheritance

digraph inheritanceec69e7af1f { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "GroveMoistureSensor" [URL="#grove.grove_moisture_sensor.GroveMoistureSensor",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 Moisture Sensor class"]; }
property moisture

Get the moisture strength value/voltage

Returns:

voltage, in mV

Return type:

(int)