Search models, users, collections, and posts

Soil moisture sensor - ESP32

Print Profile(1)

All
A1
X1
H2D
P2S
H2D Pro
X1 Carbon
P1P
H2S
X1E
P1S
H2C
A1 mini
X2D
A2L

0.2mm layer, 2 walls, 15% infill
0.2mm layer, 2 walls, 15% infill
Designer
2.8 h
1 plate

Open in Bambu Studio
Boost
52
166
5
4
57
28
Released 

Description

Boost Me (for free)

Soil Moisture Monitoring with ESP32 and Hygrometer Sensor

 

I took the battery compartment from this project. (https://makerworld.com/en/models/539919-18650-battery-case-21700-battery-case#profileId-467576)

 

Project Description

This project uses an ESP32 and a soil moisture sensor to monitor the soil’s humidity levels and send updates to a Telegram bot. The system is designed to optimize power consumption while ensuring reliable measurements over time.

The sensor is powered only when needed to prevent false readings and reduce battery consumption. Additionally, the ESP32 enters deep sleep between measurements to maximize battery life.

 

Components Used

Code

#include <WiFi.h>
#include <HTTPClient.h>
#include <UniversalTelegramBot.h>
#include <ArduinoJson.h>

#define WIFI_SSID "YOUR_WIFI"  
#define WIFI_PASSWORD "YOUR_PASSWORD"
#define BOT_TOKEN "YOUR_BOT_TOKEN"
#define CHAT_ID "YOUR_CHAT_ID"

#define SENSOR_PIN 34  // Pin analogico per il sensore di umidità
#define POWER_PIN 32   // Pin per accendere/spegnere il sensore
#define SLEEP_TIME 30  // Minuti di deep sleep

float soglia_secco = 30.0;     // Soglia per terreno troppo secco (%)
float soglia_umido = 70.0;     // Soglia per terreno umido (%)
float ultima_umidita = -1;     // Per evitare invii ripetuti

WiFiClientSecure client;
UniversalTelegramBot bot(BOT_TOKEN, client);

void setup() {
 Serial.begin(115200);

 WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
 while (WiFi.status() != WL_CONNECTED) {
   delay(500);
   Serial.print(".");
 }
 Serial.println("\nConnesso a WiFi!");

 client.setInsecure();  // Per connessione senza certificati SSL
 
 pinMode(POWER_PIN, OUTPUT);
 digitalWrite(POWER_PIN, HIGH);  // Accende il sensore
 delay(1000);  // Attendi stabilizzazione

 int raw_value = analogRead(SENSOR_PIN);
 float umidita = map(raw_value, 0, 4095, 100, 0); // Mappa il valore in %

 Serial.print("Umidità rilevata: ");
 Serial.print(umidita);
 Serial.println("%");

 if ((umidita < soglia_secco && ultima_umidita >= soglia_secco) ||
     (umidita > soglia_umido && ultima_umidita <= soglia_umido)) {
   String message = "🌱 Umidità attuale: " + String(umidita) + "%";
   if (umidita < soglia_secco) {
     message += "\n⚠️ Il terreno è troppo secco!";
   } else if (umidita > soglia_umido) {
     message += "\n✅ Il terreno è sufficientemente umido.";
   }
   bot.sendMessage(CHAT_ID, message, "");
 }

 ultima_umidita = umidita;
 digitalWrite(POWER_PIN, LOW);  // Spegne il sensore

 Serial.println("Entrando in deep sleep...");
 esp_sleep_enable_timer_wakeup(SLEEP_TIME * 60 * 1000000);  // Tempo in microsecondi
 esp_deep_sleep_start();
}

void loop() {
 // Vuoto, non verrà mai eseguito a causa del deep sleep
}

 

 


 

Comment & Rating (5)

(0/1000)

Boosted
Love your design, I'm trying to have something similar for a LD2410C radar sensor, can you share the CAD file?
The designer has replied
0
Reply
Thank you, of course I can share the file
Show original
1
Reply
Boosted
Replying to @user_3841066042 :
Perfect, I will try to modify it. I will wait for the file
Show original
0
Reply
Really like the design, but I have a lot of dead space for the electronics I'm using. Would you be willing to share STEP/CAD/Source files so I can tweak it to be a bit smaller?
The designer has replied
0
Reply
Thank you for the comment. Sure, i can share the cad file.
0
Reply
No more

License

This user content is licensed under a Standard Digital File 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.