Build a Soil Moisture Sensor with the ADICUP Evaluation Board from Analog Devices

June 15, 2017 by Ryan Jones

With all this hot weather this summer, we need to keep our plants well-fed. That's where the Debra 2 Moisture Sensor comes in!

With all this hot weather this summer, we need to keep our plants well-fed. That's where the Debra 2 Moisture Sensor comes in. Welcome to the Little Shop of Moisture Sensors!



Ever since the summer came around, Debra 2 has been extra hungry! With my busy schedule, I couldn't keep her as well fed as I should have. To help, I built a moisture sensor that can measure the moisture level of her soil and notify me anytime she needs more water. She tends to get a little hangry from time to time, so this helps!


Feeding the Debra 2


Using an Analog Devices microcontroller and an AD moisture shield, I can plug a capacitive moisture sensor into the shield and receive data from my plant. Capacitive moisture sensors measure moisture with capacitive sensing rather than resistive sensing. This means that they are resistant to corrosion and will last longer in wet environments, like our soil!

The sensor outputs and analog voltage inversely related to the moisture level. This means the more moisture, the less voltage. Because of this characteristic, we can use our sensor with any microcontroller or accessory that supports analog inputs, like our moisture shield. The CN0398 shield interprets the sensors analog data via the shields ADC and transmits this to the microcontroller via SPI communication. Lucky for us, this project was created from some example code so all the hard work was done.


The sensors wires plugged in accordingly

The sensor's output ranges from 0-3.3V. Within the code, I divided this range into three separate segments that correspond to the three moisture categories: "Feed me", "A little more", and "Satisfied". In other words, "dry", "moist", and "wet". When the analog voltage is between any range of specific values, one of the responses will be displayed in our serial monitor. A snippet of the example code can be found below.

    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 our program, it is easiest to use two micro USB cables: one plugged into the user port for debugging/upload and the other for monitoring our results. After plugging in your cables, you will first want to open the AD Eclipse IDE. Within this program, open the example code and run a proper debugging session as shown on the Analog Devices site. When it's complete you'll need to hit stop.

Open your go-to serial monitor program and set the proper COM port and baud rate, ours being 115200. Instantly, you should see the data flow. If the soil is dry, the screen will read "FEEEED MEEEE" and if it's wet it will read, "Satisfied". Change this however you want but always be sure to listen to your Debra 2 as she may get aggressive. Happy gardening making!


A glimpse at my live results

Give this project a try for yourself! Get the BOM


Other MIT-i Innovations: