4

I have soil Moisture sensor inserted into the pot soil, wet in state. (not too damp) and soil moisture sensor is connected to Arduino Mega 2560.

This is the soil moisture sensor I am using:

Analog Soil Moisture Sensor

Soil Moisture Sensor VCC is fed by 4.95 coming from Mega's 5 volt power out and soil moisture signal is connected to A0.

below are the readings

+---------------------+-------------------+-----------------------+
| timeStamp           | pot1_soilMoisture | pot1_avg_soilMoisture |
+---------------------+-------------------+-----------------------+
| 2017-01-26 14:31:19 |               825 |                    80 |
| 2017-01-26 14:32:19 |               816 |                    80 |
| 2017-01-26 14:33:20 |               828 |                    83 |
| 2017-01-26 14:34:20 |               826 |                    82 |
| 2017-01-26 14:35:20 |               820 |                    79 |
| 2017-01-26 14:36:20 |               833 |                    83 |
| 2017-01-26 14:37:20 |               463 |                    46 |
| 2017-01-26 14:38:21 |               546 |                    32 |
| 2017-01-26 14:39:21 |               156 |                    26 |
| 2017-01-26 14:40:21 |               157 |                    22 |
| 2017-01-26 14:41:21 |               509 |                    23 |
| 2017-01-26 14:42:22 |               204 |                    25 |
| 2017-01-26 14:43:21 |               226 |                    26 |
| 2017-01-26 14:44:21 |               190 |                    30 |
| 2017-01-26 14:45:22 |              1023 |                    84 |
| 2017-01-26 14:46:22 |               604 |                    83 |
| 2017-01-26 14:47:22 |               773 |                    79 |
| 2017-01-26 14:48:22 |              1023 |                    80 |
| 2017-01-26 14:49:23 |               599 |                    77 |
| 2017-01-26 14:50:23 |               766 |                    82 |
| 2017-01-26 14:51:23 |               579 |                    81 |
| 2017-01-26 14:52:23 |               729 |                    74 |
| 2017-01-26 14:53:24 |              1023 |                    82 |
| 2017-01-26 14:54:24 |               795 |                    80 |
| 2017-01-26 14:55:24 |               651 |                    77 |
| 2017-01-26 14:56:24 |               765 |                    83 |
| 2017-01-26 14:57:25 |              1023 |                    81 |
| 2017-01-26 14:58:25 |                 0 |                    60 |
| 2017-01-26 14:59:25 |               921 |                    30 |
+---------------------+-------------------+-----------------------+
1439 rows in set (0.02 sec)

I got three kind of readings of the sensor:

  • pot1_soilMoisture reading from 825 to 833 is when the sensor was dipped in water.
  • pot1_soilMoisture reading from 463 to 190-1023 is when soil moisture sensor was in air.
  • pot1_soilMoisture reading from 604 to last 921 is when soil moisture sensor is in soil. The soil is moist/wet.

I don't understand how to be definitive state of soil with such values?

2

I had this same problem when I began experimenting with soil moisture readings. I noticed that the readings from the sensor can vary widely when not hooked up correctly, or when other nearby objects are somehow interfering.

For instance when I put a SparkFun breakout similar to yours in dry soil and continuously take readings every 50ms, the signal oscillates from 0 to 50, and simply touching the soil with my finger can affect the signal due to the electricity in my body. If you have a metal pot on a metal table, that could be affecting your readings. There's a lot to consider!

However, once I water the soil and let it soak in, the reading generally becomes much more stable. Below I included a real-time plot using a plant I watered about 24 hours ago. Here's how I set up my soil moisture sensor, including code. The readings are taken every 60s and the plotter repeats the old reading until a new one is taken. There's very little deviation when all connections are secure and the soil moisture is evenly distributed.

Arduino IDE Serial Plotter output showing a consistent reading between 875 and 877

In general, the specs for the sensor will inform you on what kind of signal to expect. Based on your sample data I suspect yours is a 10-bit signal from 0-1023, so 800 range means the soil is quite moist. If you just watered the plant, then the water content around the sensor will change as it seeps through the soil, leading to fluctuations when measuring. Give the soil a few hours to absorb the moisture and try measuring again.

  • Oh well thanks, I will use this strategy and see how it goes however, I have hooked up a realtime clock module using which I give water to pot for 10 seconds(enough for small pot) twice a day . And I think there really isn't need to set up a powering solenoid to water pot based on soil moisture . Thanks for your answer – Ciasto piekarz Jan 26 '17 at 11:46
  • I agree, for potted plants this is over-doing it. Still useful to learn how the sensor works. I think if you have a large number of plants in a raised bed this is a more useful technique for regulating water automatically. – Chris Ruppel Jan 26 '17 at 15:10
  • Cool, now I have setup as per your answer, but millis instead of delay and now I am turning on soil moisture sensor using digital pin 8 . But so far I still can't make out huge distinction between when it is dipped in water or out in air or in soil – Ciasto piekarz Jan 26 '17 at 15:15
  • Do you have a second sensor to test? Or any other component that could use the same pins on your Arduino, so that you can verify that something works as intended? It's difficult to troubleshoot without some sort of reliable baseline. I did a search for your sensor and the example output on the official tutorial page seems to wildly fluctuate just like your sample data. The page doesn't provide specs so we can't be sure how it should be powered. Perhaps you could try powering with 3.3V instead of 5. – Chris Ruppel Jan 27 '17 at 8:59
  • for experimenting I connected it to Arduino Uno and got this result : pastebin.com/1jDV0kjv with delay of 600 milieseconds, I found lower the delay more incorrect values but it seems to oscillates which I feel needs calibration that I dont know how to do it ! – Ciasto piekarz Jan 28 '17 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.