#include <src/sensors/ProcessorStats.h>
ProcessorStats
class
The main class to use the main processor (MCU) as a sensor.
- Reference
- Detailed Descriptions
Base classes
- class Sensor
- The "Sensor" class is used for all sensor-level operations - waking, sleeping, and taking measurements.
Constructors, destructors, conversion operators
- ProcessorStats(const char* version, uint8_t measurementsToAverage = 1)
- Construct a new Processor Stats object for a known, unmodified development board using the standard manufacturer core for that board.
- ProcessorStats(const char* boardName, const char* version, int8_t batteryPin, float batteryMultiplier, float operatingVoltage, uint8_t measurementsToAverage = 1)
- Construct a new Processor Stats object for any processor type.
- ~ProcessorStats()
- Destroy the Processor Stats object.
Public functions
- String getSensorLocation(void) -> String override
- Get the pin or connection location between the mcu and the sensor.
- bool addSingleMeasurementResult(void) -> bool override
- Get the results from a single measurement.
- float getBatteryVoltage(void) -> float
- A helper to get battery voltage as measured by a direct connection between the battery and a processor analog pin.
- uint8_t getLastResetCode(void) -> uint8_t
- Get the processor code for the last reset cause.
- String getLastResetCause(void) -> String
- Get the cause of the last reset as a string description.
Function documentation
ProcessorStats:: ProcessorStats(const char* version,
uint8_t measurementsToAverage = 1)
Construct a new Processor Stats object for a known, unmodified development board using the standard manufacturer core for that board.
Parameters | |
---|---|
version | The version of the MCU, if applicable. This is used to fill in the correct battery connection information. |
measurementsToAverage | The number of measurements to take and average before giving a "final" result from the sensor; optional with a default value of 1. |
Boards that can be used with this constructor:
- EnviroDIY
- Mayfly
- the version must be one of "v0.3", "v0.4", "v0.5", "v0.5b", "v1.0", or "v1.1"
- Stonefly
- the version must be "v0.1"
- Mayfly
- Adafruit
- Feather M0 variants (M0, M0 Express, M0 Adalogger, etc)
- Feather M4 variants
- Feather 328p variants
- WARNING: The processor isn't powerful enough for this library. To use it, you would have to strip the library down.
- Feather 32U4 variants (Basic proto, RadioFruit, BlueFruit, etc)
- WARNING: The processor isn't powerful enough for this library. To use it, you would have to strip the library down.
- Sodaq
- Mbili
- Ndogo
- One
- the version must be "v0.1" or "v0.2"
- Autonomo
- the version must be "v0.1"
ProcessorStats:: ProcessorStats(const char* boardName,
const char* version,
int8_t batteryPin,
float batteryMultiplier,
float operatingVoltage,
uint8_t measurementsToAverage = 1)
Construct a new Processor Stats object for any processor type.
Parameters | |
---|---|
boardName | The name of the board. For many boards, you can use the defined LOGGER_BOARD value. Whatever you type here will be printed out as part of the location for the processor. It has no other effect. |
version | The version of the MCU, if applicable. Whatever you type here will be printed out as part of the location for the processor. It has no other effect. |
batteryPin | The analog pin on the processor connected to the battery. |
batteryMultiplier | Any multiplier needed to convert raw battery readings from analogRead() into true battery values based on any resistors or voltage dividers |
operatingVoltage | The processor's operating voltage; most likely 3.3 or 5. |
measurementsToAverage | The number of measurements to take and average before giving a "final" result from the sensor; optional with a default value of 1. |
String ProcessorStats:: getSensorLocation(void) override
Get the pin or connection location between the mcu and the sensor.
Returns | String Text describing how the sensor is attached to the mcu. |
---|
This returns the processor name as read from the compiler variable.
bool ProcessorStats:: addSingleMeasurementResult(void) override
Get the results from a single measurement.
Returns | bool True if the function completed successfully. |
---|
This asks the sensor for a new result, verifies that it passes sanity range checks, and then adds the value to the result array.
This also un-sets the _
float ProcessorStats:: getBatteryVoltage(void)
A helper to get battery voltage as measured by a direct connection between the battery and a processor analog pin.
Returns | float The battery voltage in volts |
---|
uint8_t ProcessorStats:: getLastResetCode(void)
Get the processor code for the last reset cause.
Returns | uint8_t The processor code for the last reset cause |
---|
String ProcessorStats:: getLastResetCause(void)
Get the cause of the last reset as a string description.
Returns | String A string describing the last reset cause |
---|