SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By pierrot10
#196204
Good day,

I just bought that rpoduct
https://www.sparkfun.com/products/13637
I also read the Hookup guide and theyspoke about calibration.

I understood, we have to take the measure when the soil is dry and when is wet.
Using the sketch above, note what values your sensor outputs when the sensor is completely dry vs when the sensor is completely submerged in a shallow cup of water. Depending on what microcontoller you’re using, the operating voltage of that microcontoller, and the resolution of its analog-to-digital converter, you’re results will vary.
then
Once you have a good handle on the values you can expect, you can use the map() function to adjust your code accordingly.
I am confuse about the map function.
Which parameter should we enter in map()
Code: Select all
map(value, fromLow, fromHigh, toLow, toHigh)
I supose, the value, is the return value from the moisture sensor.
fromLow: I suppose is the value when the soil is dry
fromHigh: I suppose is when the soil is fullywet
but what about toLow and toHigh?
fromLow: the lower bound of the value's current range
fromHigh: the upper bound of the value's current range
toLow: the lower bound of the value's target range
toHigh: the upper bound of the value's target range
In the case of my moisture sensor, how can get the target range, etc

I am bt confused about the use of map while I only now the return value, the dry value and the wet value.

Some has experience with calibrating a moisture sensor?

Thank a lot
By Valen
#196207
The target values are all up to you or how you want to output the value. If you need it to output a PWM signal then toLow could be 0 and toHigh be 255. Or some subset of that range if below a low PWM level or higher than a certain PWM level does not matter for your output device. Or incase your microcontroller drives steppermotors of a graph pen-plotter. Then toLow and toHigh could be the number of steps where the plotting area limits are. If instead you just want to send it to a pc for logging you could use a more scientific scale. Like if you calibrate measured quantities water added to a known quantity of dry soil then you could assign a calculated mass-fraction for those limits. Like 0.01 for toLow (10 gram per kilogram) and 0.05 for toHigh (50 gram per kilogram). Those numbers are totally made up by me. I don't know how dry dry is. The question is what do you want to do with that value and what numbers do you need for that?
By pierrot10
#196210
Hello, thank for your reply.
I am new with this matter.
I read that we need to calibrate.
So I can measure when it dry and when it s wet. Then I suggest when I have this value, I need to use it. And I think tieh map() ?

I can be happy with the measured value with the moisture sensor but I wish to have something close to "the exact", I wunder how I can consider the dried measure and the wet measure.

Are you using a moisture sensor? Do you consider the dried and wet measure?

Cheers
By Valen
#196215
I do not have such a sensor. I also do not know how much water soil can contain.

The moisture sensor will give an ADC result depending on the amount of water in soil it detects. That will vary with each individual sensor stick. You should measure that with wet and dry soil to get the from-values. The to-values are the range to which the ADC results should be linearly scaled. That is all that the map function does. Either you use the readings of a industrial moisture sensor that you stuck in the same bucket of partially moist soil as the baseline for to-values. Then you calibrate against another sensor. Or you use controlled amounts of water in controlled amounts of soil (the cheap method) and use those ratio's to define the moisture scale.

Something close to 'the exact' has no meaning if you don't know how much actual water is in the soil that you measured. How much water in soil you consider 'dry' or how much do you consider 'wet'?

Here is a link about soil moisture calibration that Google dug up: (a little more thorough by drying sand in an oven) http://www.edaphic.com.au/soil-water-co ... libration/