Cheap soil moisture sensors which send an electrical signal through soil to measure the resistance of the soil is all failing. Electrolysis makes this sensors of no practical use. See more about electrolysis here. The sensor used in this project is a capacitive sensor and no conductive metal is in touch with wet soil.
After loading the firmware (Arduino sketch), the sensor will create a web server on itself and log into your WiFi router. You can now access the web side on the ESP32 sensor. No data is send to the cloud.
Some familiarity with Arduino Programming, Soldering skills and HTML etc may assist. If you build this project, please upload photos via the upload link below. Enjoy the hacking.
This sensor can read:
- Soil Moisture (My code will calculate the gravimetric soil water content)
- Air temperature and relative humidity
- Wemos® Higrow ESP32 WiFi + bluetooth Battery + DHT11 Soil Temperature And Humidity Sensor Module
- For data logging (optianal)
Bread Board and OR
Soldering Iron, solder paste.
Six Female to Male jumper cables.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: INSTALL AND CONFIGURE THE ARDUINO IDE ON YOUR PC/MAC
This setup procedure should work on a Windows PC, MAC and LINUX (x86) system. Unfortunately for Raspberry PI users the LINUX (ARM) Libraries for the ESP32 Board is not available yet (although there was real clever people who compiled them from source) .
- Download and Install the Arduino IDE
- In the Preferences menu, add https://dl.espressif.com/dl/package_esp32_index.json to the Aditional Boards Manager URL.
- Install the ESP32 Libraries from Tools>Board>Boards Manager. Search for esp32 by espressif systems
- Select your Board in the menu: Tools>Board>"WeMos" WiFi & Bluetooth Battery
- Install the required DHT11 Libraries from Tools>Manage Libraries...
- You need to install DHT sensor library by Adafruit Version 1.3.7 (Or later?)
- You need to install Adafruit Unified Sensor by Adafruit Version 1.0.3
Step 2: ATTACH MICRO SD CARD FOR LOGGING (OPTIONAL)
If you need to log your data, attach a Pololu Micro SD Card Module. Other SD cards may have different wiring and code.
Step 3: DOWNLOAD THE ARDUINO SKETCH
- Download the applicable arduino sketch from GitHub and open it.
- Esp32_SoilMoisture_WebServer.ino should be use if no micro sd card module is attached.
- Esp32_SoilMoisture_WebServer_DataLog.ino requires an micro sd card and continues internet access to the NTP server. This option has very accurate time, but use large amounts of current and may deplete the battery.
- Esp32_SoilMoisture_WebServer_DataLog_Int_RTC.ino requires an micro sd card and internet access to the NTP server after reset. It uses the internal RTC of the ESP32 to update the date/time received at reset from the NTP server. This is the most power efficient solution, but the time may not be as accurate.
Step 4: GRAVIMETRIC WATER CONTENT-CALIBRATION
How should I interpret the soil moisture reading from GPIO 32?
One method is to calculate the gravimetric water content of the soil. It is calculated as:
(Mass of Water in Soil Sample)/(Mass of Dry Soil in Sample)
I have collected dry soil out of my garden (It is Limpopo, South Africa, August month and the soil is dry, really dry). You can dry soil in a oven.
- Weight you dry soil
- pour the dry soil in a container, insert the sensor in the soil and take a raw sensor reading (use the web interface). Record the Water Mass (=0 at this stage) and the sensor reading.
- Remove the sensor, add 10 ml (gram) water, mix the soil and water properly and record your Water Mass (=10 at this stage) and the sensor value.
- Go on with this process as far as you like, or until adding water does not influence the sensor reading anymore.
- My results is in the attached excel sheet. GWC is calculated as gwc=exp(-0.0015*SensorValue + 0.7072)
Step 5: Future Developments
- Attach a external RTC (Real Time Clock). Currently, NTP (Network Time Protocol) is used to get the time for data logging. This requires WiFi and is current intensive
- Add push buttons to start and stop the WiFi and web server to save battery usage.
- Ad a GPRS module and disable WiFi. This will save power.
- And yes, make this project a Siphoning rain gauge (See Photo). See idea at https://www.instructables.com/id/PiSiphon-Rain-Gauge-Prototype/