Trybotics Logo

ESP32 WiFi SOIL MOISTURE SENSOR

DESCRIPTION

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:

  1. Soil Moisture (My code will calculate the gravimetric soil water content)
  2. Air temperature and relative humidity

Supplies:

  1. Wemos® Higrow ESP32 WiFi + bluetooth Battery + DHT11 Soil Temperature And Humidity Sensor Module
  2. For data logging (optianal)

Description:

INSTALL AND CONFIGURE THE  ARDUINO IDE ON YOUR PC/MAC
2 More Images

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) .

  1. Download and Install the Arduino IDE
  2. In the Preferences menu, add https://dl.espressif.com/dl/package_esp32_index.json to the Aditional Boards Manager URL.
  3. Install the ESP32 Libraries from Tools>Board>Boards Manager. Search for esp32 by espressif systems
  4. Select your Board in the menu: Tools>Board>"WeMos" WiFi & Bluetooth Battery
  5. Install the required DHT11 Libraries from Tools>Manage Libraries...
    1. You need to install DHT sensor library by Adafruit Version 1.3.7 (Or later?)
    2. You need to install Adafruit Unified Sensor by Adafruit Version 1.0.3

Description:

If you need to log your data, attach a Pololu Micro SD Card Module. Other SD cards may have different wiring and code.

Description:

  1. Download the applicable arduino sketch from GitHub and open it.
    1. Esp32_SoilMoisture_WebServer.ino should be use if no micro sd card module is attached.
    2. 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.
    3. 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.
  2. Edit your Router SSID and Password in the sketch.
  3. Compile the sketch while pressing the boot button.
  4. If compiling is successful, press the EN button and immediately start the Arduino Serial Monitor (115200 Baud Rate)
  5. Wait for the Blue LED to go on and OFF
  6. Get the IP address printed in the serial monitor, enter it in your browser. You will now see the sensor data web page.
  7. If you added the micro sd card reader, and you compiled one of the applicable arduino sketches, you can access your data in /datalog.txt of your micro sd card.

Description:

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.

  1. Weight you dry soil
  2. 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.
  3. 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.
  4. Go on with this process as far as you like, or until adding water does not influence the sensor reading anymore.
  5. My results is in the attached excel sheet. GWC is calculated as gwc=exp(-0.0015*SensorValue + 0.7072)

Attachments

Description:

  1. 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
  2. Add push buttons to start and stop the WiFi and web server to save battery usage.
  3. Ad a GPRS module and disable WiFi. This will save power.


YOU MIGHT ALSO LIKE