Remarks

C420R
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation.mikroBUS.Sensors.C420R

Code Example

private C420R receiver;

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

    receiver = new C420R(Device.CreateSpiBus(), Device.Pins.D00);

    return Task.CompletedTask;
}

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

Sample project(s) available on GitHub

Characteristic Locus
Inheritance object ObservableBase<Current> SamplingSensorBase<Current> PollingSensorBase<Current> > C420R
Implements IObservable<IChangeResult<Current>> ISamplingSensor<Current> ISensor<Current>
Inherited Members PollingSensorBase<Current>.StartUpdating(TimeSpan?) PollingSensorBase<Current>.StopUpdating() SamplingSensorBase<Current>.samplingLock SamplingSensorBase<Current>.Updated SamplingSensorBase<Current>.SamplingTokenSource SamplingSensorBase<Current>.Conditions SamplingSensorBase<Current>.IsSampling SamplingSensorBase<Current>.UpdateInterval SamplingSensorBase<Current>.RaiseEventsAndNotify(IChangeResult<Current>) SamplingSensorBase<Current>.Read() ObservableBase<Current>.observers ObservableBase<Current>.NotifyObservers(IChangeResult<Current>) ObservableBase<Current>.Subscribe(IObserver<IChangeResult<Current>>) ObservableBase<Current>.CreateObserver(Action<IChangeResult<Current>>, Predicate<IChangeResult<Current>>) object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow.Foundation.mikroBUS.Sensors
Assembly C420R.dll

Syntax

public class C420R : PollingSensorBase<Current>, IObservable<IChangeResult<Current>>, ISamplingSensor<Current>, ISensor<Current>

Constructors

C420R(ISpiBus, IDigitalOutputPort, int, TimeSpan?)

Creates a new C420R object using the SPI bus for readings

Declaration
public C420R(ISpiBus spiBus, IDigitalOutputPort chipSelectPort, int sampleCount = 5, TimeSpan? sampleInterval = null)

Parameters

Type Name Description
ISpiBus spiBus

The SPI bus

IDigitalOutputPort chipSelectPort

Chip select port

int sampleCount

How many samples to take during a given reading (default is 5)

TimeSpan? sampleInterval

The time between sample readings (default is 5 seconds)

Remarks

C420R
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation.mikroBUS.Sensors.C420R

Code Example

private C420R receiver;

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

    receiver = new C420R(Device.CreateSpiBus(), Device.Pins.D00);

    return Task.CompletedTask;
}

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

Sample project(s) available on GitHub

C420R(ISpiBus, IPin, int, TimeSpan?)

Creates a new C420R object using the SPI bus for readings

Declaration
public C420R(ISpiBus spiBus, IPin chipSelectPin, int sampleCount = 5, TimeSpan? sampleInterval = null)

Parameters

Type Name Description
ISpiBus spiBus

The SPI bus

IPin chipSelectPin

Chip select pin

int sampleCount

How many samples to take during a given reading (default is 5)

TimeSpan? sampleInterval

The time between sample readings (default is 5 seconds)

Remarks

C420R
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation.mikroBUS.Sensors.C420R

Code Example

private C420R receiver;

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

    receiver = new C420R(Device.CreateSpiBus(), Device.Pins.D00);

    return Task.CompletedTask;
}

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

Sample project(s) available on GitHub

Properties

ReferenceVoltage

Reference voltage (2.048V)

Declaration
public Voltage ReferenceVoltage { get; protected set; }

Property Value

Type Description
Voltage

Remarks

C420R
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation.mikroBUS.Sensors.C420R

Code Example

private C420R receiver;

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

    receiver = new C420R(Device.CreateSpiBus(), Device.Pins.D00);

    return Task.CompletedTask;
}

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

Sample project(s) available on GitHub

Methods

ReadSensor()

Read value from sensor

Declaration
protected override Task<Current> ReadSensor()

Returns

Type Description
Task<Current>

unitized value

Overrides

Remarks

C420R
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation.mikroBUS.Sensors.C420R

Code Example

private C420R receiver;

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

    receiver = new C420R(Device.CreateSpiBus(), Device.Pins.D00);

    return Task.CompletedTask;
}

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

Sample project(s) available on GitHub