Skip to main content

Meadow.Foundation.Sensors.Environmental.AtlasScientificGravityDOMeter

AtlasScientificGravityDOMeter
StatusStatus badge: working
Source codeGitHub
Datasheet(s)GitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Sensors.Environmental.AtlasScientificGravityDOMeter

Code Example

AtlasScientificGravityDOMeter sensor;

public override Task Initialize()
{
Resolver.Log.Info("Initialize...");

sensor = new AtlasScientificGravityDOMeter(Device.Pins.A01);
sensor.CalibrationInAir = new Voltage(0.04, Voltage.UnitType.Volts);

// Example that uses an IObservable subscription to only be notified when the saturation changes
var consumer = AtlasScientificGravityDOMeter.CreateObserver(
handler: result =>
{
string oldValue = (result.Old is { } old) ? $"{old * 100:n1}" : "n/a";
string newValue = $"{result.New * 100:n1}";
Resolver.Log.Info($"New: {newValue}%, Old: {oldValue}%");
},
filter: null
);
sensor.Subscribe(consumer);

// optional classical .NET events can also be used:
sensor.Updated += (sender, result) =>
{
string oldValue = (result.Old is { } old) ? $"{old * 100:n0}%" : "n/a";
Resolver.Log.Info($"Updated - New: {result.New * 100:n0}%, Old: {oldValue}");
};

return Task.CompletedTask;
}

public override async Task Run()
{
Resolver.Log.Info("Run...");

await ReadSensor();

//example calibration setting, ensure the sensor is set up for calibration
var calibrationVoltage = await sensor.GetCurrentVoltage();
sensor.CalibrationInAir = calibrationVoltage;

Resolver.Log.Info($"Calibration voltage: {calibrationVoltage.Volts}V");

sensor.StartUpdating(TimeSpan.FromSeconds(2));
}

protected async Task ReadSensor()
{
var saturation = await sensor.Read();
Resolver.Log.Info($"Initial saturation: {saturation * 100:N1}%");
}

Sample project(s) available on GitHub

Class AtlasScientificGravityDOMeter

Atlas Scientific Analog Gravity Dissolved Oxygen Meter

Assembly: AtlasScientificGravityDOMeter.dll
View Source
Declaration
public class AtlasScientificGravityDOMeter : SamplingSensorBase<double>, IObservable<IChangeResult<double>>, IDissolvedOxygenSaturationSensor, ISamplingSensor<double>, ISensor<double>, ISensor, ISamplingSensor

Inheritance: System.Object -> Meadow.Foundation.ObservableBase<UNIT>

Implements:
System.IObservable<Meadow.IChangeResult<System.Double>>, Meadow.Peripherals.Sensors.Environmental.IDissolvedOxygenSaturationSensor, Meadow.Peripherals.Sensors.ISamplingSensor<System.Double>, Meadow.Peripherals.Sensors.ISensor<System.Double>, Meadow.Peripherals.Sensors.ISensor, Meadow.Peripherals.Sensors.ISamplingSensor

Properties

CalibrationInAir

The calibration value for the sensor in air

View Source
Declaration
public Voltage CalibrationInAir { get; set; }

AnalogInputPort

Returns the analog input port

View Source
Declaration
protected IAnalogInputPort AnalogInputPort { get; }

Saturation

Last saturation value read from the sensor (0.0-1.0)

View Source
Declaration
public double? Saturation { get; protected set; }

Methods

GetCurrentVoltage()

Get the current voltage, useful for calibration

View Source
Declaration
public Task<Voltage> GetCurrentVoltage()
Returns

System.Threading.Tasks.Task<Meadow.Units.Voltage>

ReadSensor()

Reads data from the sensor

View Source
Declaration
protected override Task<double> ReadSensor()
Returns

System.Threading.Tasks.Task<System.Double>: The latest sensor reading### StartUpdating(TimeSpan?) Starts continuously sampling the sensor

View Source
Declaration
public override void StartUpdating(TimeSpan? updateInterval)
Parameters
TypeName
System.Nullable<System.TimeSpan>updateInterval

StopUpdating()

Stops sampling the sensor

View Source
Declaration
public override void StopUpdating()

Implements

  • System.IObservable<Meadow.IChangeResult<System.Double>>
  • Meadow.Peripherals.Sensors.Environmental.IDissolvedOxygenSaturationSensor
  • Meadow.Peripherals.Sensors.ISamplingSensor<System.Double>
  • Meadow.Peripherals.Sensors.ISensor<System.Double>
  • Meadow.Peripherals.Sensors.ISensor
  • Meadow.Peripherals.Sensors.ISamplingSensor