Variable class

The variable class for a value and related metadata.

A variable is a result value taken by a sensor or calculated from the results of one or more sensors. It is characterized by a name (what it is a measurement of), a unit of measurement, and a resolution. The names and units of measurements for all variables come from the controlled vocabularies developed for the ODM2 data system. (http://vocabulary.odm2.org/) The resolution is determined by the method used to take the measurement by the sensor. A variable may also be assigned a universally unique identifier (UUID) and a unique variable code. Many sensors are capable of measuring multiple variables at a single time. For example, a Decagon CTD-10 is a sensor. It is able to measure 3 variables: specific conductance, temperature, and water depth. The variable named "specificConductance" has units of microsiemens per centimeter (µS/cm) and a resolution of 1 µS/cm. Each measured variable is explicitly tied to the "parent" sensor that "notifies" the variable when a new value has been measured. Each calculated variable has a parent function returning a float which is the value for that variable.

Variables are expected to be grouped together into VariableArrays.

Derived classes

class AOSongAM2315_Humidity
The Variable sub-class used for the relative humidity output from an AOSong AM2315.
class AOSongAM2315_Temp
The Variable sub-class used for the temperature output from an AOSong AM2315.
class AOSongDHT_HI
The Variable sub-class used for the heat index output calculated from measurements made by an AOSong DHT.
class AOSongDHT_Humidity
The Variable sub-class used for the humidity output from an AOSong DHT.
class AOSongDHT_Temp
The Variable sub-class used for the temperature output from an AOSong DHT.
class AlphasenseCO2_CO2
The Variable sub-class used for the carbon dioxide (CO2) output from an Alphasense IRC-A1 CO2.
class AlphasenseCO2_Voltage
The Variable sub-class used for the raw voltage output from an Alphasense IRC-A1 CO2.
class AnalogElecConductivity_EC
The Variable sub-class used for electrical conductivity measured using an analog pin connected to electrodes submerged in the medium.
class ApogeeSQ212_PAR
The Variable sub-class used for the photosynthetically active radiation (PAR) output from an Apogee SQ-212.
class ApogeeSQ212_Voltage
The Variable sub-class used for the raw voltage output from an Apogee SQ-212.
class AtlasScientificCO2_CO2
The Variable sub-class used for the CO2 concentration output from an Atlas Scientific CO2 circuit.
class AtlasScientificCO2_Temp
The Variable sub-class used for the temperature output from an Atlas Scientific CO2 circuit.
class AtlasScientificDO_DOmgL
The Variable sub-class used for the dissolved oxygen concentration output from an Atlas Scientific EZO dissolved oxygen circuit.
class AtlasScientificDO_DOpct
The Variable sub-class used for the dissolved oxygen percent of saturation output from an Atlas Scientific EZO dissolved oxygen circuit.
class AtlasScientificEC_Cond
The Variable sub-class used for the conductivity output from an Atlas Scientific EC EZO circuit.
class AtlasScientificEC_Salinity
The Variable sub-class used for the salinity output from an Atlas Scientific EC EZO circuit.
class AtlasScientificEC_SpecificGravity
The Variable sub-class used for the specific gravity output from an Atlas Scientific EC EZO circuit.
class AtlasScientificEC_TDS
The Variable sub-class used for the total dissolved solids output from an Atlas Scientific EC EZO circuit.
class AtlasScientificORP_Potential
The Variable sub-class used for the oxidation/reduction potential output from an Atlas Scientific EZO-ORP circuit.
class AtlasScientificRTD_Temp
The Variable sub-class used for the temperature output from an Atlas Scientific RTD temperature sensor.
class AtlasScientificpH_pH
The Variable sub-class used for the pH output from an Atlas Scientific EZO pH circuit.
class BoschBME280_Altitude
The Variable sub-class used for the altitude calculated from the measurements made by a Bosch BME280.
class BoschBME280_Humidity
The Variable sub-class used for the relative humidity output from a Bosch BME280.
class BoschBME280_Pressure
The Variable sub-class used for the atmospheric pressure output from a Bosch BME280.
class BoschBME280_Temp
The Variable sub-class used for the temperature output from a Bosch BME280.
class BoschBMP3xx_Altitude
The Variable sub-class used for the altitude calculated from the measurements made by a Bosch BMP3xx.
class BoschBMP3xx_Pressure
The Variable sub-class used for the atmospheric pressure output from a Bosch BMP3xx.
class BoschBMP3xx_Temp
The Variable sub-class used for the temperature output from a Bosch BMP3xx.
class CampbellClariVUE10_ErrorCode
The Variable sub-class used for the error code output from a Campbell ClariVUE10 turbidity sensor.
class CampbellClariVUE10_Temp
The Variable sub-class used for the temperature output from a Campbell ClariVUE10 turbidity sensor.
class CampbellClariVUE10_Turbidity
The Variable sub-class used for the turbidity output from a Campbell ClariVUE10 turbidity sensor.
class CampbellOBS3_Turbidity
The Variable sub-class used for the turbidity output from a Campbell OBS3+.
class CampbellOBS3_Voltage
The Variable sub-class used for the raw voltage output from a Campbell OBS3+.
class CampbellRainVUE10_Precipitation
The Variable sub-class used for the precipitation output from a Campbell RainVUE10 precipitation sensor.
class CampbellRainVUE10_RainRateAve
The Variable sub-class used for the average rainfall rate output from a Campbell RainVUE10 precipitation sensor.
class CampbellRainVUE10_RainRateMax
The Variable sub-class used for the maximum rainfall rate output from a Campbell RainVUE10 precipitation sensor.
class CampbellRainVUE10_Tips
The Variable sub-class used for the tip count output from a Campbell RainVUE10 precipitation sensor.
class Decagon5TM_Ea
The Variable sub-class used for the apparent dielectric permittivity (εa, matric potential) output from a Meter ECH20 or Decagon 5TM soil moisture probe.
class Decagon5TM_Temp
The Variable sub-class used for the temperature output output from a Meter ECH20 or Decagon 5TM soil moisture probe.
class Decagon5TM_VWC
The Variable sub-class used for the volumetric water content output from a Meter ECH20 or Decagon 5TM soil moisture probe.
class DecagonCTD_Cond
The Variable sub-class used for the conductivity output from a Decagon CTD-10 3-in-1 water level sensor..
class DecagonCTD_Depth
The Variable sub-class used for the depth output from a Decagon CTD-10 3-in-1 water level sensor..
class DecagonCTD_Temp
The Variable sub-class used for the temperature output from a Decagon CTD-10 3-in-1 water level sensor..
class DecagonES2_Cond
The Variable sub-class used for the conductivity output from a Decagon ES-2 electrical conductivity sensor.
class DecagonES2_Temp
The Variable sub-class used for the temperature output from a Decagon ES-2 electrical conductivity sensor.
class EverlightALSPT19_Current
The Variable sub-class used for the relative current output from an Everlight ALS-PT19.
class EverlightALSPT19_Illuminance
The Variable sub-class used for the calculated illuminance output from an Everlight ALS-PT19.
class EverlightALSPT19_Voltage
The Variable sub-class used for the relative current output from an Everlight ALS-PT19.
class FreescaleMPL115A2_Pressure
The Variable sub-class used for the pressure output from a Freescale Semiconductor MPL115A2.
class FreescaleMPL115A2_Temp
The Variable sub-class used for the temperature output from a Freescale Semiconductor MPL115A2.
class GroPointGPLP8_Moist
The Variable sub-class used for the soil moisture output from a GroPoint Profile GPLP8 probe.
class GroPointGPLP8_Temp
The Variable sub-class used for the temperature output from a GroPoint Profile GPLP8 probe.
class InSituRDO_DOmgL
The Variable sub-class used for the dissolved oxygen concentration output from a In-Situ RDO PRO-X dissolved oxygen sensor.
class InSituRDO_DOpct
The Variable sub-class used for the dissolved oxygen percent saturation output from a In-Situ RDO PRO-X dissolved oxygen sensor.
class InSituRDO_Pressure
The Variable sub-class used for the oxygen partial pressure output from a In-Situ RDO PRO-X dissolved oxygen sensor.
class InSituRDO_Temp
The Variable sub-class used for the temperature output from a In-Situ RDO PRO-X dissolved oxygen sensor.
class InSituTrollSdi12a_Depth
The Variable sub-class used for the depth output from a Insitu TROLL 3-in-1 water level sensor..
class InSituTrollSdi12a_Pressure
The Variable sub-class used for the pressure output from a Insitu TROLL 3-in-1 water level sensor..
class InSituTrollSdi12a_Temp
The Variable sub-class used for the temperature Output from a Insitu TROLL 3-in-1 water level sensor..
class KellerAcculevel_Height
The Variable sub-class used for the gauge height (water level with regard to an arbitrary gage datum) output from a Keller Acculevel.
class KellerAcculevel_Pressure
The Variable sub-class used for the gauge pressure (vented and barometric pressure corrected) output from a Keller Acculevel.
class KellerAcculevel_Temp
The Variable sub-class used for the temperature output from a Keller Acculevel.
class KellerNanolevel_Height
The Variable sub-class used for the gauge height (water level with regard to an arbitrary gage datum) output from a Keller Nanolevel ceramic capacitive level transmitter.
class KellerNanolevel_Pressure
The Variable sub-class used for the gauge pressure (vented and barometric pressure corrected) output from a Keller Nanolevel ceramic capacitive level transmitter.
class KellerNanolevel_Temp
The Variable sub-class used for the temperature output from a Keller Nanolevel ceramic capacitive level transmitter.
class MaxBotixSonar_Range
The Variable sub-class used for the range output from a MaxBotix HRXL-MaxSonar ultrasonic range finder.
class MaximDS18_Temp
The Variable sub-class used for the temperature output from a Maxim one-wire temperature sensor.
class MaximDS3231_Temp
The Variable sub-class used for the temperature output from a DS3231.
class MeaSpecMS5803_Pressure
The Variable sub-class used for the pressure output from a Measurement Specialties MS5803 digital pressure sensor.
class MeaSpecMS5803_Temp
The Variable sub-class used for the temperature output from a Measurement Specialties MS5803 digital pressure sensor.
class MeterHydros21_Cond
The Variable sub-class used for the conductivity output from a Meter Hydros 21 3-in-1 water level sensor..
class MeterHydros21_Depth
The Variable sub-class used for the depth output from a Meter Hydros 21 3-in-1 water level sensor..
class MeterHydros21_Temp
The Variable sub-class used for the temperature output from a Meter Hydros 21 3-in-1 water level sensor..
class MeterTeros11_Count
The Variable sub-class used for the raw calibrated VWC counts from a Meter Teros soil moisture/water content sensor.
class MeterTeros11_Ea
The Variable sub-class used for the apparent dielectric permittivity (εa, matric potential) from a Meter Teros soil moisture/water content sensor.
class MeterTeros11_Temp
The Variable sub-class used for the temperature output output from a Teros soil moisture/water content sensor.
class MeterTeros11_VWC
The Variable sub-class used for the volumetric water content output from a Teros soil moisture/water content sensor.
class Modem_BatteryPercent
The Variable sub-class used for the battery charge percent measured by a modem.
class Modem_BatteryState
The Variable sub-class used for the battery charge state measured by a modem.
class Modem_BatteryVoltage
The Variable sub-class used for the battery voltage measured by a modem.
class Modem_RSSI
The Variable sub-class used for the RSSI measured by a modem.
class Modem_SignalPercent
The Variable sub-class used for the percent of maximum signal measured by a modem.
class Modem_Temp
The Variable sub-class used for the chip temperature as measured by the modem.
class PaleoTerraRedox_Voltage
The Variable sub-class used for the voltage output from a PaleoTerra redox sensor.
class ProcessorStats_Battery
The Variable sub-class used for the battery voltage output measured by the processor's on-board ADC.
class ProcessorStats_FreeRam
The Variable sub-class used for the free RAM measured by the MCU.
class ProcessorStats_SampleNumber
The Variable sub-class used for the sample number output from the main processor.
class RainCounterI2C_Depth
The Variable sub-class used for the depth of rain output from an Adafruit Trinket based I2C tipping bucket counter.
class RainCounterI2C_Tips
The Variable sub-class used for the total tip count output from an Adafruit Trinket based I2C tipping bucket counter.
class SensirionSHT4x_Humidity
The Variable sub-class used for the relative humidity output from an Sensirion SHT4x.
class SensirionSHT4x_Temp
The Variable sub-class used for the temperature output from an Sensirion SHTx0.
class TIADS1x15_Voltage
The Variable sub-class used for the voltage output from a TI ADS1115 or ADS1015.
class TIINA219_Current
The Variable sub-class used for the current output from a TI INA219 power and current monitor.
class TIINA219_Power
The Variable sub-class used for the power use output calculated from the voltage and current measured by a TI INA219 power and current monitor.
class TIINA219_Voltage
The Variable sub-class used for the bus voltage output from a TI INA219 power and current monitor.
class TallyCounterI2C_Events
The Variable sub-class used for the events output from a Tally Counter I2C - shows the number of events since last read.
class TurnerCyclops_BTEX
The Variable sub-class used for the refined fuels (BTEX) output from a Turner Cyclops-7F.
class TurnerCyclops_Brighteners
The Variable sub-class used for the opticalBrighteners output from a Turner Cyclops-7F.
class TurnerCyclops_CDOM
The Variable sub-class used for the CDOM output from a Turner Cyclops-7F.
class TurnerCyclops_Chlorophyll
The Variable sub-class used for the chlorophyll output from a Turner Cyclops-7F.
class TurnerCyclops_CrudeOil
The Variable sub-class used for the crude oil output from a Turner Cyclops-7F.
class TurnerCyclops_Fluorescein
The Variable sub-class used for the fluorescein output from a Turner Cyclops-7F.
class TurnerCyclops_PTSA
The Variable sub-class used for the PTSA output from a Turner Cyclops-7F.
class TurnerCyclops_Phycocyanin
The Variable sub-class used for the phycocyanin output from a Turner Cyclops-7F.
class TurnerCyclops_Phycoerythrin
The Variable sub-class used for the phycoerythrin output from a Turner Cyclops-7F.
class TurnerCyclops_RedChlorophyll
The Variable sub-class used for the chlorophyll output from a Turner Cyclops-7F.
class TurnerCyclops_Rhodamine
The Variable sub-class used for the Rhodamine output from a Turner Cyclops-7F.
class TurnerCyclops_Tryptophan
The Variable sub-class used for the tryptophan output from a Turner Cyclops-7F.
class TurnerCyclops_Turbidity
The Variable sub-class used for the turbidity output from a Turner Cyclops-7F.
class TurnerCyclops_Voltage
The Variable sub-class used for the raw voltage output from a Turner Cyclops-7F.
class TurnerTurbidityPlus_Turbidity
The Variable sub-class used for the turbidity output from a Turner Turbidity Plus.
class TurnerTurbidityPlus_Voltage
The Variable sub-class used for the [raw voltage output](sensor_turbidity_plus_voltage) from a [Turner Turbidity Plus](Turner Turbidity Plus).
class VegaPuls21_Distance
The Variable sub-class used for the temperature output from a VEGAPULS C 21 radar level sensor.
class VegaPuls21_ErrorCode
The Variable sub-class used for the error code output from a VEGAPULS C 21 radar level sensor.
class VegaPuls21_Reliability
The Variable sub-class used for the reliability output from a VEGAPULS C 21 radar level sensor.
class VegaPuls21_Stage
The Variable sub-class used for the temperature output from a VEGAPULS C 21 radar level sensor.
class VegaPuls21_Temp
The Variable sub-class used for the temperature output from a VEGAPULS C 21 radar level sensor.
class YosemitechY4000_BGA
The Variable sub-class used for the blue green algae (BGA) concentration output from a Yosemitech Y4000 multiparameter sonde.
class YosemitechY4000_Chlorophyll
The Variable sub-class used for the chlorophyll concentration output from a Yosemitech Y4000 multiparameter sonde.
class YosemitechY4000_Cond
The Variable sub-class used for the conductivity output from a Yosemitech Y4000 multiparameter sonde.
class YosemitechY4000_DOmgL
The Variable sub-class used for the dissolved oxygen concentration output from a Yosemitech Y4000 multiparameter sonde.
class YosemitechY4000_ORP
The Variable sub-class used for the electrode electrical potential output from a Yosemitech Y4000 multiparameter sonde.
class YosemitechY4000_Temp
The Variable sub-class used for the temperature output from a Yosemitech Y4000 multiparameter sonde.
class YosemitechY4000_Turbidity
The Variable sub-class used for the turbidity output from a Yosemitech Y4000 multiparameter sonde.
class YosemitechY4000_pH
The Variable sub-class used for the pH output from a Yosemitech Y4000 multiparameter sonde.
class YosemitechY504_DOmgL
The Variable sub-class used for the dissolved oxygen concentration output from a Yosemitech Y502-A or Y504-A optical dissolved oxygen sensor.
class YosemitechY504_DOpct
The Variable sub-class used for the dissolved oxygen percent saturation output from a Yosemitech Y502-A or Y504-A optical dissolved oxygen sensor.
class YosemitechY504_Temp
The Variable sub-class used for the temperature output from a Yosemitech Y504 optical dissolved oxygen sensor.
class YosemitechY510_Temp
The Variable sub-class used for the temperature output from a Yosemitech Y510-B optical turbidity sensor.
class YosemitechY510_Turbidity
The Variable sub-class used for the turbidity output from a Yosemitech Y510-B optical turbidity sensor.
class YosemitechY511_Temp
The Variable sub-class used for the temperature output from a Yosemitech Y511-A optical turbidity sensor with wiper.
class YosemitechY511_Turbidity
The Variable sub-class used for the turbidity output from a Yosemitech Y511-A optical turbidity sensor with wiper.
class YosemitechY513_BGA
The Variable sub-class used for the blue green algae concentration output from a Yosemitech Y513 Blue Green Algae (BGA) sensor with wiper.
class YosemitechY513_Temp
The Variable sub-class used for the temperature output from a Yosemitech Y513-A blue green algae sensor with wiper.
class YosemitechY514_Chlorophyll
The Variable sub-class used for the chlorophyll concentration output from a Yosemitech Y514-A chlorophyll sensor with wiper.
class YosemitechY514_Temp
The Variable sub-class used for the temperature output from a Yosemitech Y514-A chlorophyll sensor with wiper.
class YosemitechY520_Cond
The Variable sub-class used for the conductivity output from a Yosemitech Y520-A 4-electrode conductivity sensor.
class YosemitechY520_Temp
The Variable sub-class used for the temperature output from a Yosemitech Y520-A 4-electrode conductivity sensor.
class YosemitechY532_Temp
The Variable sub-class used for the temperature output from a Yosemitech Y532-A digital pH sensor.
class YosemitechY532_Voltage
The Variable sub-class used for the electrode electrical potential output from a Yosemitech Y532-A digital pH sensor.
class YosemitechY532_pH
The Variable sub-class used for the pH output from a Yosemitech Y532-A digital pH sensor.
class YosemitechY533_ORP
The Variable sub-class used for the pH output from a Yosemitech Y533 ORP sensor.
class YosemitechY533_Temp
The Variable sub-class used for the temperature output from a Yosemitech Y533 ORP sensor.
class YosemitechY551_COD
The Variable sub-class used for the carbon oxygen demand (COD) output from a Yosemitech Y551-B UV254/COD sensor with wiper.
class YosemitechY551_Temp
The Variable sub-class used for the temperature output from a Yosemitech Y551-B UV254/COD sensor with wiper.
class YosemitechY551_Turbidity
The Variable sub-class used for the turbidity output from a Yosemitech Y551-B UV254/COD sensor with wiper.
class YosemitechY560_NH4_N
The Variable sub-class used for the NH4_N output from a Yosemitech Y560-Ammonium sensor.
class YosemitechY560_Temp
The Variable sub-class used for the temperature output from a Yosemitech Y560-Ammonium sensor.
class YosemitechY560_pH
The Variable sub-class used for the pH output from a Yosemitech Y560-Ammonium sensor.
class YosemitechY700_Pressure
The Variable sub-class used for the pressure output from a Yosemitech Y700 pressure sensor.
class YosemitechY700_Temp
The Variable sub-class used for the temperature output from a Yosemitech Y700 pressure sensor.
class ZebraTechDOpto_DOmgL
The Variable sub-class used for the dissolved oxygen concentration output from a Zebra-Tech D-Opto dissolved oxygen sensor.
class ZebraTechDOpto_DOpct
The Variable sub-class used for the dissolved oxygen percent saturation output from a Zebra-Tech D-Opto dissolved oxygen sensor.
class ZebraTechDOpto_Temp
The Variable sub-class used for the temperature output from a Zebra-Tech D-Opto dissolved oxygen sensor.

Constructors, destructors, conversion operators

Variable(Sensor* parentSense, const uint8_t sensorVarNum, uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode, const char* uuid)
Construct a new Variable objectfor a measured variable - that is, one whose values are updated by a sensor.
Variable(const uint8_t sensorVarNum, uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode)
Construct a new Variable objectfor a measured variable - that is, one whose values are updated by a sensor - but do not tie it to a specific sensor.
Variable(float(*)() calcFxn, uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode, const char* uuid)
Construct a new Variable object for a calculated variable - that is, one whose value is calculated by the calcFxn which returns a float.
Variable(float(*)() calcFxn, uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode)
Construct a new Variable object for a calculated variable - that is, one whose value is calculated by the calcFxn which returns a float.
Variable()
Construct a new Variable object.
~Variable()
Destroy the Variable object - no action taken.

Public functions

Variable* begin(Sensor* parentSense, const char* uuid, const char* customVarCode) -> Variable*
Begin for the Variable object.
Variable* begin(Sensor* parentSense, const char* uuid) -> Variable*
Begin for the Variable object.
Variable* begin(Sensor* parentSense) -> Variable*
Begin for the Variable object.
Variable* begin(float(*)() calcFxn, uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode, const char* uuid) -> Variable*
Begin for the Variable object.
Variable* begin(float(*)() calcFxn, uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode) -> Variable*
Begin for the Variable object.
void attachSensor(Sensor* parentSense)
Notify the parent sensor that it has an observing variable.
void onSensorUpdate(Sensor* parentSense)
Updates the interally stored data value.
String getParentSensorName(void) -> String
Get the parent sensor name, if applicable.
String getParentSensorNameAndLocation(void) -> String
Get the parent sensor name and location, if applicable.
void setCalculation(float(*)() calcFxn)
Set the calculation function for a calculted variable.
uint8_t getResolution(void) -> uint8_t
Get the variable's resolution - in decimal places.
void setResolution(uint8_t decimalResolution)
Set the variable's resolution.
String getVarName(void) -> String
Get the variable name.
void setVarName(const char* varName)
Set the variable name.
String getVarUnit(void) -> String
Get the variable unit.
void setVarUnit(const char* varUnit)
Set the variable unit.
String getVarCode(void) -> String
Get the customized code for the variable.
void setVarCode(const char* varCode)
Set a customized code for the variable.
String getVarUUID(void) -> String
Get the customized code for the variable.
void setVarUUID(const char* uuid)
Set a customized code for the variable.
bool checkUUIDFormat(void) -> bool
Verify the the UUID is correctly formatted.
float getValue(bool updateValue = false) -> float
Get current value of the variable as a float.
String getValueString(bool updateValue = false) -> String
Get current value of the variable as a string with the correct decimal resolution.
String formatValueString(float value) -> String
Get a particular value of the variable as a string with the correct decimal resolution.

Public variables

Sensor* parentSensor
Pointer to the parent sensor.
bool isCalculated
Internal note as to whether the value is calculated.

Protected variables

float _currentValue
The current data value.

Function documentation

Variable::Variable(Sensor* parentSense, const uint8_t sensorVarNum, uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode, const char* uuid)

Construct a new Variable objectfor a measured variable - that is, one whose values are updated by a sensor.

Parameters
parentSense The Sensor object supplying values.
sensorVarNum The position in the sensor's value array of this variable's value.
decimalResolution The resolution (in decimal places) of the value.
varName The name of the variable per the ODM2 variable name controlled vocabulary
varUnit The unit of the variable per the ODM2 unit controlled vocabulary
varCode A custom code for the variable. This can be any short text helping to identify the variable in files.
uuid A universally unique identifier for the variable.

Variable::Variable(const uint8_t sensorVarNum, uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode)

Construct a new Variable objectfor a measured variable - that is, one whose values are updated by a sensor - but do not tie it to a specific sensor.

Parameters
sensorVarNum The position in the sensor's value array of this variable's value.
decimalResolution The resolution (in decimal places) of the value.
varName The name of the variable per the ODM2 variable name controlled vocabulary
varUnit The unit of the variable per the ODM2 unit controlled vocabulary
varCode A custom code for the variable. This can be any short text helping to identify the variable in files.

Variable::Variable(float(*)() calcFxn, uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode, const char* uuid)

Construct a new Variable object for a calculated variable - that is, one whose value is calculated by the calcFxn which returns a float.

Parameters
calcFxn Any function returning a float value
decimalResolution The resolution (in decimal places) of the value.
varName The name of the variable per the ODM2 variable name controlled vocabulary
varUnit The unit of the variable per the ODM2 unit controlled vocabulary
varCode A custom code for the variable. This can be any short text helping to identify the variable in files.
uuid A universally unique identifier for the variable.

Variable::Variable(float(*)() calcFxn, uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode)

Construct a new Variable object for a calculated variable - that is, one whose value is calculated by the calcFxn which returns a float.

Parameters
calcFxn Any function returning a float value
decimalResolution The resolution (in decimal places) of the value.
varName The name of the variable per the ODM2 variable name controlled vocabulary
varUnit The unit of the variable per the ODM2 unit controlled vocabulary
varCode A custom code for the variable. This can be any short text helping to identify the variable in files.

Variable* Variable::begin(Sensor* parentSense, const char* uuid, const char* customVarCode)

Begin for the Variable object.

Parameters
parentSense The Sensor object supplying values. Supercedes any Sensor supplied in the constructor.
uuid A universally unique identifier for the variable. Supercedes any value supplied in the constructor.
customVarCode A custom code for the variable. Supercedes any value supplied in the constructor.
Returns Variable* A pointer to the variable object

Variable* Variable::begin(Sensor* parentSense, const char* uuid)

Begin for the Variable object.

Parameters
parentSense The Sensor object supplying values. Supercedes any Sensor supplied in the constructor.
uuid A universally unique identifier for the variable. Supercedes any value supplied in the constructor.
Returns Variable* A pointer to the variable object

Variable* Variable::begin(Sensor* parentSense)

Begin for the Variable object.

Parameters
parentSense The Sensor object supplying values. Supercedes any Sensor supplied in the constructor.
Returns Variable* A pointer to the variable object

Variable* Variable::begin(float(*)() calcFxn, uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode, const char* uuid)

Begin for the Variable object.

Parameters
calcFxn Any function returning a float value. Supercedes any function supplied in the constructor.
decimalResolution The resolution (in decimal places) of the value. Supercedes any value supplied in the constructor.
varName The name of the variable per the ODM2 variable name controlled vocabulary. Supercedes any value supplied in the constructor.
varUnit The unit of the variable per the ODM2 unit controlled vocabulary. Supercedes any value supplied in the constructor.
varCode A custom code for the variable. Supercedes any value supplied in the constructor.
uuid A universally unique identifier for the variable. Supercedes any value supplied in the constructor.
Returns Variable* A pointer to the variable object

Variable* Variable::begin(float(*)() calcFxn, uint8_t decimalResolution, const char* varName, const char* varUnit, const char* varCode)

Begin for the Variable object.

Parameters
calcFxn Any function returning a float value. Supercedes any function supplied in the constructor.
decimalResolution The resolution (in decimal places) of the value. Supercedes any value supplied in the constructor.
varName The name of the variable per the ODM2 variable name controlled vocabulary. Supercedes any value supplied in the constructor.
varUnit The unit of the variable per the ODM2 unit controlled vocabulary. Supercedes any value supplied in the constructor.
varCode A custom code for the variable. Supercedes any value supplied in the constructor.
Returns Variable* A pointer to the variable object

void Variable::attachSensor(Sensor* parentSense)

Notify the parent sensor that it has an observing variable.

Parameters
parentSense The Sensor object supplying values.

void Variable::onSensorUpdate(Sensor* parentSense)

Updates the interally stored data value.

Parameters
parentSense The Sensor object supplying values.

This is the function called by the parent sensor's notifyVariables function


String Variable::getParentSensorName(void)

Get the parent sensor name, if applicable.

Returns String The parent sensor name

This is a helper needed for dealing with variables in arrays


String Variable::getParentSensorNameAndLocation(void)

Get the parent sensor name and location, if applicable.

Returns String The parent sensor's concatentated name and location.

This is a helper needed for dealing with variables in arrays


void Variable::setCalculation(float(*)() calcFxn)

Set the calculation function for a calculted variable.

Parameters
calcFxn Any function returning a float value.

uint8_t Variable::getResolution(void)

Get the variable's resolution - in decimal places.

Returns uint8_t the variable resolution

void Variable::setResolution(uint8_t decimalResolution)

Set the variable's resolution.

Parameters
decimalResolution The resolution (in decimal places) of the value.

String Variable::getVarName(void)

Get the variable name.

Returns String The variable name

void Variable::setVarName(const char* varName)

Set the variable name.

Parameters
varName The name of the variable per the ODM2 variable name controlled vocabulary.

Must be a value from the ODM2 variable name controlled vocabulary available here: http://vocabulary.odm2.org/variablename/


String Variable::getVarUnit(void)

Get the variable unit.

Returns String The variable unit

void Variable::setVarUnit(const char* varUnit)

Set the variable unit.

Parameters
varUnit The unit of the variable per the ODM2 unit controlled vocabulary.

Must be a value from the ODM2 unit controlled vocabulary available here: http://vocabulary.odm2.org/units/


String Variable::getVarCode(void)

Get the customized code for the variable.

Returns String The customized code for the variable

void Variable::setVarCode(const char* varCode)

Set a customized code for the variable.

Parameters
varCode A custom code for the variable. This can be any short text helping to identify the variable in files.

String Variable::getVarUUID(void)

Get the customized code for the variable.

Returns String The customized code for the variable

void Variable::setVarUUID(const char* uuid)

Set a customized code for the variable.

Parameters
uuid A universally unique identifier for the variable.

bool Variable::checkUUIDFormat(void)

Verify the the UUID is correctly formatted.

Returns bool True if the UUID is correctly formatted.

float Variable::getValue(bool updateValue = false)

Get current value of the variable as a float.

Parameters
updateValue True to ask the parent sensor to measure and return a new value. Default is false.
Returns float The current value of the variable

String Variable::getValueString(bool updateValue = false)

Get current value of the variable as a string with the correct decimal resolution.

Parameters
updateValue True to ask the parent sensor to measure and return a new value. Default is false.
Returns String The current value of the variable

String Variable::formatValueString(float value)

Get a particular value of the variable as a string with the correct decimal resolution.

Parameters
value value to format
Returns String The formatted value of the variable


Variable documentation

float Variable::_currentValue protected

The current data value.

When we create the variable, we also want to initialize it with a current value of -9999 (ie, a bad result).