ModularSensors > Modules > Supported Sensors > Processor Metadata

Processor Metadata module

Classes for the using the processor as a sensor.

Introduction

The processor can return the number of "samples" it has taken, the amount of RAM it has available and, for some boards, the battery voltage (EnviroDIY Mayfly, Sodaq Mbili, Ndogo, Autonomo, and One, Adafruit Feathers). The version of the board is required as input (ie, for a EnviroDIY Mayfly: "v0.3" or "v0.4" or "v0.5"). Use a blank value (ie, "") for un-versioned boards. Please note that while you cannot opt to average more than one sample, it really makes no sense to do so for the processor. These values are only intended to be used as diagnostics.

Sensor Datasheet

Sensor Constructor

ProcessorStats(const char* version) explicit

Construct a new Processor Stats object.

Parameters
version

The version of the MCU, if applicable.

  • For an EnviroDIY Mayfly, the version should be one of "v0.3", "v0.4", "v0.5", "v0.5b", "v1.0", or "v1.1". There is a difference between some of the versions!

Need to know the Mayfly version because the battery resistor depends on it



Example Code

The processor is used as a sensor in all of the examples, including the menu a la carte example.

#include <sensors/ProcessorStats.h>

// Create the main processor chip "sensor" - for general metadata
const char*    mcuBoardVersion = "v1.1";
ProcessorStats mcuBoard(mcuBoardVersion);

// Create sample number, battery voltage, and free RAM variable pointers for the
// processor
Variable* mcuBoardBatt = new ProcessorStats_Battery(
    &mcuBoard, "12345678-abcd-1234-ef00-1234567890ab");
Variable* mcuBoardAvailableRAM = new ProcessorStats_FreeRam(
    &mcuBoard, "12345678-abcd-1234-ef00-1234567890ab");
Variable* mcuBoardSampNo = new ProcessorStats_SampleNumber(
    &mcuBoard, "12345678-abcd-1234-ef00-1234567890ab");

Classes

class ProcessorStats
The main class to use the main processor (MCU) as a 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.

Defines

#define PROCESSOR_NUM_VARIABLES = 3
Sensor::_numReturnedValues; the processor can report 3 values.
#define PROCESSOR_INC_CALC_VARIABLES = 1
Sensor::_incCalcValues; sample number is (sort-of) calculated.

Sensor Timing

The sensor timing for the processor/mcu

  • Timing variables do not apply to the processor in the same way they do to other sensors.
#define PROCESSOR_WARM_UP_TIME_MS = 0
Sensor::_warmUpTime_ms; the processor is never powered down - there is no waiting for the processor to warmup.
#define PROCESSOR_STABILIZATION_TIME_MS = 0
Sensor::_stabilizationTime_ms; the processor is never powered down - there is no waiting for the processor to stabilize.
#define PROCESSOR_MEASUREMENT_TIME_MS = 0
Sensor::_measurementTime_ms; the processor measurement times aren't measurable.

Battery Voltage

The battery voltage variable from the processor/mcu This is the voltage as measured on the battery attached to the MCU using the inbuilt ADC, if applicable.

  • Range is assumed to be 0 to 5V
  • Accuracy is processor dependent
#define PROCESSOR_BATTERY_RESOLUTION = 3
Decimals places in string representation; battery voltage should have 3.

The resolution is of the EnviroDIY Mayfly is 0.005V, we will use that resolution for all processors.

ProcessorStats_Battery(ProcessorStats* parentSense, const char* uuid = "", const char* varCode = PROCESSOR_BATTERY_DEFAULT_CODE) explicit

Construct a new ProcessorStats_Battery object.

Parameters
parentSense The parent ProcessorStats providing the result values.
uuid A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode A short code to help identify the variable in files; optional with a default value of "batteryVoltage".

#define PROCESSOR_BATTERY_VAR_NUM = 0
Battery voltage is stored in sensorValues[0].
#define PROCESSOR_BATTERY_VAR_NAME = "batteryVoltage"
Variable name in ODM2 controlled vocabulary; batteryVoltage.
#define PROCESSOR_BATTERY_UNIT_NAME = "volt"
Variable unit name in ODM2 controlled vocabulary; "volt".
#define PROCESSOR_BATTERY_DEFAULT_CODE = "Battery"
Default variable short code; "Battery".

Available RAM

The RAM variable from the processor/mcu This is the amount of free space on the processor when running the program. This is just a diagnostic value. This number should always remain the same for a single logger program. If this number is not constant over time, there is a memory leak and something wrong with your logging program.

  • Range is 0 to full RAM available on processor

ProcessorStats_FreeRam(ProcessorStats* parentSense, const char* uuid = "", const char* varCode = PROCESSOR_RAM_DEFAULT_CODE) explicit

Construct a new ProcessorStats_FreeRam object.

Parameters
parentSense The parent ProcessorStats providing the result values.
uuid A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode A short code to help identify the variable in files; optional with a default value of "FreeRam".

#define PROCESSOR_RAM_RESOLUTION = 0
Decimals places in string representation; ram should have 0 - resolution is 1 bit.
#define PROCESSOR_RAM_VAR_NUM = 1
Free RAM is stored in sensorValues[1].
#define PROCESSOR_RAM_VAR_NAME = "freeSRAM"
Variable name in ODM2 controlled vocabulary; freeSRAM.
#define PROCESSOR_RAM_UNIT_NAME = "Bit"
Variable unit name in ODM2 controlled vocabulary; "Bit".
#define PROCESSOR_RAM_DEFAULT_CODE = "FreeRam"
Default variable short code; "FreeRam".

Sample Number

The sample number variable from the processor/mcu

ProcessorStats_SampleNumber(ProcessorStats* parentSense, const char* uuid = "", const char* varCode = PROCESSOR_SAMPNUM_DEFAULT_CODE) explicit

Construct a new ProcessorStats_SampleNumber object.

Parameters
parentSense The parent ProcessorStats providing the result values.
uuid A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode A short code to help identify the variable in files; optional with a default value of "SampNum".

#define PROCESSOR_SAMPNUM_RESOLUTION = 0
Decimals places in string representation; sample number should have 0 - resolution is 1.
#define PROCESSOR_SAMPNUM_VAR_NUM = 2
Sample number is stored in sensorValues[2].
#define PROCESSOR_SAMPNUM_VAR_NAME = "sequenceNumber"
Variable name in ODM2 controlled vocabulary; sequenceNumber.
#define PROCESSOR_SAMPNUM_UNIT_NAME = "Dimensionless"
Variable unit name in ODM2 controlled vocabulary; "Dimensionless" (sequence number)
#define PROCESSOR_SAMPNUM_DEFAULT_CODE = "SampNum"
Default variable short code; "SampNum".