Garduino - Understanding the SHT10
Moderators: adafruit_support_bill, adafruit

Garduino - Understanding the SHT10

by uflnuceng on Sun Jan 12, 2014 10:17 pm

Hello again,

I'm plugging away with the SHT10 Soil temperature/moisture sensor (http://www.adafruit.com/products/1298), and I'm trying to understand some things about it.

First, my code:

Code: Select all | TOGGLE FULL SIZE
#include <SHT1x.h>
#define dataPin 10
#define clockPin 11
SHT1x sht1x(dataPin, clockPin);

#include <Wire.h>
#include "RTClib.h"
#include "DHT.h"

#define DHTPIN 2

RTC_DS1307 RTC;

#define DHTTYPE DHT22   // DHT 22  (AM2302)

DHT dht(DHTPIN, DHTTYPE);

void setup(){
  Serial.begin(57600);
  Wire.begin();
  RTC.begin();
  dht.begin();

  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    //RTC.adjust(DateTime(__DATE__, __TIME__));
  }
  Serial.println("Starting up");
}

void loop(){

  DateTime now = RTC.now();

  float temp_c;
  float temp_f;
  float humidity;

  float h = dht.readHumidity();
  float t = dht.readTemperature();

  // Read values from the sensor
  temp_c = sht1x.readTemperatureC();
  temp_f = sht1x.readTemperatureF();
  humidity = sht1x.readHumidity();

  // Print the values to the serial port
  Serial.print(now.unixtime());
  Serial.print(" ");
  // check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t) || isnan(h)) {
    Serial.println("Failed to read from DHT");
  }
  else {
    Serial.print("Air H: ");
    Serial.print(h);
    Serial.print("% ");
    Serial.print("Air T: ");
    Serial.print(t);
    Serial.print(" *C ");
  }
  Serial.print("Soil T: ");
  Serial.print(temp_c, 2);
  Serial.print("C ");
  Serial.print("Soil H: ");
  Serial.print(humidity);
  Serial.println("%");
}


I have the SHT10 and the DHT22 hooked up on the breadboard so I can compare the data. Here is when I started the code up

Code: Select all | TOGGLE FULL SIZE
Starting up
1389561344 Air H: 41.10% Air T: 20.70 *C Soil T: 21.08C Soil H: 44.33%
1389561346 Air H: 41.10% Air T: 20.70 *C Soil T: 21.07C Soil H: 44.33%
1389561348 Air H: 41.10% Air T: 20.70 *C Soil T: 21.07C Soil H: 44.30%


Both the SHT10 and the DHT22 are near each other, exposed completely to air. Pretty close in temp and humidity.

Then, I placed the probe into soil, which I wouldn't say was moist, but the probe appeared to think otherwise.

Code: Select all | TOGGLE FULL SIZE
1389561615 Air H: 41.20% Air T: 20.90 *C Soil T: 22.65C Soil H: 93.52%
1389561617 Air H: 41.10% Air T: 20.90 *C Soil T: 22.68C Soil H: 93.53%
1389561619 Air H: 41.10% Air T: 20.90 *C Soil T: 22.71C Soil H: 93.58%


Then I started adding water, about 15 mL at a time and initially the reading would go down by more than 10% RH! I'm guessing because the moisture in the soil pulls the moisture away from the tube, but then would start to go back up. When i completely saturated the soil, it never went above 97%. I took it out of the soil, dried it off with a paper towel, left it on the table as I had in the beginning and it was reading 35% RH! I let it rest for awhile and the SHT10 finally came back up to 42% RH, close to the DHT22.

So, just leaving this here for people interested in the SHT10 and how it works, and how your data might look. I'm guessing I was asking too much from it too quickly, as in the casing retains some moisture for long periods of time. I'm going to use something really dry, like maybe sugar or something, see what the data looks like. When the wife isn't around, maybe I'll bake some soil for a long time till it's really dry, and start fresh.

My inquiries to the Adafruit Gods are, what interval of sampling do you think is appropriate, because obviously even once ever second or so is too frequently. Have you ever used this probe yourself in what you would consider dry soil? What did you get for RH? I'm sure it will always be a little bit higher than the air's RH at the very least. For me to find the right values in which I wish to use this to open a water solenoid, I'm going to need a lot of data and from the looks of things, it won't come quickly unless I have some really thirsty plants.
uflnuceng
 
Posts: 25
Joined: Wed Nov 20, 2013 11:03 am

Re: Garduino - Understanding the SHT10

by adafruit_support_bill on Mon Jan 13, 2014 6:35 am

I've done a few humidity sensor projects (mostly SHT-11) and my sample times were in the 5-10 second range. You could probably get by with once every 5-10 minutes. But if the processor doesn't have anything better to do, it doesn't hurt to oversample.

I haven't done much with soil humidity monitoring. But on many occasions I have pitched a tent on what seemed to be bone-dry ground. And in the morning, the bottom of the tent would always be wet with condensation.
User avatar
adafruit_support_bill
 
Posts: 29144
Joined: Sat Feb 07, 2009 9:11 am

Re: Garduino - Understanding the SHT10

by uflnuceng on Wed Jan 15, 2014 10:49 am

I think I should go buy a plant that is already alive and can survive without much light and take some data points with it. I read up on your tutorial using Carriot. I have an ethernet shield with SD card, so maybe I'll just have it write to a data file on the card and review it. I'm going to need a couple weeks worth of data to really see what is going on with this sensor. Hope its ok that I post an experiment on this sensor on your forums as I think it would be really helpful to know how this sensor really displays data.
uflnuceng
 
Posts: 25
Joined: Wed Nov 20, 2013 11:03 am

Re: Garduino - Understanding the SHT10

by uflnuceng on Tue Mar 04, 2014 11:44 am

Ok, using the code above, I setup a DHT22 and an SHT10 as you can see in the image below. The DHT22 was used to give me ambient air temp and relative humidity, while the SHT10 was placed in different media to determine 1) its speed of change, 2) reliability of data reported, 3) consistency of results.

Board and sensor layout:
20140116_102856.jpg
board layout
20140116_102856.jpg (33.48 KiB) Viewed 694 times


When the sensor was exposed to the air, this is the comparative data between the DHT22 (Air H & T) and the SHT10 (Soil T & H) in increments of about every 4 seconds.
Code: Select all | TOGGLE FULL SIZE
1389868330 Air H: 16.30% T: 23.40 *C Soil T: 23.43*C H: 18.31%
1389868334 Air H: 16.40% T: 23.40 *C Soil T: 23.43*C H: 18.28%
1389868338 Air H: 16.40% T: 23.50 *C Soil T: 23.45*C H: 18.24%
1389868342 Air H: 16.40% T: 23.40 *C Soil T: 23.46*C H: 18.17%
1389868346 Air H: 16.70% T: 23.50 *C Soil T: 23.46*C H: 18.17%
1389868350 Air H: 16.70% T: 23.40 *C Soil T: 23.47*C H: 18.24%
1389868354 Air H: 16.70% T: 23.40 *C Soil T: 23.48*C H: 18.32%
1389868358 Air H: 16.70% T: 23.50 *C Soil T: 23.48*C H: 18.39%
1389868362 Air H: 16.60% T: 23.40 *C Soil T: 23.49*C H: 18.39%
1389868366 Air H: 16.70% T: 23.40 *C Soil T: 23.50*C H: 18.36%
1389868370 Air H: 16.60% T: 23.40 *C Soil T: 23.50*C H: 18.36%
1389868374 Air H: 16.70% T: 23.40 *C Soil T: 23.52*C H: 18.39%
1389868378 Air H: 16.80% T: 23.40 *C Soil T: 23.52*C H: 18.39%
1389868382 Air H: 16.80% T: 23.40 *C Soil T: 23.53*C H: 18.39%


Temperature was very consistent, and humidity differed within the margin of error of the sensor (+/- 1.5%).

I then placed the SHT10 sensor in some dry soil that hasn't had a plant in it for a very long time.

As it should be expected, the soil was very dry, but being hydroscopic it contained a little bit more humidity than the air around it (23.4% relative humidity versus ambient air's 15.6%).

20140116_102912.jpg
dry soil
20140116_102912.jpg (37.4 KiB) Viewed 694 times


Code: Select all | TOGGLE FULL SIZE
1389870778 Air H: 15.70% T: 23.30 *C Soil T: 23.24*C H: 23.41%
1389870782 Air H: 15.50% T: 23.30 *C Soil T: 23.25*C H: 23.45%
1389870786 Air H: 15.50% T: 23.30 *C Soil T: 23.24*C H: 23.41%
1389870790 Air H: 15.60% T: 23.30 *C Soil T: 23.24*C H: 23.45%
1389870794 Air H: 15.60% T: 23.30 *C Soil T: 23.25*C H: 23.41%


I then picked a plant that the office didn't mind me killing. I let it go without water for a few days, although by the finger touch the soil was still damp.

20140116_111510.jpg
plant
20140116_111510.jpg (59.82 KiB) Viewed 694 times


I then set the sensor to record every 5 minutes for several weeks and this is the resulting graph of that data. (To Be Continued after lunch!)
uflnuceng
 
Posts: 25
Joined: Wed Nov 20, 2013 11:03 am

Re: Garduino - Understanding the SHT10

by uflnuceng on Tue Mar 04, 2014 1:51 pm

Ok, so lunch was disappointing, but I move on.

Here is a graph of the data from the two sensors, relative humidity on the left axis, temperature in degrees Celsius on the right, and interval number on the bottom (the intervals are in increments of 5 minutes, so 9165 total increments means 31.8 days of data!)

Soil Moisture Analysis.jpg
Graph
Soil Moisture Analysis.jpg (61.81 KiB) Viewed 688 times


You can see that at the beginning, soil moisture is at about 86% and then I water the plant, which causes the sensor to dip down to about 82% rather quickly. I'm assuming this has to do with the capillary effect pulling water away from the sensor into the soil, but within 20 minutes (4 recordings) the sensor shoots up 14% and keeps going. I had filled the potted plant till there was marginal runoff out the bottom of the pot. It then maintained a consistent 102% moisture level (obviously bogus, but we can use it as a differential starting point) for a little more than two weeks when it starts to slowly decrease. At this point the soil is kinda dry, but only about an inch down there is water. By the time the sensor reaches 90% I would definitely consider the plant needing water. It hadn't lost any color but the top was significantly dry in my modest opinion. Forward to today, the relative humidity is around 68% and the plant, although alive, looks pale and the soil seems to be very dry and I can easily dig my fingers into it up to my third knuckle.

The temperature data is interesting because it shows the cold water (purple line) within a couple days returning to close to room temperature. The soil temperature then fluctuates proportionally with room temperature, but was is REALLY interesting to me is that as the soil dries out, the difference between the soil temperature and the air temperature becomes less. As soon as the soil moisture starts to decrease from 100% my calibrated eyeball seems to see the soil temperature rising to meet the air temperature. Very interesting in my opinion.

So, all in all, I'm pleased with this sensor. Like everything it requires some calibration, and although I believe that depending on the soil medium you plant it in (sandy loose soil vs thick clay vs peat moss and vermiculite) you will have different calibration needs, ultimately using the data provided, I would say once the sensor has crossed outside 5-10% of the maximum (in this case 102%), that I would set my system up to either alert me to water the plants, or open up water solenoids to do it for me. Also, if the difference between the soil temperature and air temperature is only a few tenths of a degree celsius, I would probably trigger something as well, or at least shoot at a warning for me to investigate.

I hope those looking for soil sensors find this helpful. I feel this one gives you valuable data that is useful in tending to a greenhouse.
uflnuceng
 
Posts: 25
Joined: Wed Nov 20, 2013 11:03 am

Re: Garduino - Understanding the SHT10

by adafruit_support_bill on Tue Mar 04, 2014 2:26 pm

Nice work! Thanks for posting your results. :)
User avatar
adafruit_support_bill
 
Posts: 29144
Joined: Sat Feb 07, 2009 9:11 am

Re: Garduino - Understanding the SHT10

by uflnuceng on Wed Mar 05, 2014 12:55 pm

Thought I would throw together one more graph, this one of the Absolute Percent Difference [ = abs(soil - air)/((soil + air)/2) * 100 ] and the Running Average of the Absolute PD. I don't know about you, but that Running Average looks delightfully linear. I'm definitely going to play with this data set a lot.

Temperature analysis.jpg
Temperature Analysis
Temperature analysis.jpg (50.42 KiB) Viewed 671 times
uflnuceng
 
Posts: 25
Joined: Wed Nov 20, 2013 11:03 am

Re: Garduino - Understanding the SHT10

by Geekskunk on Thu May 22, 2014 8:35 pm

@uflnuceng, found your posts and soil moisture graph helpful to understand why I am seeing similar behavior.

Perhaps my expectations on the SHT10/11 are misplaced, but what is lauded as a positive feature in the soil moisture graph (near 100% soil humidity for 20 plus days until soil extremely dry) seems rather unhelpful.

I might add, I'm on my second sensor at this point....

My first Soil/Moisture Sensor (https://www.adafruit.com/products/1298) was placed under the soil as the tutorial depicts, and was giving the same 98+ humidity readings you noted for almost two weeks, soon the temperature readings skyrocketed to false values. I removed that sensor suspecting it failed.

Now on my second, I'm much less inclined to bury in soil completely in-case that led to it's premature demise. I also found the constant high humidity readings unhelpful to determine when to water.

I currently have the sensor laying on the top of soil (sensor perpendicular to soil) , it gives fluctuating humidity during the day, of which I assume is some mix of air and nearby soil humidity. The fluctuations are unhelpful.

Calibrating is mentioned in your post, but what is to calibrate if the humidity barely budges under soil for weeks? There is no helpful movement to track. I'd also suspect your plant needed water prior to the soil moisture reading dropping so dramatically.

I'm starting to think the SHT11, is not actually helpful as a soil sensor. Please convince me otherwise or how I might go about using this sensor to aid in determining soil dryness for purpose of watering.
Geekskunk
 
Posts: 3
Joined: Thu May 22, 2014 8:09 pm

Re: Garduino - Understanding the SHT10

by darkunderlord on Mon May 26, 2014 8:55 pm

I have to agree. I find that with my sensor mostly in the soil, it shows 100 percent humidity. Taking it completely out of the soil for 20 minutes leaves it at only 60 percent. For 50 dollars I was hoping to get a more accurate or at least useful read.
darkunderlord
 
Posts: 2
Joined: Mon May 26, 2014 8:54 pm

Re: Garduino - Understanding the SHT10

by Geekskunk on Mon May 26, 2014 9:08 pm

Got my sensor data online at xively now. The soil_moist feed shows the daily up/down in moisture that I think is a inaccurate mix from having the sensor on-top of the soil:

https://xively.com/feeds/1824193320

At best I can look at the low value during the day and hope it is somewhat accurate, but I think as air humidity levels rise in my area that won't be possible either. Better than 100% all the time if it was in the soil at all.

Hoping someone from Adafruit reads and has suggestion for more helpful use. Starting to believe it should not be marketed as soil sensor.
Geekskunk
 
Posts: 3
Joined: Thu May 22, 2014 8:09 pm

Re: Garduino - Understanding the SHT10

by adafruit_support_mike on Mon May 26, 2014 11:41 pm

The sensors measure air humidity, which is different from the moisture content of soil.

Soil moisture content is a literal thing: you put a sample of soil on a scale in a cryogenic vacuum chamber and freeze dry it. The difference between the starting and ending weights was the moisture content by weight.

Air humidity is the amount of water vapor in the air, which depends on pressure and temperature. Relative humidity is the amount of water vapor actually in the air compared to the maximum amount theoretically possible at that pressure/temperature. 100% relative humidity means standing water cannot evaporate into the air, and lowering the temperature of air at 100% humidity causes water vapor to turn into liquid water. The temperature at which the water vapor currently in the air would begin to turn into liquid water is called the 'dew point'.

The air humidity inside a porous material soaked with water remains near 100% because that's the physical equilibrium for the system. If the air humidity is lower than 100%, liquid water in the pores of the material can evaporate into the air, so it will. Since there's very little air movement inside a porous material, the air will stay in one place absorbing water vapor as long as it can.

Water in the pores of the material only stops evaporating when one of two conditions exists: the air can't hold any more water vapor, or the material can't release any more water vapor into the air. The first condition is 100% air humidity. The second condition occurs when the liquid water in the material is mostly gone, and what's left is held in ways that make it harder to evaporate (adsorption, chemical bonding, chelation, etc).

The simplest but roughest way to estimate soil moisture content is to bury the sensor deep and watch for the point where the air humidity drops below 100%. That means the soil can no longer release enough water to bring the air humidity up to 100%.

A more difficult but more nuanced way to estimate soil moisture is to bury the sensor near the surface of the soil and watch how the air humidity rises and falls with temperature. The air above the surface of the soil is free to move, taking evaporated water away with it. That depletes the soil moisture at the surface, which has to be replaced by capillary action and diffusion of 100% humid air from deeper in the soil. The amount of change in the air humidity near the surface will tell you how fast moisture is leaving the soil and how fast it's being replaced.

If the soil is saturated to the point where capillary action (liquid water transport) replaces most of the water lost at the surface, the air humidity shouldn't drop very far, and should rise to near 100% quickly once the temperature goes down again. When the deep soil moisture content falls to a level where the moisture lost at the surface has to be replaced by diffusion of water vapor through the air (vapor transport), the drops in surface air humidity should become larger and last longer.

There are a *lot* of free variables in that model.. depth to which the sensor is buried, dimensions and shape of the container, ambient temperature and temperature swing, exposure to non-thermal energy (sunlight), rate of air flow at the surface of the soil, composition of the soil, how tightly the soil is compacted, etc. It's all stuff you could isolate and characterize in a lab setting though, and a bit of general tinkering should lead you to a configuration that provides useful information.
User avatar
adafruit_support_mike
 
Posts: 9162
Joined: Thu Feb 11, 2010 1:51 pm

Re: Garduino - Understanding the SHT10

by Geekskunk on Tue May 27, 2014 11:14 am

Very informative response, thank you. I think it has helped to confirm the SHT10 "Soil" Sensor is not the right tool for users (like myself) looking to casually monitor soil moisture; and not conduct a science experiment. While I agree a lab setup would help characterize, the real (world) outdoor garden is my current environment. Going to have to stand with my last post that the marketing as a soil sensor may be somewhat misleading. I might suggest 'weather-resistant temperature and humidity sensor'.

A more conventional analog probe setup seems more likely to be helpful for the majority trying to determine real-time watering needs.
Geekskunk
 
Posts: 3
Joined: Thu May 22, 2014 8:09 pm

Re: Garduino - Understanding the SHT10

by egutting on Tue May 27, 2014 1:16 pm

I've found this conversation very informative myself. I have automated my greenhouse and was originally thinking of using these sensors to measure soil moisture, but at $50 a piece, it wasn't really cost effective when I have 8 citrus trees to keep an eye on. I have since built my own analog sensors out of PVC pipe and 12 guage electrical wire. If you're interested in seeing how I did this you can see here: http://blog.cup-of-joe.me/?p=110 I have since removed the light sensor and moved down to 1.25 inch pipe parts.
egutting
 
Posts: 198
Joined: Tue Nov 13, 2012 11:57 pm

Re: Garduino - Understanding the SHT10

by darkunderlord on Tue May 27, 2014 10:03 pm

I really don't think this should be marketed as a moisture sensor then. Two nails telling me whether it's able to generate electricity or not is a better measure for damp or dry soil. Not too happy about spending this much for something that has too many factors to be trusted.
darkunderlord
 
Posts: 2
Joined: Mon May 26, 2014 8:54 pm

Re: Garduino - Understanding the SHT10

by DrSproc on Sat May 31, 2014 1:30 am

I turned to the Arduino's capacitance library as a great solution for measuring soil moisture. (Great post by DrX http://bit.ly/1nCT6iI ) Soil moisture measuring this way is almost instantaneous (capacitance dielectric field). This build can measure soil moisture, soil temperature(DS18B20), ambient temperature, humidity(DHT22) and even sunlight intensity, all managed by an Arduino Uno and Adafruit's data logger shield which also has an RTC for time. The data is saved to a micro-SD card (Yay Ladyada) and is also transmitted to my home database server via a pair of Xbees Series 1. This video I found on youtube demonstrates how well and fast capacitance sensing works. ( http://bit.ly/1hI8JgT All you really need are two insulated copper plates). Its so sensitive I can even measure the moisture of my hands. I had the capacitance sensor probes made by a great service for hobbyists @ (Laen's http://dorkbotpdx.org/wiki/pcb_order now - http://oshpark.com/ - DorkbotPDX ), and then using some of my wife's clear nail polish I still gave it another coat to make sure the plates were well insulated from the soil. Note how fast the graph reacts when the plant was watered :) I messed around with other sensors such as resistive and or humidity but couldn't get consistent readings and they took a while to react besides they required re-calibrating way too often. I think part of the problem with these other direct reading sensors is that they need to react with the soil and moisture to measure it, and you run in to all sorts of problems with reactive corrosion. Capacitance merely measures effects on its field between plates. I also found resistive type sensors would measure differently depending on which side I applied voltage when the circuit was in a voltage divider configuration. During some of my experiments, these resistive sensors would even turn into batteries themselves and I'd even find negative voltages countering divider bias... Next is sending data off to xively... this services give you triggers on thresholds for custom alerts... How cool is that... plants that can call you up when unfavorable conditions arise... lol...
Attachments
cappy_sensor.jpg
cappy_sensor.jpg (95.68 KiB) Viewed 176 times
Last edited by DrSproc on Sat May 31, 2014 7:57 am, edited 9 times in total.
User avatar
DrSproc
 
Posts: 8
Joined: Sat Apr 14, 2012 10:06 am