grove.grove_moisture_sensor
¶
- This is the code for
Grove - Moisture Sensor <https://www.seeedstudio.com/Grove-Moisture-Sensor-p-955.html>`_
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¶
GroveMoistureSensor
: Grove Moisture Sensor class
- 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)