The best tools to make your project dreams come true

Login or Signup
USD


By All About Circuits

Measure Soil Moisture with ADI's ADICUP Evaluation Board

Courtesy of All About Circuits -

Now that Summer is beginning, I needed a way to make sure Debra 2, my houseplant stays watered. I constructed this soil moisture sensor circuit to send me a message whenever Debra 2 needs water! I call this system, the Little Shop of Moisture!

 

Bill of Materials

Why?

I have a very busy schedule and I always forget that Debra 2 needs extra water this time of year. With this moisture sensor, I am notified whenever Debra 2’s pot is dry so she doesn’t get hangry!

Feeding Debra 2

Feeding Debra 2

How Does it Work?

Using an Analog Devices microcontroller and moisture sensor shield, I can plug a capacitive moisture sensor into the shield in order to receive data from my plant. A capacitive moisture sensor measures moisture with capacitive sensing rather than resistive sensing. This means that our sensor is resistant to corrosion and lasts longer in wet environments like soil!

The sensor will output an analog voltage that is inversely related to our moisture level. This means that with more moisture comes less voltage. Because of this characteristic, we can use our sensor with any microcontroller or accessory that supports analog inputs, like the CN0398 moisture shield. The moisture shield interprets the analog data from the sensors via the shield’s ADC and transmits the data to the microcontroller via SPI communication. Fortunately, ADI created some example codes for their eval boards, so the hard work was already done for us.

The wiring for this project is pretty simple

The wiring for this project is pretty simple!

The output of the sensor ranges from 0 to 3.3V. I divided the data range in the code into three segments that correspond with “Dry”, “Moist”, and “Wet. These ranges display on the serial monitor as “FEED ME”, “A LITTLE MORE”, and “SATISFIED.” You can see an example of this is in the code snippet below.

Copy Code
#ifdef USE_MANUFACTURER_MOISTURE_EQ
if(volt <= 1.1) {
moisture = printf("Satisfied");
} else if(volt > 1.1 && volt <= 1.82) {
moisture = printf("A little more");
} else if(volt > 1.82) {
moisture = printf("FEEED MEEEE");
}

To run this program, the easiest way is to use two micro USB cables. One cable is plugged into the user port to debug and upload data, and the other is used to monitor results. After you plug in your cables, you’ll want to open the Eclipse IDE. Inside the IDE, open up the example code and run a debugging session. Analog Devices has a tutorial for this on their website along with more tutorials for ADICUP eval board. When the debugging is complete, you will need to hit stop.

Next, you’ll want to open your favorite serial monitor program and set the proper COM port and baud rate, in this case, 115200. You should see the data start flowing instantly. Your screen should read “FEEEED MEEEE” when the soil is dry and “Satisfied” when the soil is wet. You can change the code to say whatever you would like.

Happy gardening… or happy making!

Key Parts and Components

Add all Digi-Key Parts to Cart
  • EVAL-ADICUP360-ND
  • EVAL-CN0398-ARDZ-ND
  • 1738-1184-ND
  • AE11229-ND