Remarks

Relay
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

A relay is an electrically operated or electromechanical switch composed of an electromagnet, an armature, a spring and a set of electrical contacts. The electromagnetic switch is operated by a small electric current that turns a larger current on or off by either releasing or retracting the armature contact, thereby cutting or completing the circuit. Relays are necessary when there must be electrical isolation between controlled and control circuits, or when multiple circuits need to be controlled by a single signal.

Sample projects available on GitHub

Code Example

protected Relay relay;

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

    relay = new Relay(Device.CreateDigitalOutputPort(Device.Pins.D02));

    return Task.CompletedTask;
}

public override Task Run()
{
    var state = false;

    while (true)
    {
        state = !state;

        Resolver.Log.Info($"- State: {state}");
        relay.IsOn = state;

        Thread.Sleep(500);
    }
}

Sample project(s) available on GitHub

Wiring Example

Characteristic Locus
Inheritance object > Relay
Implements IRelay
Inherited Members object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow.Foundation.Relays
Assembly Meadow.Foundation.dll

Syntax

public class Relay : IRelay

Constructors

Relay(IDigitalOutputPort, RelayType)

Creates a new Relay on an IDigitalOutputPort. Allows you to use any peripheral that exposes ports that conform to the IDigitalOutputPort, such as the MCP23008.

Declaration
public Relay(IDigitalOutputPort port, RelayType type = RelayType.NormallyOpen)

Parameters

Type Name Description
IDigitalOutputPort port
RelayType type

Remarks

Relay
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

A relay is an electrically operated or electromechanical switch composed of an electromagnet, an armature, a spring and a set of electrical contacts. The electromagnetic switch is operated by a small electric current that turns a larger current on or off by either releasing or retracting the armature contact, thereby cutting or completing the circuit. Relays are necessary when there must be electrical isolation between controlled and control circuits, or when multiple circuits need to be controlled by a single signal.

Sample projects available on GitHub

Code Example

protected Relay relay;

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

    relay = new Relay(Device.CreateDigitalOutputPort(Device.Pins.D02));

    return Task.CompletedTask;
}

public override Task Run()
{
    var state = false;

    while (true)
    {
        state = !state;

        Resolver.Log.Info($"- State: {state}");
        relay.IsOn = state;

        Thread.Sleep(500);
    }
}

Sample project(s) available on GitHub

Wiring Example

Relay(IPin, RelayType)

Creates a new Relay on an IDigitalOutputPort.

Declaration
public Relay(IPin pin, RelayType type = RelayType.NormallyOpen)

Parameters

Type Name Description
IPin pin

Pin connected to relay

RelayType type

Relay type

Remarks

Relay
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

A relay is an electrically operated or electromechanical switch composed of an electromagnet, an armature, a spring and a set of electrical contacts. The electromagnetic switch is operated by a small electric current that turns a larger current on or off by either releasing or retracting the armature contact, thereby cutting or completing the circuit. Relays are necessary when there must be electrical isolation between controlled and control circuits, or when multiple circuits need to be controlled by a single signal.

Sample projects available on GitHub

Code Example

protected Relay relay;

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

    relay = new Relay(Device.CreateDigitalOutputPort(Device.Pins.D02));

    return Task.CompletedTask;
}

public override Task Run()
{
    var state = false;

    while (true)
    {
        state = !state;

        Resolver.Log.Info($"- State: {state}");
        relay.IsOn = state;

        Thread.Sleep(500);
    }
}

Sample project(s) available on GitHub

Wiring Example

Properties

DigitalOut

Returns digital output port

Declaration
protected IDigitalOutputPort DigitalOut { get; set; }

Property Value

Type Description
IDigitalOutputPort

Remarks

Relay
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

A relay is an electrically operated or electromechanical switch composed of an electromagnet, an armature, a spring and a set of electrical contacts. The electromagnetic switch is operated by a small electric current that turns a larger current on or off by either releasing or retracting the armature contact, thereby cutting or completing the circuit. Relays are necessary when there must be electrical isolation between controlled and control circuits, or when multiple circuits need to be controlled by a single signal.

Sample projects available on GitHub

Code Example

protected Relay relay;

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

    relay = new Relay(Device.CreateDigitalOutputPort(Device.Pins.D02));

    return Task.CompletedTask;
}

public override Task Run()
{
    var state = false;

    while (true)
    {
        state = !state;

        Resolver.Log.Info($"- State: {state}");
        relay.IsOn = state;

        Thread.Sleep(500);
    }
}

Sample project(s) available on GitHub

Wiring Example

IsOn

Whether or not the relay is on. Setting this property will turn it on or off.

Declaration
public bool IsOn { get; set; }

Property Value

Type Description
bool

Remarks

Relay
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

A relay is an electrically operated or electromechanical switch composed of an electromagnet, an armature, a spring and a set of electrical contacts. The electromagnetic switch is operated by a small electric current that turns a larger current on or off by either releasing or retracting the armature contact, thereby cutting or completing the circuit. Relays are necessary when there must be electrical isolation between controlled and control circuits, or when multiple circuits need to be controlled by a single signal.

Sample projects available on GitHub

Code Example

protected Relay relay;

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

    relay = new Relay(Device.CreateDigitalOutputPort(Device.Pins.D02));

    return Task.CompletedTask;
}

public override Task Run()
{
    var state = false;

    while (true)
    {
        state = !state;

        Resolver.Log.Info($"- State: {state}");
        relay.IsOn = state;

        Thread.Sleep(500);
    }
}

Sample project(s) available on GitHub

Wiring Example

Type

Returns type of relay.

Declaration
public RelayType Type { get; protected set; }

Property Value

Type Description
RelayType

Remarks

Relay
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

A relay is an electrically operated or electromechanical switch composed of an electromagnet, an armature, a spring and a set of electrical contacts. The electromagnetic switch is operated by a small electric current that turns a larger current on or off by either releasing or retracting the armature contact, thereby cutting or completing the circuit. Relays are necessary when there must be electrical isolation between controlled and control circuits, or when multiple circuits need to be controlled by a single signal.

Sample projects available on GitHub

Code Example

protected Relay relay;

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

    relay = new Relay(Device.CreateDigitalOutputPort(Device.Pins.D02));

    return Task.CompletedTask;
}

public override Task Run()
{
    var state = false;

    while (true)
    {
        state = !state;

        Resolver.Log.Info($"- State: {state}");
        relay.IsOn = state;

        Thread.Sleep(500);
    }
}

Sample project(s) available on GitHub

Wiring Example

Methods

Toggle()

Toggles the relay on or off.

Declaration
public void Toggle()

Remarks

Relay
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

A relay is an electrically operated or electromechanical switch composed of an electromagnet, an armature, a spring and a set of electrical contacts. The electromagnetic switch is operated by a small electric current that turns a larger current on or off by either releasing or retracting the armature contact, thereby cutting or completing the circuit. Relays are necessary when there must be electrical isolation between controlled and control circuits, or when multiple circuits need to be controlled by a single signal.

Sample projects available on GitHub

Code Example

protected Relay relay;

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

    relay = new Relay(Device.CreateDigitalOutputPort(Device.Pins.D02));

    return Task.CompletedTask;
}

public override Task Run()
{
    var state = false;

    while (true)
    {
        state = !state;

        Resolver.Log.Info($"- State: {state}");
        relay.IsOn = state;

        Thread.Sleep(500);
    }
}

Sample project(s) available on GitHub

Wiring Example