Echo Soil moisture sensor


Outputs volumetric water content (%) for an Echo soil moisture sensor.
/**
 * Macro for data evaluation on PhotosynQ.org
 * by: Dan TerAvest
 * created: June 26, 2017 1:00 PM
 */

// Define the output object here
var output = {};
var sensor = json.message;

if (sensor == "0"){
output ["VWC"] =  MathROUND((0.0029 * json.analog_read) - 62.048);
}

else if (sensor == "1"){
output ["VWC"] =  MathROUND((0.0029 * json.analog_read) - 136.18);
}
  
else if (sensor == "2"){
output ["VWC"] = MathROUND((0.004 * json.analog_read) - 45.0701);
}
 

//output["VWC"] = VWC;

// Check if the key time exists in json
if (json.time !== undefined){

	// Add key time and value to output
	output["time"] = json.time;
}

// Return data
return output;
{
  "time": "1498504113164",
  "device_name": "MultispeQ",
  "device_version": "1",
  "device_id": "ff:ff:ff:ff",
  "device_battery": 172,
  "device_firmware": 1.17,
  "sample": [
    [
      {
        "time": "1498504113176",
        "protocol_id": 1,
        "analog_read": 16290,
        "message": [
          [
            "prompt",
            "Enter 1 for GS1, 2 for Waterscout, 3 for Echo",
            "3"
          ]
        ],
        "data_raw": [
          0
        ]
      }
    ]
  ],
  "app_os": "win32-10.0.15063",
  "app_name": "PhotosynQ",
  "app_version": "0.0.14",
  "app_device": "ia32",
  "location": [
    "42.7226078",
    "-84.4746723"
  ],
  "time_offset": "America/New_York"
}
Sam 0645   copy   copy  2
Created by

Dan TerAvest


Protocol connections:
1
Latest Update:
Jun 2017