This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Interfacing soil moisture sensor



Hi,

 

I'm starting the development of a wireless sensor network using the ez430-rf2500 kit. My goal is to measure soil humidity with a soil moisture sensor in each device of the network. The soil moisture sensor i'm using is the following: http://www.dfrobot.c...&product_id=599 . 

 

ADC10CTL1 = INCH_0;
ADC10CTL0 = ADC10IE + ADC10ON + ADC10SHT_2 + SREF_0;
for( degC = 240; degC > 0; degC-- ); // delay to allow reference to settle
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
__bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled
results[2] = ADC10MEM;

I'm having trouble integrating this sensor with the ez430-rf2500. I'm using the Temperature Sensor Monitor Demos as a basis for my project. But i don't understand this formula: degC = (((temp - 673) * 4230) / 1024); which converts the value read by the sensor! Is there any formula i could apply to my case?

My code is the following:

 I've tested it but the read values are not in the range which is given in the moisture sensor wiki. 

It is suppose to be something like this:

Value range:

  1. 0 ~300 : dry soil
  2. 300~700 : humid soil
  3. 700~950 : in water
But in my case i get the value of 78 when the sensor is OUT of the water and a value of 113 when the sensor is IN the water! What am i doing wrong?

Thanks in advance!

Best regards!

  • You don't tell how you connect moisture sensor having output voltage rage 0-4.2V to ADC of msp430.

    Nelson Sales said:

    I'm having trouble integrating this sensor with the ez430-rf2500. I'm using the Temperature Sensor Monitor Demos as a basis for my project. But i don't understand this formula: degC = (((temp - 673) * 4230) / 1024); which converts the value read by the sensor! Is there any formula i could apply to my case?

    You can use direct ADC values of 0...1023 range without any math. Well.. if degC variable is char, then you need this:

    degC = temp << 3; // this converts 0..1023 range to 0..127 range which will fit into char var

  • The power supply of the sensor is 3.3v or 5v.

    I just connected the GND to pin1 (GND), the power to pin2 (VCC) and the analog input to pin3.

    Sorry I'm kind of a newbie, I didn't understood what you said about converting the range value. I'm saving the ADC10MEM in an uint8_t var (which in my code is results[2]). How can i get the values range mensioned in the moisture sensor wiki? 

    Value range:

    1. 0 ~300 : dry soil
    2. 300~700 : humid soil
    3. 700~950 : in water
    Thanks for your help!
  • Nelson Sales said:
    Sorry I'm kind of a newbie, I didn't understood what you said about converting the range value. I'm saving the ADC10MEM in an uint8_t var (which in my code is results[2]).

    uint8 means 8 bits, same size as char. Max decimal number which can be represented using unsigned char or uint8 is 255. So downconvert adcmem value like this:

    results[2] = ADC10MEM / 8;

    You will have:

    1. 0 ~37 : dry soil
    2. 37~87 : humid soil
    3. 87~118 : in water
  • That helped! I've realized my error!

    Thank you so much for your help!

    Best regards!

**Attention** This is a public forum