Skip to main content
Any Framework

Iot.Device.Relay assembly for .NET nanoFramework C# projects

Published
May 12, 2023
3y ago
Total Downloads
9.6K
9,607

Install

dotnet add package nanoFramework.Iot.Device.Relay4 --version 1.1.313

No framework information available.

README

Module and Unit 4 Relay - I2C relay

Module and Unit 4 Relay are a realys that can be piloted thru I2C. They are available with M5Stack.

Documentation

  • The 4 Relay Module documentation can be found here
  • The 4 Relay Unit documentation can be found here

Usage

Important: make sure you properly setup the I2C pins especially for ESP32 before creating the I2cDevice, make sure you install the nanoFramework.Hardware.ESP32 nuget:

//////////////////////////////////////////////////////////////////////
// when connecting to an ESP32 device, need to configure the I2C GPIOs
// used for the bus
Configuration.SetPinFunction(21, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK);

For other devices like STM32, please make sure you're using the preset pins for the SPI bus you want to use. The chip select can as well be pre setup.

using Iot.Device.Relay;
using System.Device.I2c;
using System.Threading;

Unit4Relay unit4Relay = new(new I2cDevice(new I2cConnectionSettings(1, Base4Relay.DefaultI2cAddress)));
// This will synchronize the led with the relay
unit4Relay.SynchronizedMode = true;
// Set relay 2, the led 2 should be on
unit4Relay.SetRelay(2, State.On);
// Set back the asyn modo
unit4Relay.SynchronizedMode = false;
// Set relay 1, the led 1 should be off while the relay on
unit4Relay.SetRelay(1, State.On);
// Set led 0 to on, the relay should be off
unit4Relay.SetLed(0, State.On);

Changes from Previous Version

No structural changes between v1.1.297 and v1.1.313.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

No SPDX license expression is published. Review the license text and your organisation's policy before redistribution.No target framework metadata is available. Confirm compatibility in a representative project before standardising on this package.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.