Grove - Moisture Sensor

This Moisture Senor can be used for detecting the moisture of soil or judge if there is water around the sensor, let the plant in your garden able to reach out for human's help when they are thirsty. This sensor is very easy to use, you can just simply insert in into the soil and read the data. With this sensor, you can make a small project that can let the plant send a message to you like " I am thirsty now, please feed me some water."


Product Version Changes Released Date
Grove - Moisture Sensor V1.4 Initial June 2014


  • Soil moisture sensor based on soil resistivity meansurement
  • Easy to use
  • 2.0 cm X 6.0 cm grove module


More details about Grove modules please refer to Grove System


Item Condition Min Typical Max Unit
Voltage - 3.3 - 5 V
Current - 0 - 35 mA
Output Value Sensor in dry soil
Sensor in humid soil
Sensor in water
- 300

Platforms Supported

Arduino Raspberry Pi BeagleBone Wio LinkIt ONE


The platforms mentioned above as supported is/are an indication of the module's hardware or theoritical compatibility. We only provide software library or code examples for Arduino platform in most cases. It is not possible to provide software library / demo code for all possible MCU platforms. Hence, users have to write their own software library.

Application Ideas

  • Botanical Gardening
  • Moisture Sensoring
  • Consistency Measurement

Getting Started


If this is the first time you work with Arduino, we firmly recommend you to see Getting Started with Arduino before the start.

Play With Arduino


  • Step 1. Prepare the below stuffs:
Seeeduino V4.2 Base Shield Grove-Moisture Sensor
enter image description here enter image description here enter image description here
Get One Now Get One Now Get One Now
  • Step 2. Connect Grove-Moisture Sensor to port A0 of Grove-Base Shield.
  • Step 3. Plug Grove - Base Shield into Seeeduino.
  • Step 4. Connect Seeeduino to PC via a USB cable.


If we don't have Grove Base Shield, We also can directly connect Grove-Moisture Sensor to Seeeduino as below.

Seeeduino Grove-Moisture Sensor
5V Red
GND Black
Not Conencted White
A0 Yellow


  • Step 1. Copy the code into Arduino IDE and upload. If you do not know how to upload the code, please check how to upload code.
int sensorPin = A0;
int sensorValue = 0;

void setup() {
void loop() {
    // read the value from the sensor:
    sensorValue = analogRead(sensorPin);
    Serial.print("Moisture = " );
  • Step 2. We will see the moisture display on terminal as below.
Moisture = 0
Moisture = 31
Moisture = 48
Moisture = 139
Moisture = 155
Moisture = 124
Moisture = 236
Moisture = 218
Moisture = 215
Moisture = 221

Play With Raspberry Pi


  • Step 1. Prepare the below stuffs:
Raspberry pi GrovePi_Plus Grove-Moisture Sensor
enter image description here enter image description here enter image description here
Get One Now Get One Now Get One Now
  • Step 2. Plug the GrovePi_Plus into Raspberry.
  • Step 3. Connect Grove-Moisture Sensor to A0 port of GrovePi_Plus.
  • Step 4. Connect the Raspberry to PC through USB cable.


  • Step 1. Follow Setting Software to configure the development environment.
  • Step 2. Git clone the Github repository.
cd ~
git clone https://github.com/DexterInd/GrovePi.git
  • Step 3. Excute below commands to use the Grove-Moisture Sensor to meansure the moisture.
cd ~/GrovePi/Software/Python
python grove_moisture_sensor.py

Here is the grove_moisture_sensor.py code.

#   Here are suggested sensor values:
#       Min  Typ  Max  Condition
#       0    0    0    sensor in open air
#       0    20   300  sensor in dry soil
#       300  580  700  sensor in humid soil
#       700  940  950  sensor in water

import time
import grovepi

# Connect the Grove Moisture Sensor to analog port A0
sensor = 0

while True:

    except KeyboardInterrupt:
    except IOError:
        print ("Error")
  • Step 4. We will see the moisture display on terminal as below.
pi@raspberrypi:~/GrovePi/Software/Python $ python grove_moisture_sensor.py

Play With TI LaunchPad


The following sketch demonstrates a simple application of sensing the moisture in soil.With this, you can know whether your plant needs water or not by observing the result from the output of the sensor


  The following sketch demonstrates a simple application of sensing
  the moisture of the soil. You can know whether a plant needs water
  or not by observing the results that the sensor outputs.
  The circuit:
    * Moisture-Sensor attached to pin 24 (J6 plug on Grove Base BoosterPack)
    * one side pin (either one) to ground
    * the other side pin to +VCC
    * LED anode (long leg) attached to RED_LED
    * LED cathode (short leg) attached to ground
  - NOTE:
    This example code is in the public domain.
#include "TM1637.h"
/* Macro Define */
#define CLK 39              /* 4-digital display clock pin */
#define DIO 38              /* 4-digiral display data pin */
#define BLINK_LED RED_LED   /* blink led */
#define MOISTURE_PIN 24     /* pin of moisture sensor */
#define THRESHOLD_VALUE 300 /* threshold for watering the flowers */
#define ON HIGH             /* led on */
#define OFF LOW             /* led off */
#define _handle_led(x) digitalWrite(BLINK_LED, x) /* handle led */

/* Global Varibles */
TM1637 tm1637(CLK, DIO);    /* 4-digital display object */
int analog_value = 0;       /* varible to store the value coming from rotary angle
sensor */
int8_t bits[4] = {0};       /* array to store the single bits of the value */
/* the setup() method runs once, when the sketch starts */
void setup() {
/* Initialize 4-digital display */
/* declare the red_led pin as an OUTPUT */
    pinMode(BLINK_LED, OUTPUT);
/* the loop() method runs over and over again */
void loop() {
    analog_value = analogRead(MOISTURE_PIN); /* read the value from the sensor */
/* if the value is smaller than threshold, turn on led */
    if(analog_value < THRESHOLD_VALUE) {
    } else {
    memset(bits, 0, 4); /* reset array when we use it */
    for(int i = 3; i >= 0; i--) {
/* get single bits of the analog value */
        bits[i] = analog_value % 10;
        analog_value = analog_value / 10;
        tm1637.display(i, bits[i]); /* display by 4-digital display */


Tech Support

Please do not hesitate to contact techsupport@seeed.cc if you have any technical issue. Or submit the issue into our forum.