Skip to main content

Meadow.Foundation.mikroBUS.Sensors.CACCurrent

CACCurrent
StatusStatus badge: working
Source codeGitHub
NuGet packageNuGet Gallery for Meadow.Foundation.mikroBUS.Sensors.CACCurrent

Code Example

private CACCurrent currentClick;
private const bool useSpi = false;

public override Task Initialize()
{
Console.WriteLine("Initializing ...");

if (useSpi)
{
currentClick = new CACCurrent(
Device.CreateSpiBus(),
Device.Pins.D14.CreateDigitalOutputPort());
}
else
{
currentClick = new CACCurrent(Device.Pins.A00.CreateAnalogInputPort(5));
}

currentClick.Updated += OnCurrentUpdated;
currentClick.StartUpdating();

return Task.CompletedTask;
}

public override async Task Run()
{
while (true)
{
var r = await currentClick.Read();
Resolver.Log.Info($"Reading: {r.Amps:0.00} A");
await Task.Delay(1000);
}
}

private void OnCurrentUpdated(object sender, IChangeResult<Meadow.Units.Current> e)
{
Resolver.Log.Info($"Current changed from {(e.Old ?? new Meadow.Units.Current(0)).Amps}A to {e.New.Amps}A");
}

Sample project(s) available on GitHub

Class CACCurrent

Represents a mikroBUS current sensing AC Current Click board

Assembly: CACCurrent.dll
View Source
Declaration
public class CACCurrent : CurrentTransducer, IObservable<IChangeResult<Current>>, ISamplingSensor<Current>, ISensor<Current>, ISensor, ISamplingSensor

Inheritance: System.Object -> Meadow.Foundation.ObservableBase<Meadow.Units.Current> -> Meadow.Foundation.SamplingSensorBase<Meadow.Units.Current> -> Meadow.Foundation.Sensors.Power.CurrentTransducer

Implements:
System.IObservable<Meadow.IChangeResult<Meadow.Units.Current>>, Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Current>, Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Current>, Meadow.Peripherals.Sensors.ISensor, Meadow.Peripherals.Sensors.ISamplingSensor

Properties

ReferenceVoltage

Reference voltage (2.048V)

View Source
Declaration
public Voltage ReferenceVoltage { get; protected set; }

Implements

  • System.IObservable<Meadow.IChangeResult<Meadow.Units.Current>>
  • Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Current>
  • Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Current>
  • Meadow.Peripherals.Sensors.ISensor
  • Meadow.Peripherals.Sensors.ISamplingSensor