Skip to main content

Meadow.Foundation.Sensors.Environmental.Y4000

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

Code Example

Y4000 sensor;

public async override Task Initialize()
{
Resolver.Log.Info("Initialize...");
await Task.Delay(2000);

sensor = new Y4000(Device, Device.PlatformOS.GetSerialPortName("COM4"), 0x01, Device.Pins.D09);
await sensor.Initialize();

await Task.Delay(2000);
}

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

var isdn = await sensor.GetISDN();
Resolver.Log.Info($"Address: {isdn}");

var supplyVoltage = await sensor.GetSupplyVoltage();
Resolver.Log.Info($"Supply voltage: {supplyVoltage}");

var measurements = await sensor.Read();

Resolver.Log.Info($"Sensor data: {measurements}");
}

Sample project(s) available on GitHub

Class Y4000

Represents a Yosemitech Y4000 Multiparameter Sonde water quality sensor for dissolved oxygen, conductivity, turbidity, pH, chlorophyll, blue green algae, chlorophyll, and temperature

Assembly: Y4000.dll
View Source
Declaration
public class Y4000 : PollingSensorBase<(ConcentrationInWater? DissolvedOxygen, ConcentrationInWater? Chlorophyl, ConcentrationInWater? BlueGreenAlgae, Conductivity? ElectricalConductivity, PotentialHydrogen? PH, Turbidity? Turbidity, Temperature? Temperature, Voltage? OxidationReductionPotential)>, IObservable<IChangeResult<(ConcentrationInWater? DissolvedOxygen, ConcentrationInWater? Chlorophyl, ConcentrationInWater? BlueGreenAlgae, Conductivity? ElectricalConductivity, PotentialHydrogen? PH, Turbidity? Turbidity, Temperature? Temperature, Voltage? OxidationReductionPotential)>>, ISamplingSensor<(ConcentrationInWater? DissolvedOxygen, ConcentrationInWater? Chlorophyl, ConcentrationInWater? BlueGreenAlgae, Conductivity? ElectricalConductivity, PotentialHydrogen? PH, Turbidity? Turbidity, Temperature? Temperature, Voltage? OxidationReductionPotential)>, ISensor<(ConcentrationInWater? DissolvedOxygen, ConcentrationInWater? Chlorophyl, ConcentrationInWater? BlueGreenAlgae, Conductivity? ElectricalConductivity, PotentialHydrogen? PH, Turbidity? Turbidity, Temperature? Temperature, Voltage? OxidationReductionPotential)>, ISensor, ISamplingSensor, IDisposable

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

Implements:
System.IObservable<Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.Conductivity>,System.Nullable<Meadow.Units.PotentialHydrogen>,System.Nullable<Meadow.Units.Turbidity>,System.Nullable<Meadow.Units.Temperature>,System.ValueTuple<System.Nullable<Meadow.Units.Voltage>>>>>, Meadow.Peripherals.Sensors.ISamplingSensor<System.ValueTuple<System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.Conductivity>,System.Nullable<Meadow.Units.PotentialHydrogen>,System.Nullable<Meadow.Units.Turbidity>,System.Nullable<Meadow.Units.Temperature>,System.ValueTuple<System.Nullable<Meadow.Units.Voltage>>>>, Meadow.Peripherals.Sensors.ISensor<System.ValueTuple<System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.Conductivity>,System.Nullable<Meadow.Units.PotentialHydrogen>,System.Nullable<Meadow.Units.Turbidity>,System.Nullable<Meadow.Units.Temperature>,System.ValueTuple<System.Nullable<Meadow.Units.Voltage>>>>, Meadow.Peripherals.Sensors.ISensor, Meadow.Peripherals.Sensors.ISamplingSensor, System.IDisposable

Properties

DissolvedOxygen

The current Dissolved Oxygen concentration

View Source
Declaration
public ConcentrationInWater? DissolvedOxygen { get; }

Chlorophyl

The current Chlorophyll concentration

View Source
Declaration
public ConcentrationInWater? Chlorophyl { get; }

BlueGreenAlgae

The current Blue Green Algae concentration

View Source
Declaration
public ConcentrationInWater? BlueGreenAlgae { get; }

ElectricalConductivity

The current Electrical Conductivity

View Source
Declaration
public Conductivity? ElectricalConductivity { get; }

PH

The current Potential Hydrogen (pH)

View Source
Declaration
public PotentialHydrogen? PH { get; }

Turbidity

The current Turbidity

View Source
Declaration
public Turbidity? Turbidity { get; }

OxidationReductionPotential

The current Oxidation Reduction Potential (redux)

View Source
Declaration
public Voltage? OxidationReductionPotential { get; }

IsDisposed

Is the object disposed

View Source
Declaration
public bool IsDisposed { get; }

ModbusAddress

The current modbus address

View Source
Declaration
public byte ModbusAddress { get; }

Methods

Initialize()

Initialize sensor

View Source
Declaration
public Task Initialize()
Returns

System.Threading.Tasks.Task

GetISDN()

Get the device ISDN (address) of the sensor Note this is a broadcast event so all Y4000 devices on the bus will respond

View Source
Declaration
public Task<byte> GetISDN()
Returns

System.Threading.Tasks.Task<System.Byte>: The address as a byte### SetISDN(byte) Set the ISDN (address) of the sensor

View Source
Declaration
public Task SetISDN(byte modbusAddress)
Returns

System.Threading.Tasks.Task

Parameters
TypeNameDescription
System.BytemodbusAddressThe address

GetSupplyVoltage()

Get the current supply voltage

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

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

GetSerialNumber()

Get the device serial number

View Source
Declaration
public Task<ushort[]> GetSerialNumber()
Returns

System.Threading.Tasks.Task<System.UInt16[]>: The serial number as a ushort array### GetVersion() Get the device version

View Source
Declaration
public Task<ushort[]> GetVersion()
Returns

System.Threading.Tasks.Task<System.UInt16[]>

GetBrushInterval()

Get the brush or wiper interval

View Source
Declaration
public Task<TimeSpan> GetBrushInterval()
Returns

System.Threading.Tasks.Task<System.TimeSpan>

SetBrushInterval(TimeSpan)

Set the brush or wiper interval (normalized to minutes)

View Source
Declaration
public Task SetBrushInterval(TimeSpan interval)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
System.TimeSpaninterval

StartBrush()

Start the brush or wiper

View Source
Declaration
public Task StartBrush()
Returns

System.Threading.Tasks.Task

GetErrorFlag()

Read the error flag from the sensor

View Source
Declaration
public Task<ushort> GetErrorFlag()
Returns

System.Threading.Tasks.Task<System.UInt16>

ReadSensor()

Reads data from the sensor

View Source
Declaration
protected override Task<(ConcentrationInWater? DissolvedOxygen, ConcentrationInWater? Chlorophyl, ConcentrationInWater? BlueGreenAlgae, Conductivity? ElectricalConductivity, PotentialHydrogen? PH, Turbidity? Turbidity, Temperature? Temperature, Voltage? OxidationReductionPotential)> ReadSensor()
Returns

System.Threading.Tasks.Task<System.ValueTuple<System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.Conductivity>,System.Nullable<Meadow.Units.PotentialHydrogen>,System.Nullable<Meadow.Units.Turbidity>,System.Nullable<Meadow.Units.Temperature>,System.ValueTuple<System.Nullable<Meadow.Units.Voltage>>>>: The latest sensor reading### RaiseEventsAndNotify(IChangeResult<(ConcentrationInWater? DissolvedOxygen, ConcentrationInWater? Chlorophyl, ConcentrationInWater? BlueGreenAlgae, Conductivity? ElectricalConductivity, PotentialHydrogen? PH, Turbidity? Turbidity, Temperature? Temperature, Voltage? OxidationReductionPotential)>) Raise events for subscribers and notify of value changes

View Source
Declaration
protected override void RaiseEventsAndNotify(IChangeResult<(ConcentrationInWater? DissolvedOxygen, ConcentrationInWater? Chlorophyl, ConcentrationInWater? BlueGreenAlgae, Conductivity? ElectricalConductivity, PotentialHydrogen? PH, Turbidity? Turbidity, Temperature? Temperature, Voltage? OxidationReductionPotential)> changeResult)
Parameters
TypeNameDescription
Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.Conductivity>,System.Nullable<Meadow.Units.PotentialHydrogen>,System.Nullable<Meadow.Units.Turbidity>,System.Nullable<Meadow.Units.Temperature>,System.ValueTuple<System.Nullable<Meadow.Units.Voltage>>>>changeResultThe updated sensor data

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

View Source
Declaration
public void Dispose()

Dispose(bool)

Dispose of the object

View Source
Declaration
protected virtual void Dispose(bool disposing)
Parameters
TypeNameDescription
System.BooleandisposingIs disposing

Events

DissolvedOxygenUpdated

Raised when the DissolvedOxygen value changes

View Source
Declaration
public event EventHandler<IChangeResult<ConcentrationInWater>> DissolvedOxygenUpdated
Event Type

System.EventHandler<Meadow.IChangeResult<Meadow.Units.ConcentrationInWater>>

ChlorophylUpdated

Raised when the Chlorophyll value changes

View Source
Declaration
public event EventHandler<IChangeResult<ConcentrationInWater>> ChlorophylUpdated
Event Type

System.EventHandler<Meadow.IChangeResult<Meadow.Units.ConcentrationInWater>>

BlueGreenAlgaeUpdated

Raised when the BlueGreenAlgae value changes

View Source
Declaration
public event EventHandler<IChangeResult<ConcentrationInWater>> BlueGreenAlgaeUpdated
Event Type

System.EventHandler<Meadow.IChangeResult<Meadow.Units.ConcentrationInWater>>

ElectricalConductivityUpdated

Raised when the ElectricalConductivity value changes

View Source
Declaration
public event EventHandler<IChangeResult<Conductivity>> ElectricalConductivityUpdated
Event Type

System.EventHandler<Meadow.IChangeResult<Meadow.Units.Conductivity>>

PHUpdated

Raised when the PotentialHydrogen (pH) value changes

View Source
Declaration
public event EventHandler<IChangeResult<PotentialHydrogen>> PHUpdated
Event Type

System.EventHandler<Meadow.IChangeResult<Meadow.Units.PotentialHydrogen>>

TurbidityUpdated

Raised when the Turbidity value changes

View Source
Declaration
public event EventHandler<IChangeResult<Turbidity>> TurbidityUpdated
Event Type

System.EventHandler<Meadow.IChangeResult<Meadow.Units.Turbidity>>

TemperatureUpdated

Raised when the Temperature value changes

View Source
Declaration
public event EventHandler<IChangeResult<Temperature>> TemperatureUpdated
Event Type

System.EventHandler<Meadow.IChangeResult<Meadow.Units.Temperature>>

OxidationReductionPotentialUpdated

Raised when the OxidationReductionPotential (redux) value changes

View Source
Declaration
public event EventHandler<IChangeResult<Voltage>> OxidationReductionPotentialUpdated
Event Type

System.EventHandler<Meadow.IChangeResult<Meadow.Units.Voltage>>

Implements

  • System.IObservable<Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.Conductivity>,System.Nullable<Meadow.Units.PotentialHydrogen>,System.Nullable<Meadow.Units.Turbidity>,System.Nullable<Meadow.Units.Temperature>,System.ValueTuple<System.Nullable<Meadow.Units.Voltage>>>>>
  • Meadow.Peripherals.Sensors.ISamplingSensor<System.ValueTuple<System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.Conductivity>,System.Nullable<Meadow.Units.PotentialHydrogen>,System.Nullable<Meadow.Units.Turbidity>,System.Nullable<Meadow.Units.Temperature>,System.ValueTuple<System.Nullable<Meadow.Units.Voltage>>>>
  • Meadow.Peripherals.Sensors.ISensor<System.ValueTuple<System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.ConcentrationInWater>,System.Nullable<Meadow.Units.Conductivity>,System.Nullable<Meadow.Units.PotentialHydrogen>,System.Nullable<Meadow.Units.Turbidity>,System.Nullable<Meadow.Units.Temperature>,System.ValueTuple<System.Nullable<Meadow.Units.Voltage>>>>
  • Meadow.Peripherals.Sensors.ISensor
  • Meadow.Peripherals.Sensors.ISamplingSensor
  • System.IDisposable