Campbell OBS3+ topic

Classes for the Campbell OBS3+ analog turbidity sensor.

Introduction

The OBS-3+ puts out a simple analog signal between 0 and 2.5V. When the sensor is purchased, included in the packaging is a calibration certificate to use to convert the voltage into turbidity.

The OBS3+ supports two different turbidity ranges. The low and high range signals are read independently of each other - the signals are on different wires. Each range has a separate calibrations.

Before applying any turbidity calibration, the analog output from the OBS3+ must be converted into a high resolution digital signal. See the ADS1115 page for details on the conversion.

Sensor Datasheet

Build flags

  • -D MS_USE_ADS1015
    • switches from the 16-bit ADS1115 to the 12 bit ADS1015

Sensor Constructor

CampbellOBS3::CampbellOBS3(int8_t powerPin, uint8_t adsChannel, float x2_coeff_A, float x1_coeff_B, float x0_coeff_C, uint8_t i2cAddress = 0x48, uint8_t measurementsToAverage = 1)

Construct a new Campbell OBS3 object - need the power pin, the ADS1X15 data channel, and the calibration info.

Parameters
powerPin

The pin on the mcu controlling power to the OBS3+ Use -1 if it is continuously powered.

  • The ADS1x15 requires an input voltage of 2.0-5.5V, but this library assumes the ADS is powered with 3.3V.
  • The OBS-3 itself requires a 5-15V power supply, which can be turned off between measurements.
adsChannel The analog data channel on the TI ADS1115 that the OBS3 is connected to (0-3).
x2_coeff_A The x2 (A) coefficient for the calibration in volts
x1_coeff_B The x (B) coefficient for the calibration in volts
x0_coeff_C The x0 (C) coefficient for the calibration in volts
i2cAddress The I2C address of the ADS 1x15, default is 0x48 (ADDR = GND)
measurementsToAverage The number of measurements to take and average before giving a "final" result from the sensor; optional with a default value of 1.


Example Code

The Campbell OBS3+ is used in the menu a la carte example.

1#include <sensors/CampbellOBS3.h>
2
3// NOTE: Use -1 for any pins that don't apply or aren't being used.
4const int8_t OBS3Power = sensorPowerPin; // Power pin
5const uint8_t OBS3NumberReadings = 10;
6const uint8_t OBS3ADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC
7
8const int8_t OBSLowADSChannel = 0; // ADS channel for *low* range output
9
10// Campbell OBS 3+ *Low* Range Calibration in Volts
11const float OBSLow_A = 0.000E+00; // "A" value (X^2) [*low* range]
12const float OBSLow_B = 1.000E+00; // "B" value (X) [*low* range]
13const float OBSLow_C = 0.000E+00; // "C" value [*low* range]
14
15// Create a Campbell OBS3+ *low* range sensor object
16CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C,
17 OBS3ADSi2c_addr, OBS3NumberReadings);
18
19// Create turbidity and voltage variable pointers for the low range of the OBS3
20Variable* obs3TurbLow = new CampbellOBS3_Turbidity(
21 &osb3low, "12345678-abcd-1234-ef00-1234567890ab", "TurbLow");
22Variable* obs3VoltLow = new CampbellOBS3_Voltage(
23 &osb3low, "12345678-abcd-1234-ef00-1234567890ab", "TurbLowV");
24
25
26const int8_t OBSHighADSChannel = 1; // ADS channel for *high* range output
27
28// Campbell OBS 3+ *High* Range Calibration in Volts
29const float OBSHigh_A = 0.000E+00; // "A" value (X^2) [*high* range]
30const float OBSHigh_B = 1.000E+00; // "B" value (X) [*high* range]
31const float OBSHigh_C = 0.000E+00; // "C" value [*high* range]
32
33// Create a Campbell OBS3+ *high* range sensor object
34CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B,
35 OBSHigh_C, OBS3ADSi2c_addr, OBS3NumberReadings);
36
37// Create turbidity and voltage variable pointers for the high range of the OBS3
38Variable* obs3TurbHigh = new CampbellOBS3_Turbidity(
39 &osb3high, "12345678-abcd-1234-ef00-1234567890ab", "TurbHigh");
40Variable* obs3VoltHigh = new CampbellOBS3_Voltage(
41 &osb3high, "12345678-abcd-1234-ef00-1234567890ab", "TurbHighV");

Classes

class CampbellOBS3
The Sensor sub-class for the Campbell OBS3 analog turbidity sensor.
class CampbellOBS3_Turbidity
The Variable sub-class used for the turbidity output from a Campbell OBS3+.
class CampbellOBS3_Voltage
The Variable sub-class used for the raw voltage output from a Campbell OBS3+.

Sensor Variable Counts

The number of variables that can be returned by OBS3

#define OBS3_NUM_VARIABLES = 2
Sensor::_numReturnedValues; the OBS3 can report 2 values.
#define OBS3_INC_CALC_VARIABLES = 1
Sensor::_incCalcValues; turbidity is calculated from raw voltage using the input calibration equation.

Configuration Defines

Defines to set the address of the ADD.

#define ADS1115_ADDRESS = 0x48
The assumed address of the ADS1115, 1001 000 (ADDR = GND)

Sensor Timing

The sensor timing for an OBS3+

#define OBS3_WARM_UP_TIME_MS = 2
Sensor::_warmUpTime_ms; the ADS1115 warms up in 2ms.
#define OBS3_STABILIZATION_TIME_MS = 2000
Sensor::_stabilizationTime_ms; minimum stabilization time for the OBS3 is 2s (2000ms).
#define OBS3_MEASUREMENT_TIME_MS = 100
Sensor::_measurementTime_ms; OBS3 takes 100ms to complete a measurement - Maximum data rate = 10Hz (100ms/sample).

Turbidity

The turbidity variable from an OBS3+

  • Range: (depends on sediment size, particle shape, and reflectivity)
    • Turbidity (low/high):
      • T1: 250/1000 NTU
      • T2: 500/2000 NTU
      • T3: 1000/4000 NTU
    • Mud: 5000 to 10,000 mg L–1
    • Sand: 50,000 to 100,000 mg L–1
  • Accuracy: (whichever is larger)
    • Turbidity: 2% of reading or 0.5 NTU
    • Mud: 2% of reading or 1 mg L–1
    • Sand: 4% of reading or 10 mg L–1
  • Resolution:
    • 16-bit ADC, Turbidity:
      • T1: 0.03125/0.125 NTU
      • T2: 0.0625/0.25 NTU
      • T3: 0.125/0.5 NTU
      • OBS3_RESOLUTION = 5
    • 12-bit ADC, Turbidity:

CampbellOBS3_Turbidity::CampbellOBS3_Turbidity(CampbellOBS3* parentSense, const char* uuid = "", const char* varCode = "OBS3Turbidity") explicit

Construct a new CampbellOBS3_Turbidity object.

Parameters
parentSense The parent CampbellOBS3 providing the result values.
uuid A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode A short code to help identify the variable in files; optional with a default value of "OBS3Turbidity".

#define OBS3_TURB_VAR_NUM = 0
Variable number; turbidity is stored in sensorValues[0].
#define OBS3_RESOLUTION = 5
Decimals places in string representation; turbidity should have 5.
#define OBS3_TURB_VAR_NAME = "turbidity"
Variable name in ODM2 controlled vocabulary; "turbidity".
#define OBS3_TURB_UNIT_NAME = "nephelometricTurbidityUnit"
Variable unit name in ODM2 controlled vocabulary; "nephelometricTurbidityUnit" (NTU)
#define OBS3_TURB_DEFAULT_CODE = "OBS3Turbidity"
Default variable short code; "OBS3Turbidity".

Voltage

The voltage variable from an OBS3+

  • Range is 0 to 2.5V
  • Accuracy:

CampbellOBS3_Voltage::CampbellOBS3_Voltage(CampbellOBS3* parentSense, const char* uuid = "", const char* varCode = "OBS3Voltage") explicit

Construct a new CampbellOBS3_Voltage object.

Parameters
parentSense The parent CampbellOBS3 providing the result values.
uuid A universally unique identifier (UUID or GUID) for the variable; optional with the default value of an empty string.
varCode A short code to help identify the variable in files; optional with a default value of "OBS3Voltage".

#define OBS3_VOLTAGE_VAR_NUM = 1
Variable number; voltage is stored in sensorValues[1].
#define OBS3_VOLTAGE_VAR_NAME = "voltage"
Variable name in ODM2 controlled vocabulary; "voltage".
#define OBS3_VOLTAGE_UNIT_NAME = "volt"
Variable unit name in ODM2 controlled vocabulary; "volt".
#define OBS3_VOLTAGE_DEFAULT_CODE = "OBS3Voltage"
Default variable short code; "OBS3Voltage".
#define OBS3_VOLTAGE_RESOLUTION = 4
Decimals places in string representation; voltage should have 4.

Define documentation

#define OBS3_NUM_VARIABLES = 2

Sensor::_numReturnedValues; the OBS3 can report 2 values.

Low and high range are treated as completely independent, so only 2 "variables" are measured by each sensor - one for the raw voltage and another for the calibrated turbidity. To get both high and low range values, create two sensor objects!


#define OBS3_INC_CALC_VARIABLES = 1

Sensor::_incCalcValues; turbidity is calculated from raw voltage using the input calibration equation.


#define ADS1115_ADDRESS = 0x48

The assumed address of the ADS1115, 1001 000 (ADDR = GND)


#define OBS3_WARM_UP_TIME_MS = 2

Sensor::_warmUpTime_ms; the ADS1115 warms up in 2ms.


#define OBS3_STABILIZATION_TIME_MS = 2000

Sensor::_stabilizationTime_ms; minimum stabilization time for the OBS3 is 2s (2000ms).


#define OBS3_MEASUREMENT_TIME_MS = 100

Sensor::_measurementTime_ms; OBS3 takes 100ms to complete a measurement - Maximum data rate = 10Hz (100ms/sample).


#define OBS3_TURB_VAR_NUM = 0

Variable number; turbidity is stored in sensorValues[0].


#define OBS3_RESOLUTION = 5

Decimals places in string representation; turbidity should have 5.


#define OBS3_TURB_VAR_NAME = "turbidity"

Variable name in ODM2 controlled vocabulary; "turbidity".


#define OBS3_TURB_UNIT_NAME = "nephelometricTurbidityUnit"

Variable unit name in ODM2 controlled vocabulary; "nephelometricTurbidityUnit" (NTU)


#define OBS3_TURB_DEFAULT_CODE = "OBS3Turbidity"

Default variable short code; "OBS3Turbidity".


#define OBS3_VOLTAGE_VAR_NUM = 1

Variable number; voltage is stored in sensorValues[1].


#define OBS3_VOLTAGE_DEFAULT_CODE = "OBS3Voltage"

Default variable short code; "OBS3Voltage".


#define OBS3_VOLTAGE_RESOLUTION = 4

Decimals places in string representation; voltage should have 4.

  • Resolution:
    • 12-bit ADC (ADS1015, using build flag MS_USE_ADS1015): 2 mV