Measuring Hydraulic Properties of Soil With ESP32

Introduction: Measuring Hydraulic Properties of Soil With ESP32

Soil Hydraulic Conductivity Meter (SHC Meter)

In this project we'll build an esp-32 based instrument for measuring hydraulic properties of soil.

With this SHC Meter one can plot the Retention Curve of a saturated soil and get its hydraulic conductivity.

The retention curve is of great importance in describing the hydraulic properties of the soil and is required for the purpose of modeling flow and conveyance processes, for the benefit of irrigation management and many other applications related to the management or evaluation of groundwater. Hydraulic conductivity is very important in agriculture in the context of irrigation and soil feeding.

In this instructable we'll give a detailed explanation on how to build the instrument and get it to work.

Take a look at our GitHub for more instructions and the sketch (code for esp32):

https://github.com/deedeeharris/agritech2021

All the best,

Yedidya Harris

Yehuda Yungstien

The Faculty of Agriculture

The Hebrew University of Jerusalem (ISRAEL)

For more AgriTech projects, click here!

Supplies

The pipe (for holding the saturated soil):

  1. Piece of PVC pipe (7cm height * 11cm diameter)
  2. A plastic bottom (11cm diameter) - any plastic cover that one can drill a few holes into.
  3. 2 * PG-7 - a cable gland for inserting the tensiometers in the pipe. You can purchase them on Amazon, just search for 'PG7'.
  4. Glue - to connect the plastic bottom to the pipe, and fasted the PGs inside.

Extras for the experiment:

  1. Thin silicone tubing (8mm, 10cm - like in fish tanks / irrigation) - to connect the pressure sensors to the tensiometers.
  2. Plastic plate - to cover the pipe with soil during pre-saturation.
  3. Simple syringe + silicone tubing - to pre-saturate the tensiometers.
  4. A plastic box - a case for the electrical circuit.

Tensiometer:

  1. 2 * thin 4 mm plastic pipe
  2. 2 * ceramic cups
  3. Glue

Electrical Components:

  1. ESP32 (WROOM-32)
  2. Breadboard (60 rows, A-J)
  3. Jumper cables (male-male, male-female)
  4. ADS1115
  5. 2 * Pressure sensors MPX5100
  6. 6 * 1K Ω resistors
  7. HX711
  8. Loadcell (and wooden/plastic/glass plates for scale)

Step 1: The Ring for the Soil

A PVC pipe will be used to hold the saturated soil in the lab. Cut it with a saw (7cm height * 11cm diameter), and drill two holes at the side for the PGs. The first hole should be 2cm from the bottom, and the next hole following with 2cm away (see image A).

Use a tap wrench to make the holes good for PG. Insert the PG (size 7) in the holes. You may need to glue them to the pipe with hot glue if the tap wrench didn't work well.

Add a plastic bottom (with around 10 holes drilled) to the ring. You can use any strong plastic cover (like from a lunch box).

That's it for the ring.

Step 2: DIY Scale

To measure the loss of water in evaporation during the experiment, the pipe with the saturated soil will be weighed during the entire period of time (10 days);

Start building your scale with 2 plates and a loadcell. Wire it up.

There are many instructables that can guide you through the process. Here are a few:

As you see in the photos attached, we used 2 clear strong platic plates (15cm * 15cm). We connected the green box at the bottom, to have the scale balanced. One can add small 'legs' instead (make sure they're the same height!).

Step 3: Mini Tensiometers - Create!

Our SHC Meter uses two mini tensiometers. They are pre-saturated before the experiment. Are made out of a thing plastic pipe with a ceramic cup at the tip.

Cut two pieces of a 7cm strong plastic pipe (4mm diameter). Glue the ceramic cup to the end the pipe, or add a washer and glue it all together.

We purchased our 5 BAR ceramic cups from SoilMosture.com:

https://www.soilmoisture.com/0653-Round-Bottom-Neck-Top-Ceramic-Cup-Series/

Step 4: ESP32 Here We Comeee!

This step is wonderful. Building the circuit, and coding the microcontroller. You may encounter issues during the hardware and software stage, but that's the fun - to solve them. Google is handy. Please don't hesitate to share here any problems, so we can help out.

ESP32 is great. A microcontroller with Bluetooth and WIFI on board! There's tons of information online, and easy to use.

The breadboard we chose was a narrow and long (60 rows, A-J) BB. The ESP32 fits well. Connect it after row 0, like in the attached image. You may need to push hard to make the pins are in until the end. If you need to take the esp32 out, lift it with a flat screwdriver.

Take a look at the esp32 pinout attached. We are using a big breadboard, and one can notice the pin conversion, from the esp32 pin numbers to the actual marks on the breadboard. As you can see, each of the esp32 pins have different roles. We will connected the different sensors to the matching pins (using the breadboard).

On the breadboard blue and red lines are noticed at the left and right (power rails). Red for the positive (the voltage), and blue for the negative (ground). There's a white spacing at row 30, that separates the colored lines - offering one to have 4 different voltages if needed. In our project we'll use 5V and 3.3V. So start by connecting the blue line on the right bottom, to the blue line on the right top with a jumper cable (or a short and low cable). Do this process to 'eliminate' the spacing, and continue the future current going through the hidden wires. Read here for more information on "How to Use a Breadboard".

Now connect the power rails to voltage and ground pins on the esp32:

  1. Connect a wire between 'hole 1' on the breadboard (near the esp32) to the left red rail - 5V.
  2. 'Hole 6' on the bb (GND) to the left blue rail.
  3. 'Hole 19' on the bb (3.3V) to the right red rail.
  4. 'Hole 41' on the bb (GND) to the right blue rail.

That's it for now! Continue and connect your fantastic scale.

Step 5: Hooking Up the Scale With HX711 to the ESP32

The HX711 module allows us to read accurate weight from our loadcell (with some calibration!).

If your pins that you've received aren't connected to the HX711 - then solder them to each other.

Insert the module into your breadboard in a way you can connect wires on its side to the esp32.

Connect the loadcell to the HX711:

  • RED Wire (from the loadcell) to E+ (on the HX711)
  • BLACK Wire to E-
  • WHITE Wire to A-
  • GREEN Wire to A+

Connect the HX711 the to the esp32:

  • GND to the right blue rail.
  • VCC to the right red rail (3.3V).
  • DT to GPIO5 which is hole 50 on the breadboard (BB) we chose.
  • SCK to GPIO2 which is hole 55 on our BB.

* The pinout attached may assist you (from how2electronics.com).

For more info on connecting the HX711 between the loadcell and our microcontroller, you can read here:

Code and calibration we'll do later.

Step 6: Calm Down and Wire the Pressure Sensors With an ADS1115!

If you've made until here, well done!

Many more wires are going to join the mess. But let's make it simple.

To connect our two pressure sensors (MPX5100) to our esp32 it's good to use an ADS1115 module, to get more accurate results.

ADS1115

This module is an analog to digital converter, and has 4 different channels. We'll be using two of them for our pressure sensors.

Connections:

  • VDD on the ADS to the right red rail (3.3V) on the breadboard.
  • GND to the the right blue rail (ground).
  • SCL/SCK (serial clock pin) to GPIO22 which is hole 43 near the esp32 on our breadboard.
  • SDA to GPIO21 which is hole 46 on our bb.
  • ADDR to the the right blue rail as well.
  • A0 and A1 will be hooked up to the MPX5100.

For further information on the ADS1115, you can glance here: https://microcontrollerslab.com/ads1115-external-a...


MPX5100

Use at least 15cm long jumper cables to connect the MPX5100 to the breadboard. Since the pressure sensors are going to be attached to the tensiometers in the ring, it's good to use long wires here in advance.

Hold the MPX while seeing the text written on it. Connect 3 wires to the first 3 pins from the left (see attached image):

  • Pin 1 on MPX to the hole on the breadboard near A0 (analog channel) of the ADS115. This is the Vout. The voltage we get from the pressure sensor (we'll convert it to pressure units on the coding stage).
  • Pin 2 to the left blue rail (GND).
  • Pin 3 to the left red rail (5V). This is the voltage supply. Surprisingly the MPX5100 needs 5v to work.

Repeat these connections for the second pressure sensor. But this time, connect Pin 1 on MPX to A1.

If one needs more info on the sensor, take a look at the attached data sheet.

That's it for the electronics. Get your Arduino IDE running to start coding!

Step 7: Upload the Code to Your ESP32

Get your Arduino environment set up for the ESP32. There are many tutorials online.

Go over the sketch we have on our GitHub (it's well commented). Update the WIFI and ThingSpeak credentials. Make sure you installed the libraries needed (see top of the sketch).

Link to the GitHub for the sketch: https://github.com/deedeeharris/agritech2021/blob/...

COMPILE and UPLOAD :)!

Step 8: Test the Code and Calibration of Sensors

This step is a must.

You may encounter errors during the 'upload' to your board. Read the errors that the IDE shows, and share with us if you have a problem.

Calibration of sensors should be done for the scale and for the pressure sensors. For the scale you can get reading for a set of known weights (100 grams, 200 grams, 300 grams, etc.), and then create a linear regression to understand the offset. Same for the pressure sensors, though to do that you need a machine that can generate specific pressure values.

Step 9: Tensiometers and Soil Saturation

Since we're building a saturated soil hydraulic conductivity meter, we must saturate the soil and tensiometers in advance.

Soil saturation

Choose a soil sample (we took sandy soil) and weigh it with a lab\kitchen scale.

Insert the ring with soil in a large plastic bowl, and add around 1.5 liters of water to the bowl. Don't pour the water on the soil! Soil saturation is done by suction forces of the soil - the soils pulls the water up through the holes drilled in the bottom of the ring. Cover the top of the ring, so the water won't evaporate during the process. It should take around a day for the soil to saturate (depends by the soil type).

Saturating the Tensiometers

Use a plastic syringe and a short silicone tube to saturate the tensiometers. Insert the tensiometer (connected to the syringe with a tube) in a cup of water, and pull the syringe, while the ceramic cup is in the water. With a small wooden peg hold the syringe's top so it won't return down. Repeat this step for both tensiometers. It should take around 24-48 hours for full saturation (sign of success - tensiometer will be full with water, and some water will enter the syringe).

Step 10: The Experiment - Finally!

Saturation has completed successfully. It's time to start sensing :D!

Measure the weight of the saturated soil in the ring. Cover the bottom of the ring with some plastic wrap, so water won't escape from bottom - water should be left from soil only due to top evaporation.

Remove the tensiometers from the syringes and connect them to the pressure sensors using a short silicone tube. Make sure no water enters the sensor, since any liquid can damage it.

Place the ring on the scale. Power up the ESP32.

Let your SHC Meter start to work. Take a look at your ThingSpeak channel for live measurements.

Step 11: Analyzing the Data in Python

Using Google Colab is a great way to analyze the data and summarize your report.

Markdown and Python work well together in Colab. Start by importing the relevant libraries: pandas, numpy, matplotlib.pyplot, seaborn, urllib3, json and time.

Attached is a screenshot of readings from our sensors uploaded to ThingSpeak. We use the Android App 'ThingView' to see the reading comfortably on the cellphone.

Check at our GitHub for the full Python code for plotting the 'Soil Retention Curve' and 'Soil Hydraulic Conductivity Graph': https://github.com/deedeeharris/agritech2021

Step 12: Summary and Optional Tweaks

Summary

Building this project was a great experience for us. We encountered a few 'unplanned surprises' during the experiment.

Take a look at our GitHub for the final report: https://github.com/deedeeharris/agritech2021


Optional Tweaks:

  • Connect the ESP32 to a power bank (and the power bank to the wall) to prevent loss of measurements if there's a power outage.
  • Add an RTC module - without depending on the internet for getting the time (good when there's no internet).
  • Add a MicroSD module - to save measurements locally (working offline).
  • Add a LCD screen to see live measurements instead of the local HTTP server.

Now it's your turn to build the SHC Meter. Go for it! Don't hesitate to post questions and other comments.

Arduino Contest

Participated in the
Arduino Contest

Be the First to Share

    Recommendations

    • Sewing Challenge

      Sewing Challenge
    • Halloween Contest

      Halloween Contest
    • Micro:bit Contest

      Micro:bit Contest

    3 Comments

    0
    GiladBenIsrael
    GiladBenIsrael

    4 months ago

    Sounds great! Keep us updated with the results.

    0
    yehudayu
    yehudayu

    4 months ago

    Wow! This is one of the best and most detailed tutorials I have seen. Thanks for the details and steps. I'll use it soon!

    0
    seamster
    seamster

    4 months ago

    Very good, thanks for adding all the details and steps! : )