data_logger_general_from_protocol_set_


This macro converts and displays a stream of environmental sensors data sets obtained using the _protocol_set_ feature.
/**
* Macro for data evaluation on PhotosynQ.org
* by: David M. Kramer
* created: 2017-05-12 @ 11:07:27

The macro converts a stream of environmental data sets obtained using the _protocol_set_ feature 
into arrays and displays them.

For example, the following protocol will take temperature_humidity_pressure2, and light_intensity
once per second for 20 times. 
[{ "_protocol_set_":
[
	{
		"environmental": [
		["temperature_humidity_pressure2"],
        ["light_intensity"]
		],
     "protocols":20,
     "protocols_delay":1000
	}
]
}]

The macro will generate one array for each sensor, i.,e. temperature2, humidity2 and PAR,
as well as time. The time array is not displayed unless you un-comment the following line:

 //output.timescale = output.time;

Note: It is important to exclude data sets that are arrays, especially data_raw. This is done 
by adding the "data_raw"] to the list exclude_these:

var exclude_these=["data_raw"];

The macro can be modified to exclude the output and display of other the paramters by adding 
the names to the list called exclude_these. For example, I do not want to see "data_raw", "r", 
"g", "b", "light_intensity_raw"

var exclude_these=["data_raw", "r", "g", "b", "light_intensity_raw"];

*/


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

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

   //add values to exclude from the analyses
   var exclude_these=["data_raw", "r", "g", "b", "light_intensity_raw"];

	keys = Object.keys(json.set[2]); //find the keys to the sensors
   Object.keys(json.set[2]).join(","); //join them in a string for display
   number_sensors=keys.length;  // find the number of sensors
   output.number_sensors=number_sensors; //display the number of sensors

   // Add key time and value to output
   number_measurements=json.set.length;  	
   output.number_measurements=number_measurements;

  // var number_sensors = json.set[1]
 for (var j=0; j< number_sensors; j++){

   use_this_key=keys[j];
   if (exclude_these.indexOf(use_this_key)<0){
   temp=[];
  var i;
   for (i=1; i < number_measurements; i++){
     var t=json.set[i][use_this_key];
     temp.push(t);
   }
   output[use_this_key]=temp;
   }
 }
 //output.timescale = output.time;
}

// Return data
return output;
{
  "time_offset": "America/Detroit",
  "time": "1494601599113",
  "device_name": "MultispeQ",
  "device_version": "1",
  "device_id": "01:12:52:59",
  "device_battery": 89,
  "device_firmware": 1.17,
  "sample": [
    [
      {
        "time": "1494601599113",
        "light_intensity_raw": 0,
        "data_raw": [

        ],
        "set": [
          {
            "time": "1494601599113",
            "blank:": "blank"
          },
          {
            "time": "1494601599124",
            "protocol_id": "",
            "temperature2": 25.790001,
            "humidity2": 27.354492,
            "pressure2": 984.228271,
            "light_intensity": 17,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 25,
            "data_raw": [

            ]
          },
          {
            "time": "1494601600126",
            "protocol_id": "",
            "temperature2": 25.799999,
            "humidity2": 27.344727,
            "pressure2": 984.21759,
            "light_intensity": 18,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 26,
            "data_raw": [

            ]
          },
          {
            "time": "1494601601128",
            "protocol_id": "",
            "temperature2": 25.809999,
            "humidity2": 27.344727,
            "pressure2": 984.212158,
            "light_intensity": 17,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 25,
            "data_raw": [

            ]
          },
          {
            "time": "1494601602130",
            "protocol_id": "",
            "temperature2": 25.82,
            "humidity2": 27.333984,
            "pressure2": 984.218811,
            "light_intensity": 17,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 25,
            "data_raw": [

            ]
          },
          {
            "time": "1494601603133",
            "protocol_id": "",
            "temperature2": 25.82,
            "humidity2": 27.323242,
            "pressure2": 984.240723,
            "light_intensity": 18,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 26,
            "data_raw": [

            ]
          },
          {
            "time": "1494601604135",
            "protocol_id": "",
            "temperature2": 25.83,
            "humidity2": 27.323242,
            "pressure2": 984.224854,
            "light_intensity": 18,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 26,
            "data_raw": [

            ]
          },
          {
            "time": "1494601605137",
            "protocol_id": "",
            "temperature2": 25.83,
            "humidity2": 27.3125,
            "pressure2": 984.207397,
            "light_intensity": 18,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 26,
            "data_raw": [

            ]
          },
          {
            "time": "1494601606139",
            "protocol_id": "",
            "temperature2": 25.84,
            "humidity2": 27.313477,
            "pressure2": 984.228149,
            "light_intensity": 18,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 26,
            "data_raw": [

            ]
          },
          {
            "time": "1494601607141",
            "protocol_id": "",
            "temperature2": 25.84,
            "humidity2": 27.313477,
            "pressure2": 984.226868,
            "light_intensity": 18,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 26,
            "data_raw": [

            ]
          },
          {
            "time": "1494601608143",
            "protocol_id": "",
            "temperature2": 25.84,
            "humidity2": 27.302734,
            "pressure2": 984.231323,
            "light_intensity": 18,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 26,
            "data_raw": [

            ]
          },
          {
            "time": "1494601609145",
            "protocol_id": "",
            "temperature2": 25.85,
            "humidity2": 27.291016,
            "pressure2": 984.199219,
            "light_intensity": 18,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 26,
            "data_raw": [

            ]
          },
          {
            "time": "1494601610147",
            "protocol_id": "",
            "temperature2": 25.85,
            "humidity2": 27.291992,
            "pressure2": 984.224609,
            "light_intensity": 18,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 26,
            "data_raw": [

            ]
          },
          {
            "time": "1494601611150",
            "protocol_id": "",
            "temperature2": 25.860001,
            "humidity2": 27.292969,
            "pressure2": 984.253967,
            "light_intensity": 18,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 26,
            "data_raw": [

            ]
          },
          {
            "time": "1494601612151",
            "protocol_id": "",
            "temperature2": 25.870001,
            "humidity2": 27.28125,
            "pressure2": 984.260132,
            "light_intensity": 18,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 26,
            "data_raw": [

            ]
          },
          {
            "time": "1494601613153",
            "protocol_id": "",
            "temperature2": 25.870001,
            "humidity2": 27.282227,
            "pressure2": 984.218933,
            "light_intensity": 18,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 26,
            "data_raw": [

            ]
          },
          {
            "time": "1494601614155",
            "protocol_id": "",
            "temperature2": 25.870001,
            "humidity2": 27.270508,
            "pressure2": 984.196777,
            "light_intensity": 18,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 26,
            "data_raw": [

            ]
          },
          {
            "time": "1494601615157",
            "protocol_id": "",
            "temperature2": 25.879999,
            "humidity2": 27.271484,
            "pressure2": 984.226624,
            "light_intensity": 18,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 26,
            "data_raw": [

            ]
          },
          {
            "time": "1494601616159",
            "protocol_id": "",
            "temperature2": 25.889999,
            "humidity2": 27.260742,
            "pressure2": 984.207275,
            "light_intensity": 18,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 26,
            "data_raw": [

            ]
          },
          {
            "time": "1494601617161",
            "protocol_id": "",
            "temperature2": 25.889999,
            "humidity2": 27.260742,
            "pressure2": 984.222168,
            "light_intensity": 18,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 26,
            "data_raw": [

            ]
          },
          {
            "time": "1494601618163",
            "protocol_id": "",
            "temperature2": 25.9,
            "humidity2": 27.250977,
            "pressure2": 984.234131,
            "light_intensity": 18,
            "r": 15,
            "g": 7,
            "b": 4,
            "light_intensity_raw": 26,
            "data_raw": [

            ]
          }
        ],
        "protocol_id": 1
      }
    ]
  ],
  "app_os": "darwin-x64",
  "app_name": "PhotosynQ",
  "app_version": "0.0.3",
  "app_device": "x64",
  "location": [
    "42.7223907",
    "-84.4746075"
  ],
  "ConsoleMacro": "249"
}
Dave in cap img 4615
Created by

David M. Kramer


Protocol connections:
0
Latest Update:
May 2017