Labs / Electronic modules

Low-cost soil temperature and humidity sensor MSE

Author: Li Zisheng · Source: FreakStudio open documentation, v1.1 · License: CC BY 4.0 · Driver code (sensors/mse_soil_sensor_driver): MIT License

Contents

Introduction

Have you ever encountered such a headache: the potted plants you grow always end up with root rot or die of drought due to improper watering, and you can only judge the watering amount for your home vegetable garden by "gut feeling"? Traditional soil moisture detection solutions are either pin-type resistance sensors that are prone to corrosion and data drift, or professional equipment that is costly and requires complex calibration, making them extremely difficult to popularize in civilian and small-scale scenarios.

Low-cost soil temperature and humidity sensor MSE

Launched by Minyuan, the low-cost soil temperature and humidity sensor MSE is a capacitive intelligent detection module designed precisely to address these pain points. Leveraging high-frequency capacitive sensing technology, it enables low-cost, high-precision detection of soil moisture content and temperature, providing a reliable soil sensing solution for a wide range of scenarios from household potted plants to small-scale agriculture.

For a long time, soil moisture content detection has been plagued by the industry-wide challenges of "inaccuracy, vulnerability to damage, and high cost":

The emergence of MSE has precisely filled the gaps in these solutions by leveraging low-cost capacitive sensing technology.

Low-cost soil temperature and humidity sensor MSE

As a soil temperature and humidity sensor designed specifically for popularization scenarios, MSE boasts advantages that perfectly align with the needs of civilian use and small-scale agriculture:

Low-cost soil temperature and humidity sensor MSE

Many people fail to keep houseplants alive and thriving, and the core issue lies in their inability to accurately judge soil moisture. As shown in the figure, the MSE can be directly inserted into the potting soil to detect moisture content and temperature in real time, and remind users to water via the device or APP to precisely match the water needs of green plants. Its low-cost design also supports batch application across multiple flower pots, making it an ideal choice for smart home plant care devices, and completely putting an end to the "watering mystery".

In home gardens, small-scale farms or balcony vegetable plots, MSE can be deployed in batches in the soil to monitor moisture content in real time, and work with automatic irrigation systems to achieve on-demand watering — this not only avoids the blindness of manual watering but also saves water resources; its non-contact and durable design can also adapt to complex environments such as outdoor areas and greenhouses, eliminating the need for frequent maintenance, and thus freeing the fine management of small-scale agriculture from reliance on manual experience.

In scenarios such as residential greening and park landscapes, MSE can serve as low-cost soil sensing nodes, which can be deployed in batches in the soil of green plants to monitor the moisture content in real time, provide data support for garden maintenance, and reduce the cost of manual inspection. Meanwhile, it adapts to different soil types and environments, realizing the refined maintenance upgrade from "manual inspection" to "Data drive".

I. Module Introduction

Low-cost soil temperature and humidity sensor MSE

2. Introduction to Main Chips

2.1 Chip Overview

The sensor incorporates a high-precision digital capacitive sensing chip with built-in sensitive source, a microprocessor and algorithms. The moisture content (in percentage) is proportional to the capacitance value, which can be fitted and converted according to different soil characteristics.

2.2 Pin Definition

Low-cost soil temperature and humidity sensor MSE

2.4 Performance Parameters

Low-cost soil temperature and humidity sensor MSE
Low-cost soil temperature and humidity sensor MSE
Low-cost soil temperature and humidity sensor MSE

III. Circuit Engineering

3.1 Circuit Source Engineering

To obtain the source project of the circuit, please refer to the link below:

https://www.mysentech.com/productinfo/3096406.html

3.2 Module Usage Instructions

3.2.1 Module Test Environment Setup and Notes

Here, we first need to confirm that the serial port data is stable without garbled characters, then insert the probes into dry soil and wet soil respectively, and observe whether the moisture content value changes linearly with soil humidity; you can also use the palm of your hand / ice water to test the change of temperature reading to quickly verify that the temperature and humidity detection function works properly.

Avoid forceful insertion of the probe into the soil to prevent damage to the electrodes; the power supply voltage must strictly not exceed 5.5V; do not immerse the probe in water for a long time, and wipe it dry after testing;Calibration is required according to the actual soil in use, as differences in capacitance characteristics across different soils will affect the accuracy of readings.

3.2.2 Usage of Modbus Poll

Modbus Poll is a universal Modbus master debugging tool compatible with all capacitive sensors in this series that support the Modbus-RTU protocol. It enables quick serial communication debugging, real-time data reading and log export between sensors and computers, serving as a universal host computer tool for verifying sensor functions and collecting test data. The software supports Modbus RTU/ASCII/TCP/IP protocols, is compatible with multiple register types and data formats, and its operation process is universal for the entire series of sensors.

Before use, you need to complete the software installation and activation first. You can download the installation package through official channels; the first launch supports a 30-day trial, and you can also enter a registration code for permanent activation. After the hardware connects the sensor to the computer, open the software and click "Connection" - "Connect", then configure the serial port parameters (Port Number, baud rate, data bit/parity bit/stop bit; this series of sensors defaults to the 9600 Baud, 8N1 format, subject to the specification sheet of the corresponding specific model) in the pop-up window, and confirm to establish a communication connection.

Low-cost soil temperature and humidity sensor MSE

The following is a description of the general operation process:

  1. Serial Port Connection Configuration: After connecting the sensor to the computer via a USB-to-serial port module, launch the Modbus Poll software, click "Connection" - "Connect" on the menu bar, select the COM Port Number corresponding to the sensor in the pop-up window, and configure the serial port parameters matching the sensor (baud rate, data bits, parity check mode, stop bits; this series of sensors defaults to 9600 Baud, 8N1 format), then confirm to establish a communication connection.
  2. Import Sensor Configuration File: The software supports importing. mbp pre-configuration files corresponding to various sensor models. These files come with preset register addresses, data formats, and alias definitions, eliminating the need for manual register configuration. Simply open the. mbp file for the corresponding sensor in the software to automatically load all parameters. Once the connection is established, real-time detection data of the sensor (such as dust/rain/frost thickness values, status flag bits, etc.) will be displayed directly.
  3. Data Logging (Optional): If you need to save test data, you can configure logging rules via the "Setup" - "Excel Log" function. It supports logging data at fixed intervals or with every data update, and allows you to set a maximum number of log entries, facilitating subsequent analysis and verification of sensor data.

The above are the general basic operations of the host computer. For the. mbp preconfiguration files, specific register definitions and special configuration details of different sensor models, please refer to the content in "VII. Related Materials".

3.3 Application Experiment

Here, we use the GraftPort-RP2040 development board for testing, and the low-cost soil temperature and humidity sensor MSE uses the UART interface to communicate with the main controller.

Here, we first use the HY2.0-4P cable to connect the module via the XH2.54-4P to HY2.0-4P interface module to the GraftPort-RP2040 development board's UART0 interface:

Low-cost soil temperature and humidity sensor MSE

This diagram illustrates the wiring method between the MSE soil temperature and humidity sensor and the development board via UART.

Then insert this module into the soil:

Low-cost soil temperature and humidity sensor MSE

The module connections are shown in the following table:

Development Board Pins

Module Pins

Description

Pin 16

MTX

UART data transmission line, corresponding to the transmit pin of the development board

Pin 17

MRX

UART data transmission line, corresponding to the receiving pin of the development board

Here, we need to search for the relevant driver packages on uPyPI: https://upypi.net/zh/

Low-cost soil temperature and humidity sensor MSE

This diagram demonstrates the procedure for locating the MSE driver package on the uPyPI platform.

Enter mse_soil_sensor_driver to search, and the following will be displayed:

Low-cost soil temperature and humidity sensor MSE

This figure shows the search results page for mse_soil_sensor_driver.

Click to copy the local installation command:

Low-cost soil temperature and humidity sensor MSE

This figure shows the interface for copying the MSE driver installation command, which facilitates the completion of local import.

Import the module driver library code via the mip tool. Below are the usage commands for the mpremote tool:

mpremote mip install https://upypi.net/pkgs/mse_soil_sensor_driver/1.0.0

Import the low-cost soil temperature and humidity sensor MSE-MicroPython driver code, then copy the following main.py code into our project:

# Python env   : MicroPython v1.23.0
# -*- coding: utf-8 -*-
# @Time    : 2026/4/3 AM 10:30
# @Author  : hogeiha
# @File    : main.py
# @Description : MSE soil temperature and humidity sensor data reading and configuration example program

# ======================================== Import Modules =========================================

import time
from mse_soil_sensor import MSESoilSensor

# ======================================== Global Variables ============================================

# ======================================== Functions ============================================

def read_all():
    """
    Read and print all sensor register data

    Args:
        None

    Raises:
        None

    Notes:
        Call all read-only methods in the driver class and print the formatted results to the console.

    ==========================================
    Read and print all sensor register data

    Args:
        None

    Raises:
        None

    Notes:
        Call all read-only methods of driver class and format output to console.
    """
    # Print data separator line
    print("=" * 50)
    # Print slave address
    print(f"Sensor data (Addr: {sensor.read_node_address()})")
    # Print temperature value
    print(f"Temperature        : {sensor.read_temperature()} C")
    # Print capacitance value
    print(f"Capacitance        : {sensor.read_capacitance()} pF")
    # Print capacitance center value
    print(f"Capacitance center : {sensor.read_cap_center()} pF")
    # Print capacitance range
    print(f"Capacitance range  : {sensor.read_cap_range()} pF")
    # Print filter count
    print(f"Filter count       : {sensor.read_filter_count()}")
    # Print averaging window size
    print(f"Average window     : {sensor.read_avg_window_size()}")
    # Print temperature compensation coefficient A
    print(f"Temp comp A        : {sensor.read_temp_comp_A()}")
    # Print temperature compensation coefficient B
    print(f"Temp comp B        : {sensor.read_temp_comp_B()}")
    # Print hardware version
    print(f"Hardware version   : {sensor.read_hw_version()}")
    # Print firmware version
    print(f"Firmware version   : {sensor.read_firmware_version()}")
    # Print device UID
    print(f"Device UID         : {sensor.read_device_uid()}")
    # Print the ending separator line
    print("=" * 50)

# ======================================== Custom Classes ============================================

# ======================================== Initialization configuration ===========================================

# Wait 3 seconds to ensure the serial port is stable
time.sleep(3)
# Print startup message
print("FreakStudio: MSE soil sensor test start")

# Create the sensor instance
sensor = MSESoilSensor(slave_addr=1, baudrate=9600, uart_id=0, tx_pin=16, rx_pin=17)

# ========================================  Main Program  ============================================

# Check whether running as the main program
if __name__ == "__main__":
    # sensor.write_filter_count(20)      # Set filter count
    # sensor.write_temp_comp_A(0.5)      # Set temperature compensation A
    # Write temperature compensation coefficient B
    sensor.write_temp_comp_B(0.5)

    # Main loop: read all data every 2 seconds
    while True:
        read_all()
        time.sleep(2)

Burn the code, open the terminal, and the output is as follows:

Low-cost soil temperature and humidity sensor MSE

This diagram demonstrates the real-time output effect of the MSE module, which can be used to verify the data reading results of temperature, humidity, capacitance and other parameters.

4. Drivers

mse_soil_sensor_driver.zip 46 KB

None

VI. Revision History

Document Version

Date of Modification

Modifier

Revised Content

v1.0

2026-04-24

Hou Junhan

Initialize Document

v1.1

2026-05-20

Li Zisheng

Add introduction and the usage of 3.2.2 Modbus Poll

VII. Relevant Materials

MSE Low-Cost Soil Temperature and Humidity Sensor Product Manual-MSE202410 (1).pdf 864 KB

Modbus+Poll.rar 1.8 MB

MSE Register Configuration-202410.mbp 2 KB