Hello Hard-shovel !
Are you still around?
I ma still doubting about my SWP value returning by my sensor and by the code to calculate it.
Until last week, I was used to use the great code you provide to me
resistanceCalc(frequency, wrm);
Si.sprint(F("WRM: "),2);
Si.sprintln(wrm,2);
kPaCalc(wrm, Tsoil, swp);
val = swp;
But I was always suspicous about the SWP value. I also bout a WATER digital reader and the values never matched.
All the graph/line of Station3 is calculate with a temperature of 24Celcul. As sensor is in a room where the temeparture is between 24C and 28C, a small tolerence must be "accepted" :)
Last week I used this to get the WRM (Watermark resistance)
wrm = map(frequency,48,13233,27950,550)
but never use it. The result is wrong. I compared with datsheet of the Isometer and the result never matches.
However, your table works fine
//---------------------------------------------------------------
void resistanceCalc(float frequencyInput, int32_t &wrm){
wrm=0;
// Convert from freqency to Resistance measurement
// From SMX.pdf datasheet, page 6
// 48 Hz = 10,000,000 Ohms
// 76 Hz = 262,144 Ohms
// 13233 Hz = 0 ohms
// using lookup table held in the array RESISTORarray
//frequencyInput = constrain(frequencyInput,50, 13233);
//float newVal;
if (frequencyInput <= RESISTORarray[0]) { // Minimum value
wrm = RESISTORarray[0+1];
}
if (frequencyInput >= RESISTORarray[74]) { // Maximum value
wrm = RESISTORarray[74+1];
}
for (int i=0; i<74; i=i+2) {
if ((frequencyInput >= RESISTORarray[i]) && (frequencyInput <= RESISTORarray[i+2]))
{
wrm = RESISTORarray[i+1] - ((RESISTORarray[i+1]-RESISTORarray[i+3]) * ((frequencyInput-RESISTORarray[i]) / (RESISTORarray[i+2]-RESISTORarray[i])));
break;
}
}
Si.sprint(F("WRM: "),2); Si.sprintln(wrm,2);
}
In order to be fixed this question, I used my LoRa node to send the wrm, swp and a second swp to my server and observe the diffrence.
Look at this web page (go to Station 3)
Station 3 (Teste)
Note:
Station 1 and 2 are two station on fields.
Station 3 is a node I have at home. I put a little of water on matrix of the watermark until the SWP go to 8kpa and left it dried 1,5 day until the the SWP is 200kps. one hour ago, I put the watermark sensor into water for one hour, and I am going to leave it drying under the sun and compare the graph. Today afternoon (15.9.2018), I am going to update the code of station 1 and 2 to get the SWP value with the equation of Shock
The red line is the WRM in Ohm and not ml/h (I have not change the unit).
The yellow line is the SWP return with the equation of Shock
swp = (int16_t)(3.213 * (wrm/1000) + 4.093) / (1 - 0.009733 * (wrm/1000) - 0.01205 * Tsoil);
and the violet line is the SWP return by
void kPaCalc(int32_t ResistanceInput, int16_t FTemperatureInput, int16_t &swp){
// Convert from Resistance to SWP kPa measurement
// From SMX.pdf datasheet, page 7
// 550 Ohms = 0 SWP kPa
// 6000 Ohms = 35 SWP kPa
// 28075 Ohms =200 SWP kPa
// using lookup table held in the array SWPkPAarray
// table valid for temperature of 75F, 24C
// for increase of 1°F increase resistance by 1%.
// ** this function accepts temperature in Fahrenheit units **
//float newVal;
// Adjust compensate resistance for temperature and cpnvert celculs to Fahrenheit
// per page 8 of SMX.pdf
swp=0;
float ResistanceCompensated = ResistanceInput *(1 + 0.001*((FTemperatureInput * 1.8 + 32)-75));
Si.sprint(F("WRMc: "),2); Si.sprintln((int16_t)ResistanceCompensated,2);
if (ResistanceCompensated <= SWPkPAarray[0]) { // Minimum value
swp = SWPkPAarray[0+1];
}
if (ResistanceCompensated >= SWPkPAarray[16]) { // Maximum value
swp = SWPkPAarray[16+1];
}
//for (int i=0; i<SWPkPAarray.length-2; i=i+2) {
for (int i=0; i<16; i=i+2) {
if ((ResistanceCompensated >= SWPkPAarray[i]) && (ResistanceCompensated <= SWPkPAarray[i+2])) {
swp = SWPkPAarray[i+1] - ((SWPkPAarray[i+1]-SWPkPAarray[i+3]) * ((ResistanceInput-SWPkPAarray[i]) / (SWPkPAarray[i+2]-SWPkPAarray[i])));
break;
}
}
//return newVal;
}
It's interresting to see that the kPaCalc() progress as a step and stop at 100kpa and jump at 200kpa only when the wrm is 27950.
I used
constrain (wrm,550,27950)
so the wrm will not be display higher than 27950 even if it can go over 27950 as say the doc.
The equation of Shock look perfect and I controlled it with Watermark data reader. The result is similar with a tolerance of 5-10kpa.
From graph (See Station 3), I also compare the WRM and the SWP from the doc (see page 7) and SWP value matches.
I wonder why, in the array
long SWPkPAarray[18]{
// Watermark Sensor SMX interface Resistance to SWP kPa lookup table per SMX.pdf page 7.
// this table is valid at temperature of 75F, 24C
550, 0,
1000, 9,
1100, 10,
2000, 15,
6000, 35,
9200, 55,
12200, 75,
15575, 100,
28075, 200,
you do not consider a SWP between 100kpa and 200kpa.
I thing it's very interresting to have value from 100kpa and 200kpa, as 100kpa is the moment when soil need to be irrigate and more we come close to 200kpa, more is dangerous.
In any case, your function kPaCalc2() from the code you provided to me, 3 mounth ago seems to be best.
Thank for all
Cheers