LOGGER
Logger
Data Logging using ESP8266
|
Go to the source code of this file.
Macros | |
#define | ILLEGAL_TEMPERATURE (1000*1000) |
Typedefs | |
typedef uint32_t | SENSOR_READ_CALLBACK(uint8_t *pUniqueID, uint8_t sensorSpecific) |
Function to call to read a sensor. | |
typedef SENSOR_READ_CALLBACK * | pSENSOR_READ_CALLBACK |
pointer to function to call to read a sensor | |
Enumerations | |
enum | SensorInterfaceID_t { InterfaceProcessorPin, InterfaceOneWire, InterfaceI2C } |
How the sensor is interfaced to the system. | |
enum | SensorTypeID_t { SensorProcessorADCpin, SensorProcessorIOpin, SensorDS18x20, SensorTCA9535, SensorAD7091R, SensorDLVRpressure } |
enum | GraphType_t { GraphTypeAllIntervals, GraphTypeAllSamples } |
Define types of graphs to output. | |
Functions | |
void | sensorlibraryInit () |
< version of this module More... | |
void | sensorlibraryDumpSensors (Print *pPrinter=&Serial, FormatType_t formatType=FormatForConsole) |
String | sensorlibraryInterfaceGetName (SensorInterfaceID_t interface) |
String | sensorlibrarySensorTypeGetName (SensorTypeID_t sensorType) |
int8_t | sensorlibraryCreateSensor (uint8_t *uniqueID, String name, uint8_t bitsOfData, bool isSigned, SensorInterfaceID_t interface, SensorTypeID_t sensorType, SensorDatatypeID_t datatype, uint8_t decimalPlaces, uint8_t sensorSpecific, pSENSOR_READ_CALLBACK pReader) |
void | sensorlibraryDisableSensor (uint8_t sensorID) |
void | sensorlibraryReadSensors (LogElement_t &element) |
void | sensorlibraryDumpElement (Print *pPrinter, uint8_t indent, LogElement_t &element, FormatType_t formatType=FormatForConsole, SensorDatatypeID_t datatype=SDallTypes) |
void | sensorlibraryDumpElementIDvalue (Print *pPrinter, uint8_t indent, LogElement_t &element, FormatType_t formatType=FormatForConsole, SensorDatatypeID_t datatype=SDallTypes) |
void | sensorlibraryDumpSensorName (Print *pPrinter, uint8_t sensorID, FormatType_t formatType=FormatForConsole) |
void | sensorlibraryDumpSensorUniqueID (Print *pPrinter, uint8_t sensorID, FormatType_t formatType=FormatForConsole) |
void | sensorlibraryDumpSensorValue (Print *pPrinter, uint8_t indent, uint32_t value, uint8_t sensorID, FormatType_t formatType=FormatForConsole) |
uint32_t | sensorlibraryExtractPulseCount (uint8_t index, LogElement_t &element, uint32_t defaultCount) |
void | sensorlibraryDumpSampleList (Print *pPrinter, LogElement_t &element, SensorDatatypeID_t datatype=SDallTypes) |
void | sensorlibrarySetPulsesSinceBoot (LogElement_t &element) |
void | sensorlibraryDumpAddColumns (Print *pPrinter, GraphType_t graphType, SensorDatatypeID_t datatype) |
String | sensorlibraryGetSensorName (uint8_t index) |
void | sensorlibraryDumpSensorById (uint8_t index, Print *pPrinter, FormatType_t formatType) |
uint8_t | sensorlibraryGetI2Caddress (uint8_t sensorID) |
uint8_t | sensorlibraryGetSensorSpecificData (uint8_t sensorID) |
Variables | |
const char *const | datatypeNames [] |
Manage a library of sensors and the instances of those sensors that are observed.
#define ILLEGAL_TEMPERATURE (1000*1000) |
A temperature value that can be used to flag errors. Temperatures are in degrees * 1000 C
enum SensorTypeID_t |
The type of sensor.
NOTES: Each processor pin used as an ADC will appear in the list and will have type SensorProcessorADCpin. The sensorSpecific is used to store the processor pin number for that pin.
A single SensorAD7091R will appear as four sensors. The sensorSpecific field is use to identify which of the four ADCinputs is logged.
int8_t sensorlibraryCreateSensor | ( | uint8_t * | uniqueID, |
String | name, | ||
uint8_t | bitsOfData, | ||
bool | isSigned, | ||
SensorInterfaceID_t | interface, | ||
SensorTypeID_t | sensorType, | ||
SensorDatatypeID_t | datatype, | ||
uint8_t | decimalPlaces, | ||
uint8_t | sensorSpecific, | ||
pSENSOR_READ_CALLBACK | pReader | ||
) |
Establish a new sensor in the library.
uniqueID | unique among sensors of the same type |
name | string to emit for people |
bitsOfData | bits in one sample |
isSigned | data is a signed value |
interface | how the sensor is connected |
sensorType | what kind of device provides the sensing |
datatype | type of information that is stored |
decimalPlaces | places for display as a fixed point number |
sensorSpecific | info about this sensor |
pReader | callback to read the sensor |
void sensorlibraryDisableSensor | ( | uint8_t | sensorID | ) |
Once a sensor is created it can be turned off. This disables printout of the sensor and is typically used to decomission a sensor that is not available because the hardware is being used for another purpose
void sensorlibraryDumpAddColumns | ( | Print * | pPrinter, |
GraphType_t | graphType, | ||
SensorDatatypeID_t | datatype | ||
) |
Dump the addColumn lines for a graph. Lines appropriate to sensors that are intervals can be emitted or lines that are appropriate to sensors that are samples.
??? future enhancements may add other graph types which will need updates to the types of graphs that can be output.
The lines have the form:
data.addColumn('number', 'ADC 0');
pPrinter | where to send the ouput |
graphType | what kind of graph is being emitted |
datatype | type of data elements to put in the list |
void sensorlibraryDumpElement | ( | Print * | pPrinter, |
uint8_t | indent, | ||
LogElement_t & | element, | ||
FormatType_t | formatType = FormatForConsole , |
||
SensorDatatypeID_t | datatype = SDallTypes |
||
) |
Print the contents of an element reporting the value logged in the element by the sensorlibraryReadSensors call.
pPrinter | where to sent the output |
indent | indentation for each new line |
element | block of data to work on |
formatType | type of output to do |
datatype | limit output to this datatype |
void sensorlibraryDumpElementIDvalue | ( | Print * | pPrinter, |
uint8_t | indent, | ||
LogElement_t & | element, | ||
FormatType_t | formatType = FormatForConsole , |
||
SensorDatatypeID_t | datatype = SDallTypes |
||
) |
Print the contents of an element reporting the value logged in the element by the sensorlibraryReadSensors call. Limit the ouptut of each sensor to the ID and value of that sensor.
pPrinter | where to sent the output |
indent | indentation for each new line |
element | block of data to work on |
formatType | type of output to do |
datatype | limit output to this datatype |
void sensorlibraryDumpSampleList | ( | Print * | pPrinter, |
LogElement_t & | element, | ||
SensorDatatypeID_t | datatype = SDallTypes |
||
) |
Print a comma seperated list of sample values. Skip over the pulse counts and pin arrays
pPrinter | where to send the output |
element | element to dump samples from |
datatype | type of data elements to put in the list |
void sensorlibraryDumpSensorById | ( | uint8_t | index, |
Print * | pPrinter, | ||
FormatType_t | formatType | ||
) |
Dump a sensor given the ID returned by sensorlibraryCreateSensor.
index | Sensor ID |
pPrinter | where to send the ouput |
formatType | how to format the output |
void sensorlibraryDumpSensorName | ( | Print * | pPrinter, |
uint8_t | sensorID, | ||
FormatType_t | formatType = FormatForConsole |
||
) |
Dump the name of a sensor based on the ID index of the sensor determined when the sensor was created with sensorlibraryCreateSensor.
pPrinter | where to sent the output |
sensorID | ID returned by sensorlibraryCreateSensor |
formatType | how to format the output |
void sensorlibraryDumpSensors | ( | Print * | pPrinter = &Serial , |
FormatType_t | formatType = FormatForConsole |
||
) |
Dump a list of sensors
pPrinter | printer to use for output |
formatType | type of ouput to emit |
void sensorlibraryDumpSensorUniqueID | ( | Print * | pPrinter, |
uint8_t | sensorID, | ||
FormatType_t | formatType = FormatForConsole |
||
) |
Dump the unique ID of a sensor based on the ID index of the sensor determined when the sensor was created with sensorlibraryCreateSensor.
pPrinter | where to sent the output |
sensorID | ID returned by sensorlibraryCreateSensor |
formatType | how to format the output |
void sensorlibraryDumpSensorValue | ( | Print * | pPrinter, |
uint8_t | indent, | ||
uint32_t | value, | ||
uint8_t | sensorID, | ||
FormatType_t | formatType = FormatForConsole |
||
) |
Dump the value of a sensor based on the unique ID of the sensor determined when the sensor was created with sensorlibraryCreateSensor.
pPrinter | where to sent the output |
indent | indentation for each new line |
value | value to dump |
sensorID | ID returned by sensorlibraryCreateSensor |
formatType | format of output |
uint32_t sensorlibraryExtractPulseCount | ( | uint8_t | index, |
LogElement_t & | element, | ||
uint32_t | defaultCount | ||
) |
Given an element extract the Nth pulse count cell.
index | which pulse count to extract |
element | element to fetch it from |
defaultCount | value to store in element if value found is invalid |
uint8_t sensorlibraryGetI2Caddress | ( | uint8_t | sensorID | ) |
Look up the I2C address for a sensor. The I2C address is stored in the last byte of the uniqueID for TCA9535 device pins.
sensorID | index into 'sensors' table |
String sensorlibraryGetSensorName | ( | uint8_t | index | ) |
Fetch a pointer to the name of a sensor given the ID returned by sensorlibraryCreateSensor.
index | Sensor ID |
uint8_t sensorlibraryGetSensorSpecificData | ( | uint8_t | sensorID | ) |
Look up the sensor specific data for a sensor.
sensorID | index into 'sensors' table |
void sensorlibraryInit | ( | ) |
< version of this module
Initialize the onewire services, call once at system startup.
String sensorlibraryInterfaceGetName | ( | SensorInterfaceID_t | interface | ) |
Get the name of a sensor interface
interface | the interface ID |
void sensorlibraryReadSensors | ( | LogElement_t & | element | ) |
Read each sensor in the library and place it into the element that gets logged.
element | block of data to write data to |
String sensorlibrarySensorTypeGetName | ( | SensorTypeID_t | sensorType | ) |
Get the name of a sensor type
sensorType | the sensor type ID |
void sensorlibrarySetPulsesSinceBoot | ( | LogElement_t & | element | ) |
For all sensors that are pulse counters read the value from the element and tell the pulse counter module the initial value. This should be called with the latest element from the database at system startup to update the pulse counters with the pulses to date.
element | element to take initial pulses from |
Update the pulse counter module
const char* const datatypeNames[] |
This array is indexed by a SensorDatatypeID_t to get the ASCIZ name of that type.