ModularSensors > Classes > Sensor > SDI12Sensors
ModularSensors > Modules > SDI12Sensors


SDI12Sensors class

The main class for SDI-12 Sensors.

Base classes

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

Derived classes

class CampbellClariVUE10
The Sensor sub-class for the Campbell ClariVUE10 turbidity sensor.
class CampbellRainVUE10
The Sensor sub-class for the Campbell RainVUE10 precipitation sensor.
class Decagon5TM
The Sensor sub-class for the Meter ECH2O soil moisture sensors.
class DecagonCTD
The Sensor sub-class for the Decagon CTD-10 conductivity, temperature, and depth sensor.
class DecagonES2
The Sensor sub-class for the Decagon ES-2 sensor.
class InSituRDO
The Sensor sub-class for the In-Situ RDO PRO-X dissolved oxygen sensor.
class InSituTrollSdi12a
The Sensor sub-class for the Insitu Level/Aqua TROLL pressure, temperature, and depth sensor.
class MeterHydros21
The Sensor sub-class for the Meter Hydros 21 conductivity, temperature, and depth sensor.
class MeterTeros11
The Sensor sub-class for the Meter Teros 11 sensor.
class ZebraTechDOpto
The Sensor sub-class for the Zebra-Tech D-Opto dissolved oxygen sensor.

Constructors, destructors, conversion operators

SDI12Sensors(char SDI12address, int8_t powerPin, int8_t dataPin, uint8_t measurementsToAverage = 1, const char* sensorName = "SDI12-Sensor", const uint8_t totalReturnedValues = 1, uint32_t warmUpTime_ms = 0, uint32_t stabilizationTime_ms = 0, uint32_t measurementTime_ms = 0, int8_t extraWakeTime = 0, uint8_t incCalcValues = 0)
Construct a new SDI 12 Sensors object. This is only intended to be used within this library.
SDI12Sensors(char* SDI12address, int8_t powerPin, int8_t dataPin, uint8_t measurementsToAverage = 1, const char* sensorName = "SDI12-Sensor", const uint8_t totalReturnedValues = 1, uint32_t warmUpTime_ms = 0, uint32_t stabilizationTime_ms = 0, uint32_t measurementTime_ms = 0, int8_t extraWakeTime = 0, uint8_t incCalcValues = 0)
Construct a new SDI 12 Sensors object. This is only intended to be used within this library.
SDI12Sensors(int SDI12address, int8_t powerPin, int8_t dataPin, uint8_t measurementsToAverage = 1, const char* sensorName = "SDI12-Sensor", const uint8_t totalReturnedValues = 1, uint32_t warmUpTime_ms = 0, uint32_t stabilizationTime_ms = 0, uint32_t measurementTime_ms = 0, int8_t extraWakeTime = 0, uint8_t incCalcValues = 0)
Construct a new SDI 12 Sensors object. This is only intended to be used within this library.
~SDI12Sensors() virtual
Destroy the SDI12Sensors object - no action taken.

Public functions

String getSensorVendor(void )
Get the stored sensor vendor name returned by a previously called SDI-12 get sensor information (aI!) command.
String getSensorModel(void )
Get the stored sensor model name returned by a previously called SDI-12 get sensor information (aI!) command.
String getSensorVersion(void )
Get the stored sensor version returned by a previously called SDI-12 get sensor information (aI!) command.
String getSensorSerialNumber(void )
Get the stored sensor serial number returned by a previously called SDI-12 get sensor information (aI!) command.
String getSensorLocation(void ) override
Get the pin or connection location between the mcu and the sensor.
bool setup(void ) override
Do any one-time preparations needed before the sensor will be able to take readings.
bool startSingleMeasurement(void ) override
Tell the sensor to start a single measurement, if needed.
bool addSingleMeasurementResult(void ) override
Get the results from a single measurement.

Protected functions

bool requestSensorAcknowledgement(void )
Send the SDI-12 'acknowledge active' command [address][!] to a sensor and confirm that the correct sensor responded.
bool getSensorInfo(void )
Send the SDI-12 'info' command [address][I][!] to a sensor and parse the result into the vendor, model, version, and serial number.
int8_t startSDI12Measurement(bool isConcurrent = true)
Tell the sensor to start a single measurement, if needed.
bool getResults(void ) virtual
Gets the results of either a standard or a concurrent measurement.

Protected variables

SDI12 _SDI12Internal
Internal reference to the SDI-12 object.
char _SDI12address
Internal reference to the SDI-12 address.
int8_t _extraWakeTime
Extra wake time required for an SDI-12 sensor between the "break" and the time the command is sent.

Function documentation

SDI12Sensors(char SDI12address, int8_t powerPin, int8_t dataPin, uint8_t measurementsToAverage = 1, const char* sensorName = "SDI12-Sensor", const uint8_t totalReturnedValues = 1, uint32_t warmUpTime_ms = 0, uint32_t stabilizationTime_ms = 0, uint32_t measurementTime_ms = 0, int8_t extraWakeTime = 0, uint8_t incCalcValues = 0)

Construct a new SDI 12 Sensors object. This is only intended to be used within this library.

Parameters
SDI12address The SDI-12 address of the sensor; can be a char, char*, or int.
powerPin The pin on the mcu controlling power to the sensor Use -1 if it is continuously powered.
dataPin The pin on the mcu connected to the data line of the SDI-12 circuit.
measurementsToAverage The number of measurements to take and average before giving a "final" result from the sensor; optional with a default value of 1.
sensorName The name of the sensor. Defaults to "SDI12-Sensor".
totalReturnedValues The number of variable results returned by the sensor. Defaults to 1.
warmUpTime_ms The time in ms between when the sensor is powered on and when it is ready to receive a wake command. Defaults to 0.
stabilizationTime_ms The time in ms between when the sensor receives a wake command and when it is able to return stable values. Defaults to 0.
measurementTime_ms The time in ms between when a measurement is started and when the result value is available. Defaults to 0.
extraWakeTime Any extra time needed by the sensor between the start of the break and when the sensor is ready to accept commands. This will be between 0 and 100ms per SDI-12 protocol.
incCalcValues The number of included calculated variables from the sensor, if any. These are used for values that we would always calculate for a sensor and depend only on the raw results of that single sensor; optional with a default value of 0.

SDI12Sensors(char* SDI12address, int8_t powerPin, int8_t dataPin, uint8_t measurementsToAverage = 1, const char* sensorName = "SDI12-Sensor", const uint8_t totalReturnedValues = 1, uint32_t warmUpTime_ms = 0, uint32_t stabilizationTime_ms = 0, uint32_t measurementTime_ms = 0, int8_t extraWakeTime = 0, uint8_t incCalcValues = 0)

Construct a new SDI 12 Sensors object. This is only intended to be used within this library.

Parameters
SDI12address The SDI-12 address of the sensor; can be a char, char*, or int.
powerPin The pin on the mcu controlling power to the sensor Use -1 if it is continuously powered.
dataPin The pin on the mcu connected to the data line of the SDI-12 circuit.
measurementsToAverage The number of measurements to take and average before giving a "final" result from the sensor; optional with a default value of 1.
sensorName The name of the sensor. Defaults to "SDI12-Sensor".
totalReturnedValues The number of variable results returned by the sensor. Defaults to 1.
warmUpTime_ms The time in ms between when the sensor is powered on and when it is ready to receive a wake command. Defaults to 0.
stabilizationTime_ms The time in ms between when the sensor receives a wake command and when it is able to return stable values. Defaults to 0.
measurementTime_ms The time in ms between when a measurement is started and when the result value is available. Defaults to 0.
extraWakeTime Any extra time needed by the sensor between the start of the break and when the sensor is ready to accept commands. This will be between 0 and 100ms per SDI-12 protocol.
incCalcValues The number of included calculated variables from the sensor, if any. These are used for values that we would always calculate for a sensor and depend only on the raw results of that single sensor; optional with a default value of 0.

SDI12Sensors(int SDI12address, int8_t powerPin, int8_t dataPin, uint8_t measurementsToAverage = 1, const char* sensorName = "SDI12-Sensor", const uint8_t totalReturnedValues = 1, uint32_t warmUpTime_ms = 0, uint32_t stabilizationTime_ms = 0, uint32_t measurementTime_ms = 0, int8_t extraWakeTime = 0, uint8_t incCalcValues = 0)

Construct a new SDI 12 Sensors object. This is only intended to be used within this library.

Parameters
SDI12address The SDI-12 address of the sensor; can be a char, char*, or int.
powerPin The pin on the mcu controlling power to the sensor Use -1 if it is continuously powered.
dataPin The pin on the mcu connected to the data line of the SDI-12 circuit.
measurementsToAverage The number of measurements to take and average before giving a "final" result from the sensor; optional with a default value of 1.
sensorName The name of the sensor. Defaults to "SDI12-Sensor".
totalReturnedValues The number of variable results returned by the sensor. Defaults to 1.
warmUpTime_ms The time in ms between when the sensor is powered on and when it is ready to receive a wake command. Defaults to 0.
stabilizationTime_ms The time in ms between when the sensor receives a wake command and when it is able to return stable values. Defaults to 0.
measurementTime_ms The time in ms between when a measurement is started and when the result value is available. Defaults to 0.
extraWakeTime Any extra time needed by the sensor between the start of the break and when the sensor is ready to accept commands. This will be between 0 and 100ms per SDI-12 protocol.
incCalcValues The number of included calculated variables from the sensor, if any. These are used for values that we would always calculate for a sensor and depend only on the raw results of that single sensor; optional with a default value of 0.

String getSensorVendor(void )

Get the stored sensor vendor name returned by a previously called SDI-12 get sensor information (aI!) command.

Returns String The name of the sensor vendor as reported by the sensor itself.

String getSensorModel(void )

Get the stored sensor model name returned by a previously called SDI-12 get sensor information (aI!) command.

Returns String The name of the sensor model as reported by the sensor itself.

String getSensorVersion(void )

Get the stored sensor version returned by a previously called SDI-12 get sensor information (aI!) command.

Returns String The version of the sensor as reported by the sensor itself.

String getSensorSerialNumber(void )

Get the stored sensor serial number returned by a previously called SDI-12 get sensor information (aI!) command.

Returns String The serial number of the sensor as reported by the sensor itself.

String 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.

For SDI-12 sensors this returns a concatenation of the data pin number and the SDI-12 address.


bool setup(void ) override

Do any one-time preparations needed before the sensor will be able to take readings.

Returns bool True if the setup was successful.

This sets the pin modes for the data and power pin, sets the stream timeout time and value, and sets the status bit. This also sets the mcu's timer prescaler values to clock the serial communication. After setting the pins and prescaler, the setup tests for a response from the sensor and calls the getSensorInfo() function. Sensor power is required.


bool startSingleMeasurement(void ) override

Tell the sensor to start a single measurement, if needed.

Returns bool True if the start measurement function completed successfully.

This also sets the _millisMeasurementRequested timestamp.


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.


bool requestSensorAcknowledgement(void )

Send the SDI-12 'acknowledge active' command [address][!] to a sensor and confirm that the correct sensor responded.

Returns bool True if the correct SDI-12 sensor replied to the command.

bool getSensorInfo(void )

Send the SDI-12 'info' command [address][I][!] to a sensor and parse the result into the vendor, model, version, and serial number.

Returns bool True if all expected information fields returned by the sensor.

int8_t startSDI12Measurement(bool isConcurrent = true)

Tell the sensor to start a single measurement, if needed.

Parameters
isConcurrent Whether to start a concurrent or standard measurement. Defaults to 'true' for a concurrent measurement.
Returns int8_t The length of time the measurement is expected to take.

This also sets the _millisMeasurementRequested timestamp.


bool getResults(void ) virtual

Gets the results of either a standard or a concurrent measurement.

Returns bool True if the full number of expected results was returned.