Measure Soil Moisture with ADI's ADICUP Evaluation Board
2017-06-15 | By All About Circuits
License: See Original Project
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
- Analog Devices EVAL-ADICUP360
- Analog Devices CN0398
- Capacitive moisture sensor
- 2 micro USB cables
- PC
- A plant & some water
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
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 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.
#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!
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.
Visit TechForum