ModularSensors > Classes > Sensor > AnalogElecConductivity
ModularSensors > Modules > Conductivity via Analog Electrical Resistance > AnalogElecConductivity


AnalogElecConductivity class

Class for the analog Electrical Conductivity monitor.

Base classes

class Sensor
The "Sensor" class is used for all sensor-level operations - waking, sleeping, and taking measurements.

Constructors, destructors, conversion operators

AnalogElecConductivity(int8_t powerPin, int8_t dataPin, float Rseries_ohms = RSERIES_OHMS_DEF, float sensorEC_Konst = SENSOREC_KONST_DEF, uint8_t measurementsToAverage = 1)
Construct a new AnalogElecConductivity object.
~AnalogElecConductivity()
Destroy the AnalogElecConductivity object - no action needed.

Public functions

String getSensorLocation(void ) override
Report the sensor info.
bool addSingleMeasurementResult(void ) override
Get the results from a single measurement.
void setEC_k(float sourceResistance_ohms)
Set EC constants for internal calculations. Needs to be set at startup if different from defaults.
float readEC(void )
reads the calculated EC from an analog pin using the analog pin number set in the constructor.
float readEC(uint8_t analogPinNum)
reads the calculated EC from an analog pin.

Function documentation

AnalogElecConductivity(int8_t powerPin, int8_t dataPin, float Rseries_ohms = RSERIES_OHMS_DEF, float sensorEC_Konst = SENSOREC_KONST_DEF, uint8_t measurementsToAverage = 1)

Construct a new AnalogElecConductivity object.

Parameters
powerPin The port pin providing power to the EC probe. Needs to be switched, and assumed to be same V as the dataPin's ADC.
dataPin

The processor ADC port pin to read the voltage from the EC probe. Not all processor pins can be used as analog pins. Those usable as analog pins generally are numbered with an "A" in front of the number

  • ie, A1.
Rseries_ohms The resistance of the resistor series (R) in the line; optional with default value of 499.
sensorEC_Konst The cell constant for the sensing circuit; optional with default value of 2.88 - which is what has been measured for a typical standard sized lamp-type plug.
measurementsToAverage The number of measurements to average; optional with default value of 1.

String getSensorLocation(void ) override

Report the sensor info.

Returns String Text describing how the sensor is attached to the mcu.

bool 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 _millisMeasurementRequested timestamp (sets _millisMeasurementRequested to 0) and updates the _sensorStatus.


void setEC_k(float sourceResistance_ohms)

Set EC constants for internal calculations. Needs to be set at startup if different from defaults.

Parameters
sourceResistance_ohms series R used in calculations for EC

other possible K, not specified yet: float appliedV_V, uint8_t probeType


float readEC(void )

reads the calculated EC from an analog pin using the analog pin number set in the constructor.

Returns The electrical conductance value

float readEC(uint8_t analogPinNum)

reads the calculated EC from an analog pin.

Parameters
analogPinNum Analog port pin number
Returns The electrical conductance value