Soil moisture sensor SMT50 and Arduino

The SMT50 by TRUEBNER is perfectly suited for the Arduino. The wiring is shown in the picture above.

  • brown: 3.3 V - 30 V
  • white: ground
  • green: temperature (voltage output with 10 kOhm output resistance)
  • yellow: moisture (voltage output with 10 kOhm output resistance)

Arduino code is also pretty simple, just read the analog voltages as shown in the code snippet below:

const int measurements = 50;

float temperatureArray[measurements];
float sensorValueTemperature = 0.0;
float moistureArray[measurements];
float sensorValueMoisture = 0.0;

for (int i = 0; i < measurements; i++)
{
    temperatureArray[i] = analogRead(A0);
    moistureArray[i] = analogRead(A1);
}
 
for (int i = 0; i < measurements; i++)
{
    sensorValueTemperature += temperatureArray[i];
    sensorValueMoisture += moistureArray[i];
}


sensorValueTemperature = sensorValueTemperature / measurements;
sensorValueMoisture = sensorValueMoisture / measurements;

sensorValueTemperature = sensorValueTemperature*3.3/1024;
sensorValueMoisture = sensorValueMoisture *3.3/1024;
 
sensorValueTemperature = (sensorValueTemperature-0.5)*100;
sensorValueMoisture = sensorValueMoisture *50/3;
 
sensorValueTemperature = sensorValueTemperature*10;
sensorValueMoisture = sensorValueMoisture*10;

Please note that I measured 50 times the same analog channel and calculated the mean value to reduce any noise which may appear. The Arduino analog digital converter uses 3.3 V reference voltage. With 10 bit resolution you have 1024 steps. I first calculated the voltage, e.g. from

sensorValueTemperature = sensorValueTemperature*3.3/1024;

and then convert voltage into moisture according to the datasheet ( 0 V = 0% moisture, 3 V = 50 % moisture)

sensorValueMoisture = sensorValueMoisture *50/3;

 

Tag: soil moisture sensor