Overview
BaseSens is the abstract base class for all sensors in the SensorModuleV1 framework. It provides a unified interface for sensor initialization, updates, and data access through JSON documents.
Inheritance: All V1 sensors inherit from BaseSens
Header: lib/sensors/SensorModuleV1/base/sensor-module.h
Class Definition
Core Methods
init()
Initializes the sensor hardware and configuration.true if initialization succeeded, false otherwiseThis is a pure virtual function that must be implemented by derived sensor classes.
update()
Reads current sensor data and updates internal values.true if update succeeded, false otherwiseThis is a pure virtual function that must be implemented by derived sensor classes.
getValue()
Retrieves sensor value through a pointer parameter.Pointer to store the sensor value
getValueF()
Returns sensor value directly as a float.Current sensor value
Document Methods
setDocument()
Sets the object name for JSON document storage.Name identifier for this sensor in the JSON document
Usually called automatically by
SensorModule during initialization.setDocumentValue()
Assigns the shared JSON document for data storage.Pointer to the shared JSON document
getDocument()
Retrieves the entire JSON document.The complete JSON document containing sensor data
getVariant()
Retrieves a specific value from the JSON document.Key name to search for in the document
JSON variant containing the requested value
Additional Methods
process()
Performs additional processing on sensor data.Optional method that can be overridden for custom processing logic.
Usage Example
Inheritance Hierarchy
JSON Document Structure
Sensors store data in a shared JSON document:See Also
- SensorModule (V1) - Container and manager for V1 sensors
- BaseSens (V2) - Modern type-safe base class
- Sensor Overview - Complete sensor framework guide