Volumtetric Water Content


This macro calculates the VWC from the vegetronix soil moisture probe, using the original calibration from the manufacturer. For use with device 247 only
//============================================
// Macro for data evaluation on PhotosynQ.org
// created: 7/15/2015
//============================================

//Define the output object here
var output = {};

//var VWC = ((json.analog_read * json.analog_read * -.00000000006) + (0.00001 * json.analog_read) - 0.148) * 100;

// Convert analog read to volts
var volts = json.analog_read / 21333

// Volumetric water content in percent
var VWC = false;

/*
Voltage Range	Equation
0 to 1.1V	VWC= 10*V-1  
1.1V to 1.3V	VWC= 25*V- 17.5
1.3V  to 1.82V	VWC= 48.08*V- 47.5
1.82V to 2.2V	VWC= 26.32*V- 7.89
*/


if(volts <= 1.1)
  VWC = 10 * volts - 1

else if(volts > 1.1 && volts <= 1.3)
  VWC = 25 * volts - 17.5
  
else if(volts > 1.3 && volts <= 1.82)
  VWC = 48.08 * volts -47.5
  
else if(volts > 1.82)
  VWC = 26.32 * volts - 7.89
 

//Show value and name in output 
output ["volts"] = json.analog_read / 21333
output["VWC"] = MathROUND(VWC,2);

output["VWC"] = VWC;
output["analog_read"] = json.analog_read

//Return data
return output;
{
  "time_offset": 240,
  "time": 1436978406784,
  "device_id": 131,
  "firmware_version": "0.420",
  "sample": [
    [
      {
        "time": 1436978406784,
        "protocol_id": 1,
        "get_userdef7": [
          0,
          0
        ],
        "averages": 30,
        "analog_read": 17019,
        "data_raw": [

        ]
      }
    ]
  ]
}
Sam 0645   copy   copy  2
Created by

Dan TerAvest


Protocol connections:
1
Latest Update:
Sep 2016