Stufin
Home Quick Cart Profile

M5 Stack Earth Moisture Unit

Buy Now on Stufin

Measurement Range

0-100% soil moisture level

Resolution

3%

Accuracy

5%

Operating Temperature

-20C to 85C

Storage Temperature

-40C to 125C

Power Supply

3.3V to 5V

Current Consumption

<1mA (standby), 10mA (active)

Wireless Connectivity

Wi-Fi 802.11 b/g/n, Bluetooth 4.2

Dimension

50x25x15mm

Weight

20g

Applications

  • Agricultural Monitoring: Soil moisture monitoring for precision farming and irrigation systems.
  • Gardening and Horticulture: Monitoring soil moisture levels for optimal plant growth and water management.
  • Environmental Monitoring: Soil moisture monitoring for climate and weather stations.
  • Research and Development: Soil moisture analysis for scientific research and experimentation.
The M5 Stack Earth Moisture Unit is suitable for various applications, including

By providing accurate and reliable soil moisture data, the M5 Stack Earth Moisture Unit is an essential component for IoT projects focused on agriculture, gardening, and environmental monitoring.

Pin Configuration

  • M5 Stack Earth Moisture Unit Documentation
  • Overview
  • The M5 Stack Earth Moisture Unit is a compact and easy-to-use IoT component designed to measure the moisture level in soil. This module is part of the M5 Stack ecosystem, a popular platform for rapid prototyping and development of IoT projects. The Earth Moisture Unit features a simple and intuitive interface, making it an ideal choice for a wide range of applications, from agriculture to environmental monitoring.
  • Pinout Description
  • The M5 Stack Earth Moisture Unit has a total of 6 pins, each with a specific function. The pinout is described below:
  • Pin 1: VCC (Power Supply)
  • Function: Power supply pin
  • Description: Connect to a power source (3.3V or 5V) to power the module
  • Recommended voltage: 3.3V or 5V
  • Maximum current: 10mA
  • Pin 2: GND (Ground)
  • Function: Ground pin
  • Description: Connect to the ground of the power source or the microcontroller
  • Recommended voltage: 0V
  • Pin 3: OUT (Analog Output)
  • Function: Analog output pin
  • Description: Provides an analog signal indicating the soil moisture level (0-100%)
  • Output range: 0-3.3V (or 0-5V, depending on the power supply)
  • Recommended connection: Connect to an analog-to-digital converter (ADC) or a microcontroller's analog input pin
  • Pin 4: NC (Not Connected)
  • Function: Not connected internally
  • Description: This pin is not connected to any internal component and should be left unconnected
  • Pin 5: VREF (Reference Voltage)
  • Function: Reference voltage pin
  • Description: Provides a stable reference voltage (typically 1.1V or 2.5V) for the analog output
  • Output range: 1.1V or 2.5V (depending on the module's internal configuration)
  • Recommended connection: Connect to the reference voltage input of an ADC or a microcontroller's analog reference pin
  • Pin 6: DOUT (Digital Output)
  • Function: Digital output pin
  • Description: Provides a digital signal indicating the soil moisture level (high or low)
  • Output logic: High ( Soil moisture level above the set threshold) / Low (Soil moisture level below the set threshold)
  • Recommended connection: Connect to a microcontroller's digital input pin or a logic-level compatible device
  • Connection Structure
  • When connecting the M5 Stack Earth Moisture Unit to a microcontroller or a development board, follow the recommended connection structure:
  • ```markdown
  • M5 Stack Earth Moisture Unit
  • +---------------+
  • | VCC (Pin 1) |
  • | (3.3V or 5V) |
  • +---------------+
  • |
  • |
  • v
  • +---------------+
  • | GND (Pin 2) |
  • | (0V) |
  • +---------------+
  • |
  • |
  • v
  • +---------------+
  • | OUT (Pin 3) |
  • | (Analog Output)|
  • +---------------+
  • |
  • |
  • v
  • +---------------+
  • | NC (Pin 4) |
  • | (Not Connected)|
  • +---------------+
  • |
  • |
  • v
  • +---------------+
  • | VREF (Pin 5) |
  • | (Reference Voltage)|
  • +---------------+
  • |
  • |
  • v
  • +---------------+
  • | DOUT (Pin 6) |
  • | (Digital Output) |
  • +---------------+
  • ```
  • Note: Ensure proper electrical connections and avoid short-circuiting pins to prevent damage to the module or the microcontroller.
  • This documentation provides a detailed description of the M5 Stack Earth Moisture Unit's pins and their recommended connections. By following this guide, you can effectively integrate the module into your IoT project and start measuring soil moisture levels with ease.

Code Examples

M5 Stack Earth Moisture Unit Documentation
Overview
The M5 Stack Earth Moisture Unit is a sensor module designed to measure the moisture level in soil. It is a popular IoT component used in agriculture, gardening, and environmental monitoring projects. This unit is compatible with the M5 Stack development board and provides an easy-to-use interface for measuring soil moisture levels.
Technical Specifications
Operating Voltage: 3.3V to 5.5V
 Communication Protocol: I2C
 Measurement Range: 0-100% soil moisture
 Accuracy: 5%
 Response Time: 10ms
Pinout
The M5 Stack Earth Moisture Unit has a 4-pin interface:
VCC (Red wire): Connect to the power supply (3.3V to 5.5V)
 GND (Black wire): Connect to the ground
 SCL (Yellow wire): Connect to the I2C clock pin (SCL)
 SDA (White wire): Connect to the I2C data pin (SDA)
Example Code 1: Basic Soil Moisture Measurement
This example demonstrates how to use the M5 Stack Earth Moisture Unit to measure the soil moisture level and display it on the M5 Stack's built-in LCD screen.
```c
#include <M5Stack.h>
#include <Wire.h>
#define MOISTURE_UNIT_ADDRESS 0x36 // I2C address of the M5 Stack Earth Moisture Unit
M5Stack m5;
void setup() {
  m5.begin();
  Wire.begin();
}
void loop() {
  int moistureLevel = 0;
  Wire.beginTransmission(MOISTURE_UNIT_ADDRESS);
  Wire.write(0x00); // Register address for moisture measurement
  Wire.endTransmission();
  Wire.requestFrom(MOISTURE_UNIT_ADDRESS, 1);
  moistureLevel = Wire.read();
m5.Lcd.setCursor(0, 0);
  m5.Lcd.print("Soil Moisture: ");
  m5.Lcd.print(moistureLevel);
  m5.Lcd.print("%");
delay(1000);
}
```
Example Code 2: Automating Watering System
This example demonstrates how to use the M5 Stack Earth Moisture Unit to automate a watering system. When the soil moisture level falls below a certain threshold, the system triggers a relay module to turn on a water pump.
```c
#include <M5Stack.h>
#include <Wire.h>
#define MOISTURE_UNIT_ADDRESS 0x36 // I2C address of the M5 Stack Earth Moisture Unit
#define RELAY_PIN 22 // Pin connected to the relay module
M5Stack m5;
void setup() {
  m5.begin();
  Wire.begin();
  pinMode(RELAY_PIN, OUTPUT);
}
void loop() {
  int moistureLevel = 0;
  Wire.beginTransmission(MOISTURE_UNIT_ADDRESS);
  Wire.write(0x00); // Register address for moisture measurement
  Wire.endTransmission();
  Wire.requestFrom(MOISTURE_UNIT_ADDRESS, 1);
  moistureLevel = Wire.read();
if (moistureLevel < 30) { // Soil moisture level threshold
    digitalWrite(RELAY_PIN, HIGH); // Turn on the water pump
  } else {
    digitalWrite(RELAY_PIN, LOW); // Turn off the water pump
  }
delay(1000);
}
```
Example Code 3: IoT-Based Soil Moisture Monitoring
This example demonstrates how to use the M5 Stack Earth Moisture Unit to send soil moisture data to a cloud-based IoT platform (e.g., MQTT) using a Wi-Fi module.
```c
#include <M5Stack.h>
#include <Wire.h>
#include <WiFi.h>
#include <PubSubClient.h>
#define MOISTURE_UNIT_ADDRESS 0x36 // I2C address of the M5 Stack Earth Moisture Unit
#define WIFI_SSID "your_wifi_ssid"
#define WIFI_PASSWORD "your_wifi_password"
#define MQTT_SERVER "your_mqtt_server"
#define MQTT_PORT 1883
#define MQTT_TOPIC "soil_moisture"
M5Stack m5;
WiFiClient espClient;
PubSubClient client(espClient);
void setup() {
  m5.begin();
  Wire.begin();
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  Serial.println("Connected to WiFi");
  client.setServer(MQTT_SERVER, MQTT_PORT);
}
void loop() {
  int moistureLevel = 0;
  Wire.beginTransmission(MOISTURE_UNIT_ADDRESS);
  Wire.write(0x00); // Register address for moisture measurement
  Wire.endTransmission();
  Wire.requestFrom(MOISTURE_UNIT_ADDRESS, 1);
  moistureLevel = Wire.read();
if (!client.connected()) {
    reconnect();
  }
  client.loop();
char soilMoistureString[10];
  sprintf(soilMoistureString, "%d", moistureLevel);
  client.publish(MQTT_TOPIC, soilMoistureString);
delay(1000);
}
void reconnect() {
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    if (client.connect("M5StackClient")) {
      Serial.println("connected");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      delay(5000);
    }
  }
}
```
These examples demonstrate the basic usage of the M5 Stack Earth Moisture Unit in various IoT applications. You can modify and extend these examples to fit your specific project requirements.