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 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 InSitu RDO PRO-X dissolved oxygen 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 numReturnedVars = 1, uint32_t warmUpTime_ms = 0, uint32_t stabilizationTime_ms = 0, uint32_t measurementTime_ms = 0, int8_t extraWakeTime = 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 numReturnedVars = 1, uint32_t warmUpTime_ms = 0, uint32_t stabilizationTime_ms = 0, uint32_t measurementTime_ms = 0, int8_t extraWakeTime = 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 numReturnedVars = 1, uint32_t warmUpTime_ms = 0, uint32_t stabilizationTime_ms = 0, uint32_t measurementTime_ms = 0, int8_t extraWakeTime = 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.
bool getResults()
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 numReturnedVars = 1, uint32_t warmUpTime_ms = 0, uint32_t stabilizationTime_ms = 0, uint32_t measurementTime_ms = 0, int8_t extraWakeTime = 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".
numReturnedVars 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.

SDI12Sensors(char* SDI12address, int8_t powerPin, int8_t dataPin, uint8_t measurementsToAverage = 1, const char* sensorName = "SDI12-Sensor", const uint8_t numReturnedVars = 1, uint32_t warmUpTime_ms = 0, uint32_t stabilizationTime_ms = 0, uint32_t measurementTime_ms = 0, int8_t extraWakeTime = 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".
numReturnedVars 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.

SDI12Sensors(int SDI12address, int8_t powerPin, int8_t dataPin, uint8_t measurementsToAverage = 1, const char* sensorName = "SDI12-Sensor", const uint8_t numReturnedVars = 1, uint32_t warmUpTime_ms = 0, uint32_t stabilizationTime_ms = 0, uint32_t measurementTime_ms = 0, int8_t extraWakeTime = 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".
numReturnedVars 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.

StringgetSensorVendor(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.

StringgetSensorModel(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.

StringgetSensorVersion(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.

StringgetSensorSerialNumber(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.

StringgetSensorLocation(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.


boolsetup(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.


boolstartSingleMeasurement(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.


booladdSingleMeasurementResult(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.


boolrequestSensorAcknowledgement(void ) protected

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.

boolgetSensorInfo(void ) protected

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.

boolgetResults() protected

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

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