Environment - Soil moisture sensor

.

Plugin details

Type: Environment

Name: Soil moisture sensor

Status ESP32: COLLECTION CLIMATE

Status ESP8266: COLLECTION CLIMATE

GitHub: P047_i2c-soil-moisture-sensor.ino

Maintainer: .

Used libraries: .

Supported hardware

Though not directly applicable, as it is about selecting an Analog Soil-moisture sensor, this Youtube video has usable tips on finding a reliable sensor.

Configuration

../_images/P047_DeviceConfiguration.png
  • Name A unique name should be entered here.

  • Enabled The device can be disabled or enabled. When not enabled the device should not use any resources.

I2C Options

The available settings here depend on the build used. At least the Force Slow I2C speed option is available, but selections for the I2C Multiplexer can also be shown. For details see the I2C Bus page

  • I2C Address (Hex): The address the device is using. The default I2C address is prefilled, and can be configured to use a different address, see below. As this can be any valid I2C address in range: 0x01..0x7F, it has to be typed here, using a hexadecimal value.

For the Adafruit I2C Capacitive Moisture sensor, only addresses 0x36..0x39 can be configured, by connecting the A0/A1 address soldering pads. For this sensor only these addresses can be selected.

Note

If the device doesn’t stay enabled after setting the Enabled checkbox, then possibly the address of the sensor is changed from the default. The I2C Scan on the Tools page can be used to detect what I2C device addresses are in use (disconnect other I2C devices to avoid confusion). Possibly, another device-model is listed for this sensor, but that is caused by the feature that it can have any address set that’s in the I2C allowed range of 0x00 to 0x7F.

Device Settings

  • Sensor model: Select the model of the used sensor. When changing the selection the page will be reloaded to adjust the available configuration options, tailored to the selected sensor.

../_images/P047_SensorModelOptions.png
  • Catnip electronics/miceuz (default): The originally supported soil moisture sensor, that supports temperature, moisture and light measurement, has a sleep-mode, and can report a version number, to optionally validate if the sensor is supported.

  • BeFlE v2.2: An I2C soil moisture sensor that supports temperature and moisture measurement. There is no sleep mode or version check available.

  • BeFlE v3.x: An I2C soil moisture sensor that supports temperature and moisture measurement, has a low-power Sleep mode and can report it’s version, but this is not explicitly checked.

  • Adafruit (4026): An I2C soil moisture sensor that supports temperature and moisture measurement. There is no sleep mode available, and the version is only logged at startup.

When selecting the BeFlE v2.2 sensor, only these Device Settings will be available:

../_images/P047_SensorModelBeFlE.png

When selecting the BeFlE v3.x sensor, only these Device Settings will be available:

../_images/P047_SensorModelBeFlEv3.png
  • Send sensor to sleep: When not actively reading the sensor, the device can be set to sleep-mode, to conserve some power. (Catnip and BeFlE v3 sensors only).

  • Check sensor version: To validate if the sensor is of the correct mode, the version can be validated. (Catnip sensor only).

  • Change sensor address: To use multiple sensors connected to a single ESP unit, a sensor can be configured to use a different I2C address. To change that address, this checkbox has to be enabled, and a different I2C address should be entered in the Change I2C Address to (Hex) field in hexadecimal format, range: 0x01..0x7F. This option isn’t available for the Adafruit sensor.

  • Change I2C Addr. to (Hex): The new address to be used by the sensor. The change will be applied the next time the task is enabled. The I2C Address (Hex) field, above, will be updated with the new value. After the change is applied, the tasks Settings have to be saved once more to save the new address as the address to use. This option isn’t available for the Adafruit sensor.

When using the I2C scanner, the changed address will show up, but it probably will not show the sensor name, as only the original I2C address is added to the list. NB: Not all builds show known names for sensors to reduce the build binary size.

Note

The newly set address is permanently stored in the sensor, and can be changed again at a later time if desired.

Data Acquisition

This group of settings are standard available configuration items.

  • Single event with all values: When this setting is enabled, all available values will be sent in a single event <TaskName>#All, with all values in order as arguments to the event.

  • Show derived values: When checked, the Devices overview page, and the /json endpoint (used for updating the Devices overview page) will include any Derived values as defined. See the TaskValueSetDerived and TaskValueSetPresentation commands.

  • Event & Log derived values: When checked, the Derived values will be generated as Events, to be handled in Rules, and sent to logging devices like the Syslog server and/or SD-card logging.

(The derived values options are only available if String variables feature is included in the build.)


  • Send to Controller: Select the Controller(s) to send the Values to, either on a TaskRun command applied to the task, or on an Interval time action.

Send to Controller is only visible when one or more Controllers are configured.

Depending on the controller capabilities, some configuration settings may be shown:

../_images/Task_config_page_Controllers_section.png

All configured Controllers are shown here, including the enabled or disabled state (multiple Controllers can be enabled, only a single MQTT Controller can be enabled at one time!).

For each controller the user can select wether the data should be sent on each Interval (or explicit TaskRun).

For the Domoticz controllers the value index (IDX) has to be configured.

For some controllers, like Home Assistant/openHAB, there are extra options available.

  • Group: This represents the group id to combine all values from multiple tasks into a single grouped-device during MQTT AutoDiscovery. Groups, by design, can span multiple ESPEasy devices, if desired, as long as the Task/Valuename combinations are unique. If a group should only combine Tasks from a single ESPEasy unit, the group id should be unique across multiple ESPEasy units. The group description, default Group <n>, can be adjusted in Home Assistant. If the Group value matches the current Unit nr, the Unit name, %sysname%, is used instead of Group <nr>.

  • Retained: For MQTT Controllers, this setting can be enabled to send the values for the current task with the Retain flag set. The Publish Retain flag in the Controller settings will override this by sending all task values with Retain flag enabled.

  • Send derived: This checkbox determines if any configured Derived values should also be sent to the controller (and included in the AutoDiscovery if that’s available and enabled).

  • Resend MQTT Discovery: When checked, will start a resend of the MQTT Discovery process for this task after a random delay, when Submit is clicked, so any changed settings will be updated in the MQTT broker. This setting is only available if the controller is enabled, the Auto Discovery feature is available and enabled for the controller. This setting is not stored.

Other controllers, like f.e. FHEM HTTP, do not support additional settings besides the checkbox to enable sending the data.


Interval By default, Interval will be set to 60 sec. The minimum value allowed is 1 sec. but each read is taking at least 2 seconds, so selecting a value below 3 seonds might cause intermittent read failures or invalid values.

Values

The measured values are available in Temperature, Moisture and Light. A formula can be set to recalculate. The number of decimals is by default set to 2, and can be set to 0 for Moisture, as no decimals are provided from the measurement.

NB: The BeFlE and Adafruit sensors don’t support a Light value, so that won’t be available if that Sensor model is selected.

NB2: The Adafruit sensor has a different range for the moisture values: 200..2000 compared to the Catnip and BeflE sensors: 1..800, so any moisture calibration has to be based on actual observation, and not on absolute numbers.

Change log

Changed in version 2.0:

added 2024-05: Add support for BeFlE v3.x I2C moisture sensor.

added 2024-04: Add support for Adafruit I2C moisture sensor.

added 2023-03: Add support for BeFlE v2.2 I2C moisture sensor.

added Major overhaul for 2.0 release.

Added in version 1.0:

added Initial release version.