Soil Moisture Sensor ESP32 Mini
Print Profile(1)

Bill of Materials
Description
Description
I have created a second, more compact soil moisture sensor than the photovoltaic panel version, incorporating a USB-C charging port for convenient recharging without disassembling the sensor. Its compact size makes it ideal for indoor potted plants.
I utilized a capacitive sensor for soil moisture detection, coupled with an ESP32 mini for data transmission to Home Assistant.
An integrated 18650 battery pack with a charging circuit is included. A dedicated opening allows for manual USB charging.
Printing
All printed parts are ABS and require no supports. The TPU component is the USB port cover.
Assembly
Before inserting the moisture sensor, apply silicone sealant to the groove for a watertight seal, and add a bead of silicone externally where the sensor protrudes. A 38mm inner diameter O-ring should be placed in the lid's recess to ensure a leakproof fit.
Electronics
For the electrical components, I created a battery pack using a single 18650 cell.
The battery pack connects directly to the TP4056 charging module at the B+/B- terminals.
The charging module's OUT+/OUT- output connects directly to the ESP32 mini module: VCC to OUT+ and GND to OUT-.
The moisture sensor connects to the ESP32 mini module: VCC to 3V3, GND to GND, and the AUOT pin to GPIO36.
Connect the ESP32 mini's GPIO26 and RST pins together to enable deep sleep functionality, allowing the board to execute code at regular intervals before entering low-power mode.

Required Materials
1 x ESP32 Mini
1 x Soil Moisture Sensor
1 x TP4056 USB-C Charging Module
1 x 18650 Battery
Boost Me (for free)
Do you like the model? If so, please support me and help me create more amazing models.
Code
This is the code to be entered into ESPHome after creating the sensor. The first part is automatically generated; you only need to copy the section after “captive_portal:”
esphome:
name: umidita-terreno-2
friendly_name: Umidità terreno_2
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "xxxxxxxxxxxxxxxxxxxxxxxxxx"
ota:
- platform: esphome
password: "xxxxxxxxxxxxxxxxxxxxxxxxxxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Umidita-Terreno-2"
password: "xxxxxxxxxxxxxx"
captive_portal:
sensor:
- platform: adc
pin: GPIO36 # For ESP32
name: "Umidità del Suolo_2"
unit_of_measurement: "%"
accuracy_decimals: 1
update_interval: 10s # Update less frequently to save power
attenuation: 11db # Expands the ADC range to 0-3.9V to prevent saturation
filters:
- calibrate_linear:
- 3.3 -> 0.0 # Dry (in air)
- 0.95 -> 100.0 # Very moist soil
- lambda: |-
if (x < 0) return 0;
if (x > 100) return 100;
return x;
- median:
window_size: 5
send_every: 3
send_first_at: 1
deep_sleep:
run_duration: 120s # Active for 2 minutes
sleep_duration: 3600s # Deep sleep for 60 minutes
License
You shall not share, sub-license, sell, rent, host, transfer, or distribute in any way the digital or 3D printed versions of this object, nor any other derivative work of this object in its digital or physical format (including - but not limited to - remixes of this object, and hosting on other digital platforms). The objects may not be used without permission in any way whatsoever in which you charge money, or collect fees.










Comment & Rating (14)