Hi, can you help me with the sketch?
i am trying to obtain de VWC thought this function using milivolt as argument but i have very weird values, do you see something wrong with this part of the code?
I need to know 3 values of each lecture, raw, milivolts and VWC, and i call its separately and feed one with each other....
int raw1 = raw_getValue(7, A1);
float mVolt1 = mv_getValue(raw1);
double vwc1 = vwc_getValue(mVolt1);
int raw_getValue(uint8_t pinWrite, uint8_t pinRead) {
int raw = 0;
digitalWrite(pinWrite, HIGH); // poner el Pin en HIGH
delay(200); // esperar...
for (int i = 0; i < 3; i++) {
raw += analogRead(pinRead);
delay(200); }
digitalWrite(pinWrite, LOW); // poner el Pin en LOW
raw = raw/3;
return raw;
}
float mv_getValue(int raw){
float mV = (raw * (1.1/1023.0))*1000;
return mV;
}
double vwc_getValue(float mv){
float volt = mv/1000;
double vwc = (5.5667*pow(volt, 3)) - (19.6738*pow(volt, 2)) + (31.0893*volt) - 6.7511;
return vwc;
}